From a75cb05dfe66a8e9bc4b7a48222b15e2ecf51c74 Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sat, 31 Oct 2020 14:58:34 +0100 Subject: [PATCH 01/15] Add Makefile --- Makefile | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..753d847 --- /dev/null +++ b/Makefile @@ -0,0 +1,112 @@ +# ===================================================================================== +# ===================================================================================== +# Prerequisites +# ===================================================================================== +# ===================================================================================== + +# The following are "special targets", see: +# https://www.gnu.org/software/make/manual/html_node/Special-Targets.html#Special-Targets +# A phony target: not a file, just some routine. +.PHONY: clean preflight + +# ===================================================================================== +# Set variables, executables and their flags +# ===================================================================================== + +TEX = latexmk +TEX_FLAGS = + +PANDOC = pandoc +# For pandoc, provide dynamic metadata for the date. All other settings are in the +# `defaults` file. +PANDOC_FLAGS = \ + --defaults=pandoc/defaults.yaml \ + --metadata=date:$(shell date --iso-8601) + +# GitLab CI defines variables that we can check for. This allows us to detect if we're +# in a CI scenario. +# See also: +# https://www.gnu.org/software/make/manual/html_node/Conditional-Syntax.html#Conditional-Syntax +# https://docs.gitlab.com/ee/ci/variables/predefined_variables.html +ifdef CI + # pandoc is quiet by default + PANDOC_FLAGS += --verbose +else + # latexmk is verbose by default + TEX_FLAGS += --quiet +endif + +# ===================================================================================== +# ===================================================================================== +# Files to build +# ===================================================================================== +# ===================================================================================== + +# Produce all found tex files, but only the README.md (not CHANGELOG.md etc.): +SRC := $(wildcard *.tex) README.md + +# First rule is what is run by default if just using `make` with no arguments. +# It is the 'goal': https://www.gnu.org/software/make/manual/html_node/Goals.html. +# The name `all` is just a convention. +# Change suffix of multiple different extensions (.tex, .md), to the same suffix (.pdf). +# See also: https://stackoverflow.com/a/33926814 +all: preflight $(addsuffix .pdf, $(basename $(SRC))) + +# ===================================================================================== +# Rules for file building +# ===================================================================================== + +# This Makefile uses implicit rules, see: +# https://www.gnu.org/software/make/manual/html_node/Implicit-Rules.html#Implicit-Rules +# For those, Automatic Variables are important: +# https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html +# $*: "The stem with which an implicit rule matches" +# $<: "The name of the first prerequisite" +# $@: "The file name of the target of the rule" +# $^: "The names of all the prerequisites, with spaces between them" + +# Pattern rule, see: +# https://www.gnu.org/software/make/manual/html_node/Pattern-Rules.html, +# Just sets up an implicit rule to specify how to get from prerequisite to target, +# called whever `make` detects it needs to do so. No need to specify things manually. +%.pdf: %.tex + $(info Running $(TEX)...) + @$(TEX) $(TEX_FLAGS) $< + +PANDOC_TEMPLATE = $(strip $(shell grep "^template:" pandoc/defaults.yaml | cut --delimiter=":" --field=2)) +PANDOC_TEMPLATE_DIR = /usr/share/pandoc/data/templates + +%.pdf: %.md $(PANDOC_TEMPLATE_DIR)/$(PANDOC_TEMPLATE).latex + $(info Running $(PANDOC)...) + @$(PANDOC) $(PANDOC_FLAGS) --output=$@ $< + +EISVOGEL_ARCHIVE = Eisvogel.tar.gz + +# The `$(info ...)` function gives out-of-order logging, while `echo` works with the +# `wget` progress display. +$(PANDOC_TEMPLATE_DIR)/$(PANDOC_TEMPLATE).latex: + @echo Template not found at $@, downloading... + @wget --quiet --show-progress --no-clobber \ + "https://github.com/Wandmalfarbe/pandoc-latex-template/releases/latest/download/${EISVOGEL_ARCHIVE}" + @echo Extracting $(EISVOGEL_ARCHIVE)... + @tar --extract --file=${EISVOGEL_ARCHIVE} eisvogel.tex + @echo Moving template to $@. This is required for make to work reliably but \ + requires sudo privileges. + @sudo mv eisvogel.tex $@ + +# ===================================================================================== +# Help users install programs required for compilation. +# ===================================================================================== +preflight: + @echo Checking presence of required libraries... + @ldconfig --print-cache | grep --silent "librsvg" || \ + (echo "librsvg missing: required by pandoc to convert files containing SVGs."; exit 69) + @echo Libraries OK. + +clean: + $(warning "Removing generated and auxiliary files of ALL found tex files.") + @latexmk -C + $(warning "Removing remaining PDF files (e.g. those generated by pandoc).") + @rm *.pdf + $(warning "Removing downloaded pandoc archive.") + @rm $(EISVOGEL_ARCHIVE) From a7b879ccadc991385d8182eb918d8dcc1f456c07 Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sat, 31 Oct 2020 15:10:38 +0100 Subject: [PATCH 02/15] Rework clean rule --- Makefile | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 753d847..b240fee 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,8 @@ # Set variables, executables and their flags # ===================================================================================== -TEX = latexmk -TEX_FLAGS = +LATEXMK = latexmk +LATEXMK_FLAGS = PANDOC = pandoc # For pandoc, provide dynamic metadata for the date. All other settings are in the @@ -33,7 +33,7 @@ ifdef CI PANDOC_FLAGS += --verbose else # latexmk is verbose by default - TEX_FLAGS += --quiet + LATEXMK_FLAGS += --quiet endif # ===================================================================================== @@ -70,8 +70,8 @@ all: preflight $(addsuffix .pdf, $(basename $(SRC))) # Just sets up an implicit rule to specify how to get from prerequisite to target, # called whever `make` detects it needs to do so. No need to specify things manually. %.pdf: %.tex - $(info Running $(TEX)...) - @$(TEX) $(TEX_FLAGS) $< + $(info Running $(LATEXMK)...) + @$(LATEXMK) $(LATEXMK_FLAGS) $< PANDOC_TEMPLATE = $(strip $(shell grep "^template:" pandoc/defaults.yaml | cut --delimiter=":" --field=2)) PANDOC_TEMPLATE_DIR = /usr/share/pandoc/data/templates @@ -104,9 +104,11 @@ preflight: @echo Libraries OK. clean: - $(warning "Removing generated and auxiliary files of ALL found tex files.") - @latexmk -C - $(warning "Removing remaining PDF files (e.g. those generated by pandoc).") - @rm *.pdf - $(warning "Removing downloaded pandoc archive.") - @rm $(EISVOGEL_ARCHIVE) + @echo "Removing generated and auxiliary files of all found TeX files..." + @$(LATEXMK) -C $(LATEXMK_FLAGS) + @echo "Remaining PDF files are (e.g. those generated by pandoc):" + @ls *.pdf 2>/dev/null || echo "None." + @echo "Removing all remaining PDF files..." + @$(RM) *.pdf + @echo "Removing downloaded pandoc archive..." + @$(RM) $(EISVOGEL_ARCHIVE) From 0ba8812764d18a40fa8c6ee5fe3161d57e3bb3b3 Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sat, 31 Oct 2020 15:52:27 +0100 Subject: [PATCH 03/15] Add git short SHA to pandoc PDF metadata --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b240fee..af667d8 100644 --- a/Makefile +++ b/Makefile @@ -17,11 +17,11 @@ LATEXMK = latexmk LATEXMK_FLAGS = PANDOC = pandoc -# For pandoc, provide dynamic metadata for the date. All other settings are in the -# `defaults` file. +# For pandoc, provide dynamic metadata for the date. Git short SHA works both in CI and +# locally. All other settings are in the `defaults` file. PANDOC_FLAGS = \ --defaults=pandoc/defaults.yaml \ - --metadata=date:$(shell date --iso-8601) + --metadata=date:"$(shell date --iso-8601) ($(shell git rev-parse --short HEAD))" # GitLab CI defines variables that we can check for. This allows us to detect if we're # in a CI scenario. From dd7b97df76c9adbe76c50f9d078bb1b4b1969ec3 Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sat, 31 Oct 2020 15:57:26 +0100 Subject: [PATCH 04/15] Add quotes to all echos where missing Always a good idea, else black magic happens --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index af667d8..81790d2 100644 --- a/Makefile +++ b/Makefile @@ -85,23 +85,23 @@ EISVOGEL_ARCHIVE = Eisvogel.tar.gz # The `$(info ...)` function gives out-of-order logging, while `echo` works with the # `wget` progress display. $(PANDOC_TEMPLATE_DIR)/$(PANDOC_TEMPLATE).latex: - @echo Template not found at $@, downloading... + @echo "Template not found at $@, downloading..." @wget --quiet --show-progress --no-clobber \ "https://github.com/Wandmalfarbe/pandoc-latex-template/releases/latest/download/${EISVOGEL_ARCHIVE}" - @echo Extracting $(EISVOGEL_ARCHIVE)... + @echo "Extracting $(EISVOGEL_ARCHIVE)..." @tar --extract --file=${EISVOGEL_ARCHIVE} eisvogel.tex - @echo Moving template to $@. This is required for make to work reliably but \ - requires sudo privileges. + @echo "Moving template to $@. This is required for make to work reliably but \ + requires sudo privileges." @sudo mv eisvogel.tex $@ # ===================================================================================== # Help users install programs required for compilation. # ===================================================================================== preflight: - @echo Checking presence of required libraries... + @echo "Checking presence of required libraries..." @ldconfig --print-cache | grep --silent "librsvg" || \ (echo "librsvg missing: required by pandoc to convert files containing SVGs."; exit 69) - @echo Libraries OK. + @echo "Libraries OK." clean: @echo "Removing generated and auxiliary files of all found TeX files..." From 492d7cf6efb074c5a1757248d365810e9aec6e81 Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sat, 31 Oct 2020 16:03:59 +0100 Subject: [PATCH 05/15] Add more debugging output --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 81790d2..67c79ec 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,10 @@ # Set variables, executables and their flags # ===================================================================================== +# Configure latexmk tool using '.latexmkrc' in project root, not in here. LATEXMK = latexmk -LATEXMK_FLAGS = +# After the run, display the relevant rules (for debugging). +LATEXMK_FLAGS = --rules PANDOC = pandoc # For pandoc, provide dynamic metadata for the date. Git short SHA works both in CI and @@ -95,13 +97,15 @@ $(PANDOC_TEMPLATE_DIR)/$(PANDOC_TEMPLATE).latex: @sudo mv eisvogel.tex $@ # ===================================================================================== -# Help users install programs required for compilation. +# Help users install programs required for compilation and help debug. # ===================================================================================== preflight: @echo "Checking presence of required libraries..." @ldconfig --print-cache | grep --silent "librsvg" || \ (echo "librsvg missing: required by pandoc to convert files containing SVGs."; exit 69) @echo "Libraries OK." +# Output looks like: https://tex.stackexchange.com/a/311753/120853 + @$(LATEXMK) --commands clean: @echo "Removing generated and auxiliary files of all found TeX files..." From 028afa4f14b5cc272220b48d772ea5057a88310f Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sat, 31 Oct 2020 16:18:22 +0100 Subject: [PATCH 06/15] Move debug toggle into CI block --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 67c79ec..84193a7 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,7 @@ # Configure latexmk tool using '.latexmkrc' in project root, not in here. LATEXMK = latexmk -# After the run, display the relevant rules (for debugging). -LATEXMK_FLAGS = --rules +LATEXMK_FLAGS = PANDOC = pandoc # For pandoc, provide dynamic metadata for the date. Git short SHA works both in CI and @@ -33,6 +32,8 @@ PANDOC_FLAGS = \ ifdef CI # pandoc is quiet by default PANDOC_FLAGS += --verbose + # After the run, display the relevant rules (for debugging) + LATEXMK_FLAGS += --rules else # latexmk is verbose by default LATEXMK_FLAGS += --quiet From 7eb200500b9846ece3ff56701a83e0391a8840e8 Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sat, 31 Oct 2020 16:52:52 +0100 Subject: [PATCH 07/15] Fix gitignore paths --- .gitignore | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5c152b3..0f73440 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -## Generated PDF is not suitable for Git. We get our compiled PDF via CI anyway. - -*.pdf +# Generated PDF is not suitable for Git. We get our compiled PDF via CI. +# Only ignore root level PDF, since images/vectors might be in PDF format. +/*.pdf # Testing environment testing.tex @@ -19,7 +19,7 @@ dirty_directory/ *contourtmp* # Automatically generated files by svg package: -images/vectors/svg-inkscape +**/svg-inkscape/* ## Core latex/pdflatex auxiliary files: *.aux From b00e01c5dfcd82f3553426edf39e77cef81604cb Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sat, 31 Oct 2020 16:55:11 +0100 Subject: [PATCH 08/15] Introduce second clean job One regular clean job ('mostlyclean'), and one ('clean') thorough one --- Makefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 84193a7..713104c 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ # The following are "special targets", see: # https://www.gnu.org/software/make/manual/html_node/Special-Targets.html#Special-Targets # A phony target: not a file, just some routine. -.PHONY: clean preflight +.PHONY: clean mostlyclean preflight # ===================================================================================== # Set variables, executables and their flags @@ -108,12 +108,17 @@ preflight: # Output looks like: https://tex.stackexchange.com/a/311753/120853 @$(LATEXMK) --commands -clean: +# For target name, see: https://www.gnu.org/prep/standards/html_node/Standard-Targets.html +mostlyclean: @echo "Removing generated and auxiliary files of all found TeX files..." @$(LATEXMK) -C $(LATEXMK_FLAGS) @echo "Remaining PDF files are (e.g. those generated by pandoc):" @ls *.pdf 2>/dev/null || echo "None." @echo "Removing all remaining PDF files..." @$(RM) *.pdf - @echo "Removing downloaded pandoc archive..." + @echo "Removing downloaded pandoc archive, if any..." @$(RM) $(EISVOGEL_ARCHIVE) + +clean: mostlyclean + @echo "Removing all files ignored by git (.gitignore)..." + @git clean --force -xd From 305a324e1fc0b8963a3690fbcb9172753661301a Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sat, 31 Oct 2020 17:43:46 +0100 Subject: [PATCH 09/15] Fix PHONY targets, rework other targets --- Makefile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 713104c..67bd730 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ # The following are "special targets", see: # https://www.gnu.org/software/make/manual/html_node/Special-Targets.html#Special-Targets # A phony target: not a file, just some routine. -.PHONY: clean mostlyclean preflight +.PHONY: all clean mostlyclean tex preflight # ===================================================================================== # Set variables, executables and their flags @@ -45,15 +45,18 @@ endif # ===================================================================================== # ===================================================================================== -# Produce all found tex files, but only the README.md (not CHANGELOG.md etc.): -SRC := $(wildcard *.tex) README.md +# Produce all found tex files. +tex_sources = $(wildcard *.tex) +tex_pdfs := $(tex_sources:.tex=.pdf) # First rule is what is run by default if just using `make` with no arguments. # It is the 'goal': https://www.gnu.org/software/make/manual/html_node/Goals.html. # The name `all` is just a convention. # Change suffix of multiple different extensions (.tex, .md), to the same suffix (.pdf). # See also: https://stackoverflow.com/a/33926814 -all: preflight $(addsuffix .pdf, $(basename $(SRC))) +all: preflight tex README.pdf +# A rule for only LaTeX files: +tex: $(tex_pdfs) # ===================================================================================== # Rules for file building From 8a828db741563ddc96fa6e6fb1a58b6b986c92d4 Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sat, 31 Oct 2020 17:45:12 +0100 Subject: [PATCH 10/15] Move suffix to variable creation point, so that it is available everywhere Also improve logging output --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 67bd730..7fa7861 100644 --- a/Makefile +++ b/Makefile @@ -76,21 +76,21 @@ tex: $(tex_pdfs) # Just sets up an implicit rule to specify how to get from prerequisite to target, # called whever `make` detects it needs to do so. No need to specify things manually. %.pdf: %.tex - $(info Running $(LATEXMK)...) + $(info Running $(LATEXMK) to build $@...) @$(LATEXMK) $(LATEXMK_FLAGS) $< -PANDOC_TEMPLATE = $(strip $(shell grep "^template:" pandoc/defaults.yaml | cut --delimiter=":" --field=2)) +PANDOC_TEMPLATE = $(strip $(shell grep "^template:" pandoc/defaults.yaml | cut --delimiter=":" --field=2)).latex PANDOC_TEMPLATE_DIR = /usr/share/pandoc/data/templates -%.pdf: %.md $(PANDOC_TEMPLATE_DIR)/$(PANDOC_TEMPLATE).latex - $(info Running $(PANDOC)...) +%.pdf: %.md $(PANDOC_TEMPLATE_DIR)/$(PANDOC_TEMPLATE) + $(info Running $(PANDOC) to build $@...) @$(PANDOC) $(PANDOC_FLAGS) --output=$@ $< EISVOGEL_ARCHIVE = Eisvogel.tar.gz # The `$(info ...)` function gives out-of-order logging, while `echo` works with the # `wget` progress display. -$(PANDOC_TEMPLATE_DIR)/$(PANDOC_TEMPLATE).latex: +$(PANDOC_TEMPLATE_DIR)/$(PANDOC_TEMPLATE): @echo "Template not found at $@, downloading..." @wget --quiet --show-progress --no-clobber \ "https://github.com/Wandmalfarbe/pandoc-latex-template/releases/latest/download/${EISVOGEL_ARCHIVE}" From 1fe81d1c530e34c1244111d686a85d27608d0d9f Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sat, 31 Oct 2020 17:46:03 +0100 Subject: [PATCH 11/15] Fix echo newline having too much whitespace --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7fa7861..30aeccb 100644 --- a/Makefile +++ b/Makefile @@ -96,8 +96,7 @@ $(PANDOC_TEMPLATE_DIR)/$(PANDOC_TEMPLATE): "https://github.com/Wandmalfarbe/pandoc-latex-template/releases/latest/download/${EISVOGEL_ARCHIVE}" @echo "Extracting $(EISVOGEL_ARCHIVE)..." @tar --extract --file=${EISVOGEL_ARCHIVE} eisvogel.tex - @echo "Moving template to $@. This is required for make to work reliably but \ - requires sudo privileges." + @echo "Moving template to $@. This is required for make to work reliably but requires sudo privileges." @sudo mv eisvogel.tex $@ # ===================================================================================== From 7a852cc6654e23bd823ee3bef8f51c2a2df741c4 Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sat, 31 Oct 2020 17:46:29 +0100 Subject: [PATCH 12/15] Add pandoc template cleanup to thorough clean job --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 30aeccb..f9ac3ea 100644 --- a/Makefile +++ b/Makefile @@ -124,3 +124,5 @@ mostlyclean: clean: mostlyclean @echo "Removing all files ignored by git (.gitignore)..." @git clean --force -xd + @echo "Removing pandoc template..." + @sudo $(RM) $(PANDOC_TEMPLATE_DIR)/$(PANDOC_TEMPLATE) From 8b12544469e30b85f5462ca3694fedb772c918ac Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sat, 31 Oct 2020 17:46:52 +0100 Subject: [PATCH 13/15] Adjust CI config to use make program --- .gitlab-ci.yml | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8ff6ba8..d43ce32 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,6 +6,11 @@ default: # Override any entrypoint back to a naked shell so that job `script`s can be # executed normally. # See also: https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#overriding-the-entrypoint-of-an-image + # Cannot use `make` as ENTRYPOINT even if all scripts used it: runner expects an + # entrypoint that accepts shell scripts ("the runner expects that the image has + # no entrypoint or that the entrypoint is prepared to start a shell command. ") + # See also: + # https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#overriding-the-entrypoint-of-an-image entrypoint: [ "" ] # LaTeX and pandoc stages both provide PDFs: artifacts: @@ -19,28 +24,20 @@ default: # only: # - tags +preflight: + stage: .pre + script: + - make preflight + # Preflight checks are relevant, but we are interested in how exactly later jobs + # error out if preflight fails. Therefore, allow failure. + allow_failure: true + build_latex: stage: build script: - # For debugging: show commands that will be used for compilation, as configured - # after reading all found config (RC) files. - # Looks like: https://tex.stackexchange.com/a/311753/120853 - - latexmk --commands - # No *.tex-file given as argument to latexmk: run on all *.tex-files found in root. - # Configure latexmk tool using '.latexmkrc' in project root. - # After the run, display the relevant rules (for debugging). - - latexmk --rules + - make tex build_pandoc: stage: build - variables: - README_BASENAME: "README" script: - # Provide dynamic metadata for the date. All other settings are in the `defaults` - # file. - - | - pandoc \ - --defaults=pandoc/defaults.yaml \ - --metadata=date:$(date --iso-8601) \ - --output=${README_BASENAME}.pdf \ - ${README_BASENAME}.md + - make README.pdf From b30eac7d71b4f8b5a6bf60194c763f9ec802dfb2 Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sat, 31 Oct 2020 18:38:42 +0100 Subject: [PATCH 14/15] Turn off artifacts for job --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d43ce32..d4a3ab0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,6 +31,9 @@ preflight: # Preflight checks are relevant, but we are interested in how exactly later jobs # error out if preflight fails. Therefore, allow failure. allow_failure: true + inherit: + # Do not inherit artifacts, this stage has none. + default: [image] build_latex: stage: build From ecd2fb911059f665a6ffe6ab3e80b9ba74ffab2b Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Sat, 31 Oct 2020 18:52:31 +0100 Subject: [PATCH 15/15] Fix git short SHA retrieval Manual retrieval with 'git rev-parse' did not work in CI --- Makefile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index f9ac3ea..74c5698 100644 --- a/Makefile +++ b/Makefile @@ -18,11 +18,9 @@ LATEXMK = latexmk LATEXMK_FLAGS = PANDOC = pandoc -# For pandoc, provide dynamic metadata for the date. Git short SHA works both in CI and -# locally. All other settings are in the `defaults` file. -PANDOC_FLAGS = \ - --defaults=pandoc/defaults.yaml \ - --metadata=date:"$(shell date --iso-8601) ($(shell git rev-parse --short HEAD))" +# For pandoc, provide dynamic metadata for the date (see below). Git short SHA works +# both in CI and locally. All other settings are in the `defaults` file. +PANDOC_FLAGS = --defaults=pandoc/defaults.yaml # GitLab CI defines variables that we can check for. This allows us to detect if we're # in a CI scenario. @@ -30,15 +28,19 @@ PANDOC_FLAGS = \ # https://www.gnu.org/software/make/manual/html_node/Conditional-Syntax.html#Conditional-Syntax # https://docs.gitlab.com/ee/ci/variables/predefined_variables.html ifdef CI + GIT_SHORT_SHA = $$CI_COMMIT_SHORT_SHA # pandoc is quiet by default PANDOC_FLAGS += --verbose # After the run, display the relevant rules (for debugging) LATEXMK_FLAGS += --rules else # latexmk is verbose by default + GIT_SHORT_SHA = $(shell git rev-parse --short HEAD) LATEXMK_FLAGS += --quiet endif +PANDOC_FLAGS += --metadata=date:"$(shell date --iso-8601) ($(GIT_SHORT_SHA))" + # ===================================================================================== # ===================================================================================== # Files to build