Skip to content

Commit 0786da8

Browse files
committed
Ignore v3 in CI if Python < 3.12
Signed-off-by: Thomas Calmant <thomas.calmant@gmail.com>
1 parent 34c971a commit 0786da8

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

.github/workflows/build-20.04.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ name: CI Build - Python 3.5-3.7
55

66
on:
77
push:
8-
branches: [ "master" ]
8+
branches: [ "main", "master" ]
99
tags: '**'
1010
pull_request:
11-
branches: [ "master" ]
11+
branches: [ "main", "master" ]
1212

1313
jobs:
1414
build:
@@ -34,13 +34,14 @@ jobs:
3434
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
3535
- name: Lint with flake8
3636
run: |
37+
# javaobj/v3 and tests/test_v3.py require Python 3.12+ syntax
3738
# stop the build if there are Python syntax errors or undefined names
38-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
39+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=javaobj/v3,tests/test_v3.py
3940
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
40-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
41+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=javaobj/v3,tests/test_v3.py
4142
- name: Test
4243
run: |
43-
coverage run -m pytest
44+
coverage run -m pytest --ignore=tests/test_v3.py
4445
- name: Coveralls
4546
env:
4647
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

.github/workflows/build-24.04.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,23 @@ jobs:
3232
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
3333
- name: Lint with flake8
3434
run: |
35-
# stop the build if there are Python syntax errors or undefined names
36-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
37-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
38-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
35+
# javaobj/v3 and tests/test_v3.py require Python 3.12+ syntax; exclude them on older versions
36+
if python -c "import sys; sys.exit(0 if sys.version_info >= (3, 12) else 1)"; then
37+
# stop the build if there are Python syntax errors or undefined names
38+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
39+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
40+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
41+
else
42+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=javaobj/v3,tests/test_v3.py
43+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=javaobj/v3,tests/test_v3.py
44+
fi
3945
- name: Test
4046
run: |
41-
coverage run -m pytest
47+
if python -c "import sys; sys.exit(0 if sys.version_info >= (3, 12) else 1)"; then
48+
coverage run -m pytest
49+
else
50+
coverage run -m pytest --ignore=tests/test_v3.py
51+
fi
4252
- name: Coveralls
4353
env:
4454
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

0 commit comments

Comments
 (0)