Skip to content

Commit 84759b3

Browse files
authored
Drop unsupported Python versions
* Update package setup * Update CI configuration * Address test issues * Mock timezone in test_create_dip_success
1 parent 9506c76 commit 84759b3

17 files changed

+72
-77
lines changed

.github/workflows/test.yml

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,65 +7,52 @@ on:
77
- "master"
88
jobs:
99
tox:
10-
name: "Test ${{ matrix.toxenv }}"
11-
runs-on: "ubuntu-20.04"
10+
name: "Test Python ${{ matrix.python-version }}"
11+
runs-on: "ubuntu-22.04"
1212
strategy:
1313
matrix:
14-
include:
15-
- python-version: "3.6"
16-
toxenv: "py36"
17-
- python-version: "3.7"
18-
toxenv: "py37"
19-
- python-version: "3.8"
20-
toxenv: "py38"
21-
- python-version: "3.9"
22-
toxenv: "py39"
14+
python-version: [
15+
"3.8",
16+
"3.9",
17+
"3.10",
18+
"3.11",
19+
"3.12",
20+
]
2321
steps:
2422
- name: "Check out repository"
25-
uses: "actions/checkout@v3"
23+
uses: "actions/checkout@v4"
2624
- name: "Set up Python ${{ matrix.python-version }}"
2725
uses: "actions/setup-python@v4"
2826
with:
2927
python-version: "${{ matrix.python-version }}"
30-
- name: "Get pip cache dir"
31-
id: "pip-cache"
32-
run: |
33-
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
34-
- name: "Cache pip packages"
35-
uses: "actions/cache@v3"
36-
with:
37-
path: "${{ steps.pip-cache.outputs.dir }}"
38-
key: "${{ runner.os }}-pip-${{ hashFiles('**/base.txt', '**/local.txt', '**/production.txt') }}"
39-
restore-keys: |
40-
${{ runner.os }}-pip-
28+
cache: "pip"
29+
cache-dependency-path: |
30+
requirements.txt
31+
requirements-dev.txt
4132
- name: "Install tox"
4233
run: |
4334
python -m pip install --upgrade pip
44-
pip install tox
35+
pip install tox tox-gh-actions
4536
- name: "Run tox"
46-
env:
47-
TOXENV: ${{ matrix.toxenv }}
4837
run: |
4938
tox -- --cov --cov-config .coveragerc --cov-report xml:coverage.xml
5039
- name: "Upload coverage report"
5140
if: github.repository == 'artefactual/automation-tools'
5241
uses: "codecov/codecov-action@v3"
5342
with:
5443
files: ./coverage.xml
55-
fail_ci_if_error: true
44+
fail_ci_if_error: false
5645
verbose: true
57-
name: ${{ matrix.toxenv }}
58-
flags: ${{ matrix.toxenv }}
5946
lint:
6047
name: "Lint"
6148
runs-on: "ubuntu-22.04"
6249
steps:
6350
- name: "Check out repository"
64-
uses: "actions/checkout@v3"
51+
uses: "actions/checkout@v4"
6552
- name: "Set up Python"
6653
uses: "actions/setup-python@v4"
6754
with:
68-
python-version: "3.8"
55+
python-version: "3.12"
6956
- name: "Install tox"
7057
run: |
7158
python -m pip install --upgrade pip

.pre-commit-config.yaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
repos:
22
- repo: https://github.com/asottile/pyupgrade
3-
rev: v2.31.0
3+
rev: v3.10.1
44
hooks:
55
- id: pyupgrade
6-
args: [--py3-plus, --py36-plus]
6+
args: [--py38-plus]
77
- repo: https://github.com/asottile/reorder_python_imports
8-
rev: v2.6.0
8+
rev: v3.10.0
99
hooks:
1010
- id: reorder-python-imports
11-
args: [--py3-plus, --py36-plus]
12-
- repo: https://github.com/ambv/black
13-
rev: 22.8.0
11+
args: [--py38-plus]
12+
- repo: https://github.com/psf/black
13+
rev: "23.7.0"
1414
hooks:
1515
- id: black
1616
args: [--safe, --quiet]
17-
language_version: python3
1817
- repo: https://github.com/pycqa/flake8
19-
rev: 5.0.4
18+
rev: "6.1.0"
2019
hooks:
2120
- id: flake8
22-
language_version: python3
21+
additional_dependencies:
22+
- flake8-bugbear==23.9.16
23+
- flake8-comprehensions==3.14.0

aips/create_dip.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,6 @@ def get_original_relpath(original_name):
444444

445445

446446
if __name__ == "__main__":
447-
448447
parser = argparse.ArgumentParser(
449448
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
450449
)
@@ -544,7 +543,7 @@ def get_original_relpath(original_name):
544543
# The main function returns the DIP's path on success
545544
# or an int higher than 0 if it fails. The scrip will
546545
# always exit with an int, 0 on success.
547-
if type(ret) != int:
546+
if not isinstance(ret, int):
548547
ret = 0
549548

550549
sys.exit(ret)

aips/create_dips_job.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def main(
133133
)
134134

135135
# Do not try upload on creation error
136-
if type(dip_path) == int:
136+
if isinstance(dip_path, int):
137137
LOGGER.error("Could not create DIP from AIP: %s", uuid)
138138
continue
139139

@@ -200,7 +200,6 @@ def filter_aips(aips, location_uuid, origin_pipeline_uuid):
200200

201201

202202
if __name__ == "__main__":
203-
204203
parser = argparse.ArgumentParser(
205204
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
206205
)

dips/copy_to_netx.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ def main(
231231

232232

233233
if __name__ == "__main__":
234-
235234
parser = argparse.ArgumentParser(
236235
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
237236
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-r base.txt
1+
-r requirements.txt
22
pytest==7.0.1
33
pytest-cov==4.0.0
44
vcrpy==4.1.1

requirements.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
-r requirements/production.txt
1+
amclient==1.2.3
2+
metsrw==0.4.0
3+
requests==2.31.0
4+
sqlalchemy==1.4.49
5+
urllib3==1.26.18

requirements/base.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

requirements/production.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/test_aips_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_init_success(self):
2020
assert os.path.isfile(DATABASE_FILE)
2121
assert "aip" in models.Base.metadata.tables
2222
assert hasattr(session, "add")
23-
assert callable(getattr(session, "add"))
23+
assert callable(session.add)
2424

2525
def test_init_fail(self):
2626
"""Test that the database can't be created in a wrong path."""

0 commit comments

Comments
 (0)