-
Notifications
You must be signed in to change notification settings - Fork 46
148 lines (128 loc) · 4.22 KB
/
main.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Continuous integration
on:
pull_request:
push:
branches:
- master
tags:
- '*'
env:
HAS_SECRETS: ${{ secrets.HAS_SECRETS }}
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
jobs:
checks:
name: Check with pre-commit and Prospector
runs-on: ubuntu-24.04
timeout-minutes: 15
if: "!startsWith(github.event.head_commit.message, '[skip ci] ')"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: python3 -m pip install --requirement=ci/requirements.txt
- name: Print environment information
run: c2cciutils-env
env:
GITHUB_EVENT: ${{ toJson(github) }}
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: "pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}\npre-commit-"
- run: pre-commit run --all-files
- run: git diff --exit-code --patch > /tmp/pre-commit.patch || true
if: failure()
- uses: actions/upload-artifact@v4
with:
name: Apply pre-commit fix.patch
path: /tmp/pre-commit.patch
retention-days: 1
if: failure()
- run: poetry install --extras=debug_images
- run: poetry run prospector --output=pylint --die-on-tool-error
test:
name: Run tests
runs-on: ubuntu-24.04
timeout-minutes: 15
needs:
- checks
strategy:
fail-fast: false
matrix:
python-version:
- '3.10'
- '3.11'
- '3.12'
steps:
- run: docker system prune --all --force
- name: GitHub event
run: echo ${GITHUB_EVENT} | python3 -m json.tool
env:
GITHUB_EVENT: ${{ toJson(github) }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v4
- run: python3 -m pip install $(grep poetry ci/requirements.txt)
- run: poetry install --extras=debug_images
- name: Versions
run: |
poetry --version
python --version
poetry run python --version
[ "$(python3 --version)" == "$(poetry run python --version)" ]
- run: |
poetry run coverage run --source=deskew --module pytest --durations=0 --verbose --color=yes \
--profile --profile-svg --junitxml=results/test-reports/junit.xml tests
poetry run coverage report
poetry run coverage html --directory=results/coverage
- uses: actions/upload-artifact@v4
with:
name: Test results (${{ matrix.python-version }})
path: results
if: always()
publish:
name: Publish package
runs-on: ubuntu-24.04
timeout-minutes: 15
needs:
- test
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.TOKEN }}
if: env.HAS_SECRETS == 'HAS_SECRETS'
- uses: actions/checkout@v4
if: env.HAS_SECRETS != 'HAS_SECRETS'
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: python3 -m pip install --requirement=ci/requirements.txt
- name: Init Git
run: |
git config credential.helper 'cache --timeout=120'
git config user.email "<ci@ci.com>"
git config user.name "CI"
if: env.HAS_SECRETS == 'HAS_SECRETS'
- name: Init pypi
run: |-
echo "[pypi]" > ~/.pypirc
echo "username = ${{ secrets.PYPI_USERNAME }}" >> ~/.pypirc
echo "password = ${{ secrets.PYPI_PASSWORD }}" >> ~/.pypirc
if: env.HAS_SECRETS == 'HAS_SECRETS'
- name: Publish
run: c2cciutils-publish
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
GITHUB_TOKEN: ${{ secrets.TOKEN }}
if: env.HAS_SECRETS == 'HAS_SECRETS'
- run: git diff --exit-code --patch > /tmp/dpkg-versions.patch || true
if: failure()
- uses: actions/upload-artifact@v4
with:
name: Update dpkg versions list.patch
path: /tmp/dpkg-versions.patch
retention-days: 1
if: failure()