Skip to content

Commit cb3dc7a

Browse files
Merge pull request #358 from python-accelerator-middle-layer/tests-several-python-versions
Update workflow for unit tests to test against several python versions
2 parents 6e28b79 + ef7a196 commit cb3dc7a

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
# This workflow will install Python dependencies, run tests and lint with a single version of Python
1+
# This workflow will install Python dependencies, run tests and lint with a several version of Python
22
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
33

4-
name: run tests
4+
name: Run unit tests
55

66
on:
77
push:
88
branches: [ "main" ]
99
pull_request:
10+
workflow_dispatch:
1011

1112
permissions:
1213
contents: read
@@ -15,27 +16,39 @@ jobs:
1516
build:
1617

1718
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
python-version: >-
23+
${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
24+
&& fromJSON(vars.PYTHON_ALL_SUPPORTED_TEST_VERSIONS)
25+
|| fromJSON(vars.PYTHON_DEFAULT_TEST_VERSIONS) }}
1826
1927
steps:
20-
- uses: actions/checkout@v4
21-
with:
22-
submodules: recursive
23-
- name: Set up Python 3.12
24-
uses: actions/setup-python@v3
28+
- uses: actions/checkout@v6
29+
30+
- name: Set up Python ${{ matrix.python-version }}
31+
uses: actions/setup-python@v7
2532
with:
26-
python-version: ">=3.12"
33+
python-version: ${{ matrix.python-version }}
34+
2735
- name: Install dependencies
2836
run: |
2937
python -m pip install --upgrade pip
3038
pip install .[test]
3139
pip install ./tests/dummy_cs/tango-pyaml
3240
pip install ./tests/external
3341
pip install flake8
42+
43+
- name: Display Python version
44+
run: python -c "import sys; print(sys.version)"
45+
3446
- name: Lint with flake8
3547
run: |
3648
# stop the build if there are Python syntax errors or undefined names
3749
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3850
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
3951
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
52+
4053
- name: Test with pytest
4154
run: python -m pytest tests

0 commit comments

Comments
 (0)