Skip to content

Commit

Permalink
Feature/unjank ci stuff (#38)
Browse files Browse the repository at this point in the history
* improve makefiles (fix racecondition for cleaning)

* update linter settings

* remove unnecessairy build step

* update actions

* use old design
  • Loading branch information
Rdeisenroth authored Aug 26, 2024
1 parent e8dfc42 commit 6d49fea
Show file tree
Hide file tree
Showing 13 changed files with 213 additions and 618 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@ jobs:
steps:
# 1. Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Set up Git repository
uses: actions/checkout@v3

# 2. Link texmf folder to the current texmf home
- name: Link texmf folder to the current texmf home
run: |
ln -s /root/texmf $(kpsewhich -var-value=TEXMFHOME)
texhash --verbose
uses: actions/checkout@v4

# 3. Build the documents
- name: "Build the documents"
Expand All @@ -47,7 +41,7 @@ jobs:
# 4. Upload artifacts to GitHub
- name: Upload artifacts to GitHub
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Vorkurs-Materialien
path: "pdfout/*.pdf"
Expand Down Expand Up @@ -92,7 +86,7 @@ jobs:
# save the pdf file from the previous workflow
- name: Save pdf file
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: .
name: Vorkurs-Materialien
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/check-formatting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Execute Pre-commit Hooks
uses: pre-commit/[email protected].0
uses: pre-commit/[email protected].1
15 changes: 7 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.6.0
hooks:
- id: mixed-line-ending
args: [--fix=lf]
- id: end-of-file-fixer
- id: check-yaml
# - id: check-added-large-files
- id: mixed-line-ending
args: [--fix=lf]
- repo: https://github.com/cmhughes/latexindent.pl.git
rev: V3.18
rev: V3.24.4
hooks:
- id: latexindent
args: ["--overwriteIfDifferent", "--silent", "-l=latexindent.yaml"]
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: 'v1.7.0' # Use the sha / tag you want to point at
- repo: https://github.com/hhatto/autopep8
rev: 'v2.3.1' # Use the sha / tag you want to point at
hooks:
- id: autopep8
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: '2.6.1' # pick a git hash / tag to point to
rev: '2.7.3' # pick a git hash / tag to point to
hooks:
- id: editorconfig-checker
exclude_types: [tex,python]
Expand Down
6 changes: 3 additions & 3 deletions codingchallenges/2021/2048-advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def printField(state: list, style: int = 1, color_new: bool = False, new_fields:
borderspacer = "|"
betweenspacer = "|"
else:
hlineupper = f"{('╭'+ '-' * maxLength+'╮')*len(state)}\n"
hlinelower = f"{('╰'+ '-' * maxLength+'╯')*len(state)}\n"
hlineupper = f"{('╭' + '-' * maxLength+'╮')*len(state)}\n"
hlinelower = f"{('╰' + '-' * maxLength+'╯')*len(state)}\n"
borderspacer = "|"
betweenspacer = "||"
for y, row in enumerate(state):
Expand Down Expand Up @@ -152,7 +152,7 @@ def printGameState(state: list, game_round: int, new_fields: list = [[3, 0]]):
print("\033[H\033[J\033[0m", end="")
print(f"Zug: {game_round}")
print(
f"Höchster Wert: {max(map(lambda x : max(map(lambda y : y if isinstance(y,int) else 0, x)),state))}")
f"Höchster Wert: {max(map(lambda x: max(map(lambda y: y if isinstance(y, int) else 0, x)), state))}")
printField(state, display_style, color_new, new_fields)


Expand Down
74 changes: 51 additions & 23 deletions exercises/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@
OUT_DIR := pdfout/
FILES := $(wildcard Aufgabe*.tex)

# Compile LaTeX with jobname and environment variables
# $1: tex file to compile
# $2: jobname (output file name without extension)
# $3: environment variables
# $4: directory to compile in
define compile_latex_with_jobname_and_env
cd $(4) && $(3) latexmk --shell-escape -synctex=1 -interaction=nonstopmode -file-line-error -lualatex -jobname=$(2) "$(1)"
endef

# Build LaTeX with jobname and environment variables, compile and copy to output directory
# $1: tex file to compile
# $2: jobname (output file name without extension)
# $3: environment variables
define build_latex_with_jobname_and_env
$(eval DIR := $(dir $(1)))
$(eval FILE := $(notdir $(1)))
Expand All @@ -17,7 +26,6 @@ define build_latex_with_jobname_and_env
endef

all:
$(MAKE) clean
$(MAKE) compile

$(FILES:.tex=.tex.regular):
Expand Down Expand Up @@ -47,31 +55,51 @@ $(FILES:.tex=.tex.sol.high-contrast):
compile: $(FILES:.tex=.tex.regular) $(FILES:.tex=.tex.sol.regular) $(FILES:.tex=.tex.dark) $(FILES:.tex=.tex.sol.dark) $(FILES:.tex=.tex.high-contrast) $(FILES:.tex=.tex.sol.high-contrast)
@echo -e "\e[1;42mAll Done. PDFs can be found in $(OUT_DIR)\e[0m"

# Remove files with a specific pattern recursively
# $1: pattern to match
# $2: additional global find parameters
# $3: additional directories to exclude
# Example: $(call remove_files,**/*.pdf, -maxdepth 1)
# explanation of find parameters:
# -depth: process each directory's contents before the directory itself (otherwise, the directory itself would be deleted first leading to errors when processing the contents)
# -not \( -path "*/.git/*" -prune \): exclude .git directories
# -wholename '$(1)': match the pattern
# -exec rm -rf {} \;: remove the matched files (-r also works on files, but is needed for directories)
define remove_files
@find . $(if $(strip $(2)),$(2),) -depth -not \( -path "*/.git/*" $(foreach dir,$(strip $(3)),-o -path "*/$(dir)*") -prune \) -wholename '$(1)' -exec rm -rf {} \;
endef

clean:
@echo -e "\e[1;34mCleaning up leftover build files...$<\e[0m"
@latexmk -C -f
@find . -wholename '**/options.cfg' -delete
@find . -maxdepth 1 -wholename '**/*.pdf' -delete
@find . -wholename '**/*.aux' -delete
@find . -wholename '**/*.fdb_latexmk' -delete
@find . -wholename '**/*.fls' -delete
@find . -wholename '**/*.len' -delete
@find . -wholename '**/*.listing' -delete
@find . -wholename '**/*.log' -delete
@find . -wholename '**/*.out' -delete
@find . -wholename '**/*.synctex.gz' -delete
@find . -wholename '**/*.toc' -delete
@find . -wholename '**/*.nav' -delete
@find . -wholename '**/*.snm' -delete
@find . -wholename '**/*.vrb' -delete
@find . -wholename '**/*.bbl' -delete
@find . -wholename '**/*.blg' -delete
@find . -wholename '**/*.idx' -delete
@find . -wholename '**/*.ilg' -delete
@find . -wholename '**/*.ind' -delete
@find . -wholename '**/*.pyg' -delete
@find . -wholename '**/*.bak[0-9]*' -delete
@find . -wholename '**/_minted-*' -delete
$(call remove_files,**/options.cfg)
$(call remove_files,**/*.pdf,,$(OUT_DIR) media)
$(call remove_files,**/*.aux)
$(call remove_files,**/*.fdb_latexmk)
$(call remove_files,**/*.fls)
$(call remove_files,**/*.len)
$(call remove_files,**/*.listing)
$(call remove_files,**/*.log)
$(call remove_files,**/*.out)
$(call remove_files,**/*.synctex.gz)
$(call remove_files,**/*.toc)
$(call remove_files,**/*.nav)
$(call remove_files,**/*.snm)
$(call remove_files,**/*.vrb)
$(call remove_files,**/*.bbl)
$(call remove_files,**/*.bbl-SAVE-ERROR)
$(call remove_files,**/*.bcf-SAVE-ERROR)
$(call remove_files,**/*.blg)
$(call remove_files,**/*.idx)
$(call remove_files,**/*.ilg)
$(call remove_files,**/*.ind)
$(call remove_files,**/*.pyg)
$(call remove_files,**/*.bcf)
$(call remove_files,**/*.xmpdata)
$(call remove_files,**/*.xmpi)
$(call remove_files,**/*.run.xml)
$(call remove_files,**/*.bak[0-9]*)
$(call remove_files,**/_minted-*)
@echo -e "\e[1;44mDone cleaning up leftover build files.$<\e[0m"

cleanBuild:
Expand Down
Loading

0 comments on commit 6d49fea

Please sign in to comment.