Skip to content

Commit b80ce22

Browse files
authored
Simplify CI and use cache. (#1217)
remove tox.
1 parent e109817 commit b80ce22

File tree

9 files changed

+114
-1236
lines changed

9 files changed

+114
-1236
lines changed

.github/workflows/ci.yml

Lines changed: 93 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ name: CI
33
on:
44
workflow_dispatch:
55
inputs:
6-
run_check:
7-
description: 'Run checks'
6+
run_lint:
7+
description: 'Run lint'
88
required: false
99
default: true
1010
type: boolean
1111
run_test:
12-
description: 'Run tests'
12+
description: 'Run test'
1313
required: false
1414
default: true
1515
type: boolean
@@ -23,209 +23,162 @@ on:
2323
branches:
2424
- dev
2525

26+
2627
jobs:
27-
test:
28-
# Should match JOB_NAME below
29-
name: ${{ matrix.task.name }} - ${{ matrix.os.name }} ${{ matrix.python.name }} ${{ matrix.arch.name }}
28+
integreation_test:
29+
name: ${{ matrix.task.name }} - ${{ matrix.os.name }} ${{ matrix.python.name }}
3030
runs-on: ${{ matrix.os.runs-on }}
3131
container: ${{ matrix.os.container[matrix.python.docker] }}
32-
# present runtime seems to be about 2-4 minutes
33-
# with pypy being the exception (7 minutes)
34-
timeout-minutes: 15
32+
timeout-minutes: 10
3533
strategy:
3634
fail-fast: false
3735
matrix:
3836
task:
39-
- name: Test
40-
tox: test
41-
coverage: true
37+
- name: pylint
38+
type: lint
39+
cmd: pylint --recursive=y examples pymodbus test
40+
- name: codespell
41+
type: lint
42+
cmd: codespell
43+
- name: bandit
44+
type: lint
45+
cmd: bandit -r -c bandit.yaml .
46+
- name: flake8
47+
type: lint
48+
cmd: flake8
49+
- name: isort
50+
type: lint
51+
cmd: isort --check .
52+
- name: black
53+
type: lint
54+
cmd: black --check --safe --quiet examples/ pymodbus/ test/
55+
- name: docs
56+
type: lint
57+
cmd: make -C doc/ html
58+
- name: pytest
59+
type: test
60+
cmd: pytest --cov=pymodbus --cov=test --cov-report=term-missing --cov-report=xml -v --full-trace --timeout=20
4261
os:
4362
- name: Linux
4463
runs-on: ubuntu-latest
45-
matrix: linux
64+
activate: '. venv/bin/activate'
4665
container:
4766
3.8: docker://python:3.8-buster
4867
3.9: docker://python:3.9-buster
4968
3.10: docker://python:3.10-buster
5069
pypy3: docker://pypy:3-stretch
5170
- name: macOS
5271
runs-on: macos-latest
53-
matrix: macos
72+
activate: '. venv/bin/activate'
5473
- name: Windows
5574
runs-on: windows-latest
56-
matrix: windows
75+
activate: 'venv/Scripts/activate'
5776
ports: 5020-5099
58-
openssl:
59-
x86: win32
60-
x64: win64
6177
python:
6278
- name: CPython 3.8
63-
tox: py38
6479
action: 3.8
6580
docker: 3.8
6681
matrix: 3.8
6782
implementation: cpython
6883
- name: CPython 3.9
69-
tox: py39
7084
action: 3.9
7185
docker: 3.9
7286
matrix: 3.9
7387
implementation: cpython
7488
- name: 'CPython 3.10'
75-
tox: 'py310'
7689
action: '3.10'
7790
docker: '3.10'
7891
matrix: '3.10'
7992
implementation: cpython
8093
- name: PyPy 3.8
81-
tox: pypy38
8294
action: pypy-3.8
8395
docker: pypy3.8
8496
matrix: 3.8
8597
implementation: pypy
86-
openssl_msvc_version: 2019
8798
- name: PyPy 3.9
88-
tox: pypy39
8999
action: pypy-3.9
90100
docker: pypy3.9
91101
matrix: 3.9
92102
implementation: pypy
93-
openssl_msvc_version: 2019
94-
arch:
95-
- name: x86
96-
action: x86
97-
matrix: x86
98-
- name: x64
99-
action: x64
100-
matrix: x64
101103
exclude:
102-
- os:
103-
matrix: linux
104-
arch:
105-
matrix: x86
106-
- os:
107-
matrix: macos
108-
arch:
109-
matrix: x86
110-
- os:
111-
matrix: windows
104+
- task:
105+
type: lint
106+
os:
107+
name: macOS
108+
- task:
109+
type: lint
110+
os:
111+
name: Windows
112+
- task:
113+
type: lint
112114
python:
113-
implementation: pypy
114-
- os:
115-
matrix: macos
115+
matrix: 3.9
116+
- task:
117+
type: lint
118+
python:
119+
matrix: '3.10'
120+
- task:
121+
type: lint
116122
python:
117123
implementation: pypy
118-
env:
119-
# Should match name above
120-
JOB_NAME: ${{ matrix.task.name }} - ${{ matrix.os.name }} ${{ matrix.python.name }} ${{ matrix.arch.name }}
124+
- python:
125+
implementation: pypy
126+
os:
127+
name: macOS
128+
- python:
129+
implementation: pypy
130+
os:
131+
name: Windows
121132
steps:
122-
- uses: actions/checkout@v3
123-
with:
124-
fetch-depth: 0
133+
- name: Checkout repository
134+
uses: actions/checkout@v3
135+
125136
- name: Set up ${{ matrix.python.name }} (if CPython)
126-
if: ${{ job.container == '' && matrix.python.implementation == 'cpython'}}
137+
if: ${{ job.container == '' && matrix.python.implementation == 'cpython' }}
127138
uses: actions/setup-python@v3
128139
with:
129140
python-version: '${{ matrix.python.action }}.0-alpha - ${{ matrix.python.action }}.X'
130-
architecture: '${{ matrix.arch.action }}'
141+
check-latest: true
142+
131143
- name: Set up ${{ matrix.python.name }} (if PyPy)
132-
if: ${{ job.container == '' && matrix.python.implementation == 'pypy'}}
144+
if: ${{ job.container == '' && matrix.python.implementation == 'pypy' }}
133145
uses: actions/setup-python@v3
134146
with:
135147
python-version: '${{ matrix.python.action }}'
136-
architecture: '${{ matrix.arch.action }}'
137-
- name: Install
138-
run: |
139-
pip install --upgrade pip setuptools wheel
140-
pip install --upgrade tox
141-
- name: Test
142-
env:
143-
# When compiling Cryptography for PyPy on Windows there is a cleanup
144-
# failure. This is CI, it doesn't matter.
145-
PIP_NO_CLEAN: 1
146-
run: |
147-
tox -vv -e ${{ matrix.python.tox }}
148-
- name: Coverage Processing
149-
if: matrix.task.coverage
150-
run: |
151-
mkdir coverage_reports
152-
cp .coverage "coverage_reports/.coverage.${{ env.JOB_NAME }}"
153-
cp coverage.xml "coverage_reports/coverage.${{ env.JOB_NAME }}.xml"
154-
- name: Upload Coverage
155-
if: matrix.task.coverage
156-
uses: actions/upload-artifact@v3
157-
with:
158-
name: coverage
159-
path: coverage_reports/*
160-
check:
161-
# Should match JOB_NAME below
162-
name: ${{ matrix.task.name }} - ${{ matrix.os.name }} ${{ matrix.python.name }} ${{ matrix.arch.name }}
163-
runs-on: ${{ matrix.os.runs-on }}
164-
container: ${{ matrix.os.container[matrix.python.docker] }}
165-
strategy:
166-
fail-fast: false
167-
matrix:
168-
task:
169-
- name: pylint
170-
tox: pylint
171-
# continue_on_error: true
172-
- name: codespell
173-
tox: codespell
174-
# continue_on_error: true
175-
- name: bandit
176-
tox: bandit
177-
# continue_on_error: true
178-
- name: flake8
179-
tox: flake8
180-
# continue_on_error: true
181-
- name: isort
182-
tox: isort_CI
183-
# continue_on_error: true
184-
- name: black
185-
tox: black_CI
186-
# continue_on_error: true
187-
- name: Docs
188-
tox: docs
189-
# continue_on_error: true
190-
os:
191-
- name: Linux
192-
runs-on: ubuntu-latest
193-
matrix: linux
194-
container:
195-
3.8: docker://python:3.8-buster
196-
python:
197-
- name: CPython 3.8
198-
tox: py38
199-
action: 3.8
200-
docker: 3.8
201-
implementation: cpython
202-
arch:
203-
- name: x64
204-
action: x64
205-
matrix: x64
206-
env:
207-
# Should match name above
208-
JOB_NAME: ${{ matrix.task.name }} - ${{ matrix.os.name }} ${{ matrix.python.name }} ${{ matrix.arch.name }}
209-
steps:
210-
- uses: actions/checkout@v3
148+
check-latest: true
149+
150+
- name: venv restore
151+
id: cache-venv
152+
uses: actions/cache@v3
211153
with:
212-
fetch-depth: 0
213-
- name: Install
154+
path: venv
155+
key: "venv_${{ matrix.os.name }}_${{ matrix.python.name }}_${{ hashFiles('requirements.txt') }}"
156+
157+
- name: venv create
158+
if: ${{ steps.cache-venv.outputs.cache-hit != 'true' }}
214159
run: |
215-
pip install --upgrade pip setuptools wheel
216-
pip install --upgrade tox
217-
- name: Test format
218-
continue-on-error: ${{ matrix.task.continue_on_error == true }}
160+
python -m venv venv
161+
${{ matrix.os.activate }}
162+
pip install -r requirements.txt
163+
pip install -e .
164+
165+
- name: test
219166
run: |
220-
tox -vv -e ${{ matrix.task.tox }}
167+
${{ matrix.os.activate }}
168+
${{ matrix.task.cmd }}
169+
170+
- name: lint
171+
if: ${{ matrix.task.type == 'lint' && inputs.run_lint }}
172+
run: |
173+
${{ matrix.os.activate }}
174+
${{ matrix.task.cmd }}
175+
221176
all:
222177
name: All
223178
runs-on: ubuntu-latest
224179
needs:
225-
- check
226-
- test
180+
- integreation_test
227181
steps:
228182
- name: This
229-
shell: python
230183
run: |
231-
import this
184+
ls -l
Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1-
name: Clean
1+
name: Clean workflow runs
22
on:
33
workflow_dispatch:
4+
inputs:
5+
days:
6+
description: 'retain days (default 14)'
7+
required: false
8+
default: 14
9+
keeps:
10+
description: 'keep minimum runs (default 6)'
11+
required: false
12+
default: 6
413
schedule:
5-
# Daily at 05:20
6-
- cron: '50 11 * * *'
14+
# Sundays at 01:35 UTC.
15+
- cron: '35 1 * * 0'
716

817
jobs:
918
del_runs:
1019
runs-on: ubuntu-latest
1120
steps:
12-
- name: Delete workflow runs
21+
- name: Delete old workflow runs
1322
uses: Mattraks/delete-workflow-runs@v2
1423
with:
1524
token: ${{ github.token }}
1625
repository: ${{ github.repository }}
17-
retain_days: 10
18-
keep_minimum_runs: 6
26+
retain_days: ${{ github.events.inputs.days }}
27+
keep_minimum_runs: ${{ github.events.inputs.keeps }}

0 commit comments

Comments
 (0)