Skip to content

Commit 0774027

Browse files
authored
Merge pull request #21 from IAS-Uni-Siegen/toolchain-improv
Toolchain improv
2 parents 1192231 + 0012963 commit 0774027

20 files changed

+514
-396
lines changed

.github/workflows/latex-ci.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: LaTeX + Python CI
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
jobs:
7+
format-check:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: Install latexindent binary
13+
run: |
14+
set -e
15+
curl -L -o latexindent-linux \
16+
https://github.com/cmhughes/latexindent.pl/releases/latest/download/latexindent-linux
17+
chmod +x latexindent-linux
18+
sudo mv latexindent-linux /usr/local/bin/latexindent
19+
echo "latexindent installed at:"
20+
which latexindent || echo "latexindent not found on PATH"
21+
22+
echo "latexindent verbose version info:"
23+
latexindent -vv
24+
25+
- name: Check LaTeX formatting with latexindent (dry-run)
26+
run: |
27+
set -e
28+
for ext in tex sty cls; do
29+
for file in $(find . -name "*.${ext}" || true); do
30+
formatted=$(latexindent -l=.latexindent.yml -o=- "$file")
31+
original=$(cat "$file")
32+
if [ "$formatted" != "$original" ]; then
33+
echo "::error file=$file::File is not properly formatted. Please run latexindent locally."
34+
exit 1
35+
fi
36+
done
37+
done
38+
echo "All LaTeX files are properly formatted!"
39+
40+
41+
- name: Install Python format tools
42+
run: |
43+
python -m pip install --upgrade pip
44+
pip install ruff
45+
46+
- name: Check Python + Notebook formatting (Ruff)
47+
run: |
48+
set -e
49+
50+
echo "Checking .py files formatting..."
51+
PY_FAILED=0
52+
for file in $(find . -name "*.py" -not -path "*/.*"); do
53+
if ! ruff format --check --config ./pyproject.toml "$file"; then
54+
echo "::error file=$file::Formatting check failed for $file."
55+
PY_FAILED=1
56+
fi
57+
done
58+
59+
echo "Checking .ipynb files formatting..."
60+
NB_FAILED=0
61+
for file in $(find . -name "*.ipynb" -not -path "*/.*"); do
62+
if ! ruff format --check --config ./pyproject.toml "$file"; then
63+
echo "::error file=$file::Formatting check failed for $file."
64+
echo "TIP: There is likely a trailing newline at the end of a code cell."
65+
ruff format --diff --config ./pyproject.toml "$file"
66+
NB_FAILED=1
67+
fi
68+
done
69+
70+
if [ $PY_FAILED -ne 0 ] || [ $NB_FAILED -ne 0 ]; then
71+
echo "Formatting check failed. You can check by running 'ruff format .' locally."
72+
exit 1
73+
fi
74+
75+
echo "All files passed formatting!"
76+
77+
build:
78+
needs: format-check
79+
runs-on: ubuntu-latest
80+
strategy:
81+
fail-fast: false
82+
matrix:
83+
tex:
84+
- test/testLecture.tex
85+
- test/testExercise.tex
86+
- test/testExam.tex
87+
steps:
88+
- uses: actions/checkout@v4
89+
90+
- name: Submodule-like setup
91+
run: |
92+
mkdir -p ../course_template
93+
rsync -av --exclude='.git' . ../course_template/
94+
mkdir -p ../../course_template
95+
ln -s "$PWD/theme" ../../course_template/theme || true
96+
ln -s "$PWD/style" ../../course_template/style || true
97+
98+
- uses: xu-cheng/latex-action@v3
99+
with:
100+
root_file: ${{ matrix.tex }}
101+
args: -pdf -interaction=nonstopmode -halt-on-error -shell-escape

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,6 @@ _site/
321321
# Ignore folders generated by Bundler
322322
.bundle/
323323
vendor/
324+
325+
# Ignore folders generated by ruff
326+
.ruff_cache/

.latexindent.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
onlyOneBackUp: 1
2+
maxNumberOfBackUps: 1
3+
backupExtension: .libak
4+
5+
defaultIndent: "\t"
6+
lookAtTheseModifyLineBreaks:
7+
environments: 1
8+
commands: 0
9+
ifElseFi: 1
10+
items: 1
11+
specialBeginEnd: 1
12+
13+
indentAfterHeadings:
14+
section:
15+
indentAfterThisHeading: 1
16+
level: 1
17+
subsection:
18+
indentAfterThisHeading: 1
19+
level: 2
20+
subsubsection:
21+
indentAfterThisHeading: 1
22+
level: 3
23+
24+
alignAtAmpersand:
25+
environments:
26+
aligned: 1
27+
matrix: 1
28+
tabular: 1
29+
array: 1
30+
spacesAfterAmpersand: 1
31+
32+
modifyLineBreaks:
33+
yaml: 1
34+
preserveBlankLines: 0
35+
condenseMultipleBlankLinesInto: 1
36+
37+
noAdditionalIndent:
38+
comment: 1
39+
verbatim: 1
40+
lstlisting: 1
41+
42+
preamble:
43+
indentPreamble: 1
44+
45+
maximumIndentation:
46+
environments: 10
47+
commands: 10

.vscode/extensions.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"James-Yu.latex-workshop",
4+
"charliermarsh.ruff"
5+
]
6+
}

.vscode/settings.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"latex-workshop.formatting.latexindent.path": "latexindent",
3+
"latex-workshop.formatting.latexindent.args": [
4+
"-m",
5+
"-l=%WORKSPACE_FOLDER%/.latexindent.yml",
6+
"%TMPFILE%",
7+
"-o=%TMPFILE%"
8+
],
9+
"editor.formatOnSave": true,
10+
"latex-workshop.formatting.latex": "latexindent",
11+
"ruff.configuration": "./pyproject.toml",
12+
"[python]": {
13+
"editor.formatOnSave": true,
14+
"editor.codeActionsOnSave": {
15+
"source.organizeImports": "explicit"
16+
},
17+
"editor.defaultFormatter": "charliermarsh.ruff"
18+
},
19+
"notebook.formatOnSave.enabled": true,
20+
"notebook.codeActionsOnSave": {
21+
"notebook.source.organizeImports": "explicit"
22+
}
23+
}

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,12 @@ This allows you to use the LaTeX classes provided in the course template reposit
110110
- All example themes contain a six-color palette designed to provide improved readability and accessibility for generated documents
111111
- This color palette is taken from ["Communicating Effectively in Color" by J. W. Kimball in IEEE Power Electronics Magazine](https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=10839151&isnumber=10839145).
112112

113+
### Contributing
114+
115+
- We recommend using [VSCode](https://code.visualstudio.com/) as code editor.
116+
- [Ruff](https://github.com/astral-sh/ruff) should be installed.
117+
118+
```bash
119+
pip install ruff
120+
```
121+
- It is expected that [LaTeX Workshop](https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop) and [Ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) extensions are installed so that formatting of the code is achieved automatically.

0 commit comments

Comments
 (0)