Repository navigation
106 lines (91 loc) · 2.88 KB
/
Copy pathcontinuous-integration.yml
File metadata and controls
106 lines (91 loc) · 2.88 KB
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
name: Continuous Integration
permissions:
contents: read
on:
push:
paths-ignore:
- "docs/**"
branches: [main]
pull_request:
paths-ignore:
- "docs/**"
branches:
- "**"
jobs:
Pre-commit-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Python 3.13
uses: actions/setup-python@v7
with:
python-version: 3.13
- name: Linting
run: |
pip install pre-commit
pre-commit run --all-files
Testing:
needs: pre-commit-checks
runs-on: ubuntu-latest
env:
RUN_CADC_TESTS: ${{ github.repository == 'CHIMEFRB/datatrail-cli' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
steps:
- uses: actions/checkout@v7
- name: Install uv
uses: astral-sh/setup-uv@v10.2.0
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
cache-python: true
python-version: ${{ matrix.python-version }}
- name: Installation
run: uv sync --locked
- name: Create NETRC file
if: env.RUN_CADC_TESTS == 'true'
env:
CANFAR_NETRC: ${{ secrets.CANFAR_NETRC }}
run: |
umask 077
test -n "$CANFAR_NETRC"
printf '%s\n' "$CANFAR_NETRC" > "$RUNNER_TEMP/CANFAR_NETRC"
- name: Obtain CADC certificate
if: env.RUN_CADC_TESTS == 'true'
run: |
umask 077
mkdir -p "$HOME/.ssl"
uv run --no-sync cadc-get-cert --netrc-file "$RUNNER_TEMP/CANFAR_NETRC" --days-valid 1 --cert-filename "$HOME/.ssl/cadcproxy.pem"
test -s "$HOME/.ssl/cadcproxy.pem"
openssl x509 -in "$HOME/.ssl/cadcproxy.pem" -noout -checkend 0
- name: Run tests
if: env.RUN_CADC_TESTS == 'true'
run: |
uv run --no-sync pytest tests/ --cov . --cov-report=lcov --cov-report=xml
- name: Run tests without CADC credentials
if: env.RUN_CADC_TESTS != 'true'
run: |
uv run --no-sync pytest tests/ -m "not cadc" --cov . --cov-report=lcov --cov-report=xml
- name: Remove NETRC file and CADC certificate
if: ${{ always() && env.RUN_CADC_TESTS == 'true' }}
run: |
rm -f -- "$RUNNER_TEMP/CANFAR_NETRC" "$HOME/.ssl/cadcproxy.pem"
- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: "coverage.lcov"
fail-on-error: false
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v7.1.1
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}