From f0290accd46ee45383b56b9acc9624f5707f6b0e Mon Sep 17 00:00:00 2001 From: Wouter Verhelst Date: Sat, 27 Oct 2018 18:38:26 +0000 Subject: Make the build fail on (useful) errors --- ci/README.md | 39 +++++++++++++++++++++++++++++++++++++++ ci/build-me | 37 +++++++++++++++++++++++++++++++++++++ ci/docker-image/Dockerfile | 11 +++++++++++ 3 files changed, 87 insertions(+) create mode 100644 ci/README.md create mode 100755 ci/build-me create mode 100644 ci/docker-image/Dockerfile (limited to 'ci') diff --git a/ci/README.md b/ci/README.md new file mode 100644 index 00000000000..4560a67f0b7 --- /dev/null +++ b/ci/README.md @@ -0,0 +1,39 @@ +Building the website with GitLab CI +=================================== + +On every commit, the website will be built. By default, only the +following parts will be built: + +- The english website (always). +- If any files were touched under a translation directory, that + translation. + +The built files will be made available as artifacts. These can be +browsed through the GitLab webinterface for basic review and validation +of any made changes. Note, however, that content negotiation does not +work on GitLab, and that internal links will be broken (because they +miss the `$language.html` suffix). This is expected. + +The build can be fine-tuned by setting the list of forced translations. +This list can be set in two ways: + +1. Add a line starting with `forced translations:` to the commit + message, followed by the list; +2. Set the environment variable `WEBWML_FORCED_TRANSLATIONS` to the + list of translations wanted. This can be done by going to the "CI/CD" + option in the left-hand-side menu of GitLab, then choosing + "Pipelines", and "Run Pipeline". There, fill out the name of the + variable in "Input variable key" and its value in "Input variable + value". You must be logged in and have access to the repository to be + able to do so (but you may fork the repository, if you prefer). + +If the list of translations is set to 'all', then all translations will +be built. If the list of translations is set to a space-separated list +of languages, then any language in that list will be built. + +To skip GitLab CI altogether, make sure that either `[skip ci]` or `[ci +skip]` occurs in the commit message. + +The CI jobs use a docker image that is stored in the GitLab container +registry. The Dockerfile for this image is stored [in this +repository](docker-image/Dockerfile) diff --git a/ci/build-me b/ci/build-me new file mode 100755 index 00000000000..b87ab7c9612 --- /dev/null +++ b/ci/build-me @@ -0,0 +1,37 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; + +my $is_forced = 0; +my @translations; + +if(defined($ENV{WEBWML_FORCE_TRANSLATIONS})) { + @translations = split(' ', $ENV{WEBWML_FORCED_TRANSLATIONS}); +} else { + if($ENV{CI_COMMIT_MESSAGE} =~ /force translations:(.*)/i) { + @translations = split(' ', $1); + } +} + +if(scalar(grep(/$ENV{CI_JOB_NAME}/, @translations)) > 0) { + exit 0; +} + +if(scalar(@translations) > 0 && $translations[0] eq 'all') { + exit 0; +} + +open GIT, "git log -p \$CI_COMMIT_BEFORE_SHA..HEAD|diffstat -p1 -l|"; + +while() { + next unless /\//; + my @dirparts = split(\//); + if($dirparts[0] eq $ENV{CI_JOB_NAME}) { + close GIT; + exit 0; + } +} + +close GIT; +exit 1; diff --git a/ci/docker-image/Dockerfile b/ci/docker-image/Dockerfile new file mode 100644 index 00000000000..c7b874ae38e --- /dev/null +++ b/ci/docker-image/Dockerfile @@ -0,0 +1,11 @@ +FROM debian:stretch +MAINTAINER Wouter Verhelst +RUN apt-get update +# This creates several layers. This is *ON PURPOSE*. The alternative is +# to have a nearly 2G single layer; pushing that takes multiple hours, +# and pulling that is sloooow too. +RUN apt-get -y install wml make gettext && apt-get clean +RUN apt-get -y install git opencc diffstat && apt-get clean +RUN apt-get -y install libintl-perl libxml-rss-perl wget libtimedate-perl libsoap-lite-perl liblocale-gettext-perl && apt-get clean +RUN apt-get -y install texlive-latex-base texlive-binaries texlive-fonts-recommended && apt-get clean +RUN apt-get -y install debiandoc-sgml python-lxml && apt-get clean -- cgit v1.2.3