-
Notifications
You must be signed in to change notification settings - Fork 4
128 lines (123 loc) · 4.23 KB
/
tests.yml
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
# run test suites
name: Tests
on:
- pull_request
- push
- release
- workflow_dispatch
# cancel the current workflow if another commit was pushed on the same PR or reference
# uses the GitHub workflow name to avoid collision with other workflows running on the same PR/reference
concurrency:
group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}"
cancel-in-progress: true
jobs:
# see: https://github.com/fkirc/skip-duplicate-actions
skip_duplicate:
continue-on-error: true
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_duplicate.outputs.should_skip && ! contains(github.ref, 'refs/tags') }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: "same_content"
skip_after_successful_duplicate: "true"
do_not_skip: '["pull_request", "workflow_dispatch", "schedule", "release"]'
# see: https://github.com/actions/setup-python
tests:
needs: skip_duplicate
if: ${{ needs.skip_duplicate.outputs.should_skip != 'true' }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.allow-failure }}
env:
# override make command to install directly in active python
CONDA_CMD: ""
services:
# Label used to access the service container
mongodb:
image: mongo:3.4.23 # DockerHub
ports:
- "27017:27017"
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
allow-failure: [false]
test-case: [test-local]
include:
# linter tests
- os: ubuntu-latest
python-version: 3.11
allow-failure: false
test-case: lint
# coverage test
- os: ubuntu-latest
python-version: 3.11
allow-failure: false
test-case: coverage
# smoke test of Docker image
- os: ubuntu-latest
python-version: None # doesn't matter which one (in docker), but match default of repo
allow-failure: false
test-case: docker-test
# deprecated versions
- os: ubuntu-latest
python-version: 3.8 # EOL 2024-10
allow-failure: false
test-case: test-local
steps:
- uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: Setup Python
uses: actions/setup-python@v5
if: ${{ matrix.python-version != 'None' }}
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
if: ${{ matrix.python-version != 'None' }}
# install package and dependencies directly,
# skip sys/conda setup to use active python
run: make install develop
- name: Display Packages
if: ${{ matrix.python-version != 'None' }}
run: pip freeze
- name: Display Environment Variables
run: |
hash -r
env | sort
- name: Run Tests
run: make --no-keep-going ${{ matrix.test-case }}
- name: Stop Workers
if: ${{ matrix.python-version == 'None' }}
run: make docker-stop
- name: Upload coverage report
uses: codecov/codecov-action@v4.0.1
if: ${{ success() && matrix.test-case == 'coverage' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/coverage.xml
fail_ci_if_error: true
verbose: true
deploy_pypi:
needs: tests
# Don't match master branch for upload to avoid duplicate error, even if the tag is usually applied on master.
if: ${{ success() && github.event_name == 'push' && contains(github.ref, 'refs/tags') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Build Distribution Package
run: make develop dist
- name: Push Package to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true # For debugging 'twine upload' if a problem occurs.