-
-
Notifications
You must be signed in to change notification settings - Fork 31
122 lines (110 loc) · 4.31 KB
/
autofix.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
name: Autofix
"on":
push:
# Only targets main branch to avoid amplification effects of auto-fixing
# the exact same stuff in multiple non-rebased branches.
branches:
- main
jobs:
autofix:
uses: kdeldycke/workflows/.github/workflows/[email protected]
with:
gitignore-extra-categories: node
format-css:
name: Generate Pygment styles, format CSS files and create a PR
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: "3.12"
- name: Install uv
run: |
python -m pip install -r https://raw.githubusercontent.com/kdeldycke/workflows/v4.1.4/requirements/uv.txt
- name: Install Pygments
run: |
uv venv --system
uv pip install .
- name: Generate Pygments styles
run: |
for STYLE in $(uv run pygmentize -L styles | grep -E '^\* .*\:$' | cut -d ' ' -f 2 | cut -d ':' -f 1);
do
CSS_FILE="./plumage/static/css/pygments/$STYLE.css"
uv run pygmentize -f html -S "$STYLE" -a ".pygments-style-$STYLE" > "$CSS_FILE"
# Crappy split of side-by-side declarations to please styleint.
sed -i "s/; /; \n/g" "$CSS_FILE"
done
- name: Install npm
run: |
sudo apt --quiet --yes install npm
- name: Install stylelint
run: |
npm install --save-dev stylelint stylelint-config-standard stylelint-config-sass-guidelines
- name: Autofix CSS
# Allow that step to fail so we can proceed with creating the auto-fix
# PR below.
run: |
npx stylelint --fix --config stylelint-config-standard "plumage/static/**/*.css" || true
npx stylelint --fix --config stylelint-config-sass-guidelines "plumage/static/**/*.scss" || true
- name: Discard all local changes but CSS files
run: |
# Remove untracked directories and files.
git clean -fd
# Temporarily stash our target files.
git stash -- '*.css'
git stash -- '*.scss'
# Reset all repository.
git checkout --force
# Restore modified files. Do not fail if no file has been stashed.
git stash pop || true
- uses: peter-evans/[email protected]
with:
assignees: ${{ github.actor }}
commit-message: "[autofix] Upgrade and format CSS style"
title: "[autofix] Upgrade and format CSS style"
body: >
<details><summary><code>Workflow metadata</code></summary>
> [Auto-generated on run `#${{ github.run_id }}`](${{ github.event.repository.html_url }}/actions/runs/${{
github.run_id }}) by `${{ github.job }}` job from [`autofix.yaml`](${{ github.event.repository.html_url
}}/blob/${{ github.sha }}/.github/workflows/autofix.yaml) workflow.
</details>
labels: "🤖 ci"
branch: autofix-css
format-jinja:
name: Format Jinja
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: "3.12"
- name: Install uv
run: |
python -m pip install -r https://raw.githubusercontent.com/kdeldycke/workflows/v4.1.4/requirements/uv.txt
- name: Install djlint
run: |
uv venv --system
uv pip install ".[test]"
- name: Autofix Jinja
run: >
uv run djlint
--reformat
--profile jinja
--format-css
--format-js
--warn
plumage/templates/*.html
- uses: peter-evans/[email protected]
with:
assignees: ${{ github.actor }}
commit-message: "[autofix] Format Jinja"
title: "[autofix] Format Jinja"
body: >
<details><summary><code>Workflow metadata</code></summary>
> [Auto-generated on run `#${{ github.run_id }}`](${{ github.event.repository.html_url }}/actions/runs/${{
github.run_id }}) by `${{ github.job }}` job from [`autofix.yaml`](${{ github.event.repository.html_url
}}/blob/${{ github.sha }}/.github/workflows/autofix.yaml) workflow.
</details>
labels: "🤖 ci"
branch: autofix-jinja