-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (95 loc) · 3.56 KB
/
dev-tools.yml
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
---
# Run all dev tools and update README.md
name: Run dev tools and update README.md
on: # yamllint disable-line rule:truthy
push:
branches:
- main
paths:
- '**.py'
pull_request:
permissions: read-all
jobs:
update_readme:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
- name: Install rssfixer and dev dependencies
run: |
python -m pip install poetry
poetry install --with dev,github --no-interaction
# yamllint disable rule:line-length
- name: Run bandit
run: poetry run bandit -l -f json -o resources/bandit.json -r src/rssfixer
# yamllint enable
# yamllint disable rule:line-length
- name: Commit updated bandit.json
id: commit_bandit
run: |
git add resources/bandit.json
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
if git diff --quiet && git diff --staged --quiet; then
echo "No changes in bandit.json, skipping commit."
echo "commit_status=skipped" >> "$GITHUB_ENV"
else
git commit -m "Update bandit.json"
echo "commit_status=committed" >> "$GITHUB_ENV"
fi
# yamllint enable
- name: Run update-readme.py
run: poetry run markdown-code-runner --verbose README.md
# yamllint disable rule:line-length
- name: Commit updated README.md
id: commit_readme
run: |
git add README.md
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
if git diff --quiet && git diff --staged --quiet; then
echo "No changes in README.md, skipping commit."
else
git commit -m "Update README.md"
echo "commit_status=committed" >> "$GITHUB_ENV"
fi
# yamllint enable
- name: Run coverage and create badge
run: |
poetry run coverage run -m pytest
poetry run coverage report -m > resources/coverage.txt
poetry run coverage-badge -f -q -o resources/coverage.svg
# yamllint disable rule:line-length
- name: Commit updated resources/coverage.txt resources/coverage.svg
id: commit
run: |
git add resources/coverage.txt resources/coverage.svg
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
if git diff --quiet && git diff --staged --quiet; then
echo "No changes in resources/coverage.txt or resources/coverage.svg, skipping commit."
else
git commit -m "Update resources/coverage.txt resources/coverage.svg"
echo "commit_status=committed" >> "$GITHUB_ENV"
fi
# yamllint enable
# yamllint disable rule:line-length
- name: Push changes
if: env.commit_status == 'committed' && github.actor != 'dependabot[bot]'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref }}
# yamllint enable