forked from spacetelescope/jwst
-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (122 loc) · 4.66 KB
/
Copy pathtests.yml
File metadata and controls
131 lines (122 loc) · 4.66 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: tests
on:
pull_request:
branches:
- main
- 'release/*.x'
types:
- opened
- synchronize
- reopened
- ready_for_review
push:
branches:
- main
- 'release/*.x'
tags:
- '*'
schedule:
- cron: "0 9 * * 1" # every Monday at 9a
workflow_dispatch:
inputs:
crds_context:
description: CRDS context (leave blank for latest)
type: string
required: false
default: ''
crds_server:
description: CRDS server
type: string
required: false
default: https://jwst-crds.stsci.edu
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ inputs.crds_context }}
cancel-in-progress: true
permissions: {}
env:
PYTHON_VERSIONS: 3.9 3.10 3.11 3.12 3.13 3.14
CRDS_PATH: /tmp/data/crds_cache
CRDS_OBSERVATORY: jwst
CRDS_SERVER_URL: ${{ inputs.crds_server || 'https://jwst-crds.stsci.edu' }}
CRDS_CLIENT_RETRY_COUNT: 3
CRDS_CLIENT_RETRY_DELAY_SECONDS: 20
jobs:
supported-pythons:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3"
- run: pip install packaging tomli
- name: convert Python version(s) into JSON list
id: versions
shell: python
run: |
import os
import json
import tomli
from packaging.specifiers import SpecifierSet
from packaging.version import Version
with open("pyproject.toml", "rb") as pyproject_toml_file:
version_requirements = SpecifierSet(tomli.load(pyproject_toml_file)["project"]["requires-python"])
versions = [str(version) for version in sorted([Version(version) for version in os.environ["PYTHON_VERSIONS"].split() if version in version_requirements])]
with open(os.environ["GITHUB_OUTPUT"], "a") as github_output:
print(f"json={json.dumps(versions)}", file=github_output)
print(f"oldest={versions[0]}", file=github_output)
print(f"latest={versions[-1]}", file=github_output)
outputs:
python-version-json: ${{ steps.versions.outputs.json }}
oldest: ${{ steps.versions.outputs.oldest }}
latest: ${{ steps.versions.outputs.latest }}
crds:
runs-on: ubuntu-latest
steps:
- if: inputs.crds_context
id: latest-context
run: >
echo latest-context=$(
curl -s -X POST -d '{"jsonrpc": "1.0", "method": "get_default_context", "params": ["${{ env.CRDS_OBSERVATORY }}", "latest"], "id": 1}' ${{ env.CRDS_SERVER_URL }}/json/ --retry 8 --connect-timeout 10 |
python -c "import sys, json; print(json.load(sys.stdin)['result'])"
) >> $GITHUB_OUTPUT
outputs:
path: ${{ env.CRDS_PATH }}
server-url: ${{ env.CRDS_SERVER_URL }}
context: ${{ inputs.crds_context || steps.latest-context.outputs.latest-context }}
client-retry-count: ${{ env.CRDS_CLIENT_RETRY_COUNT }}
client-retry-delay-seconds: ${{ env.CRDS_CLIENT_RETRY_DELAY_SECONDS }}
test:
needs:
- supported-pythons
- crds
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@4193751d511425d4edc1d5657c24b2128d49b017 # v2.6.4
with:
setenv: |
CRDS_PATH: ${{ needs.crds.outputs.path }}
CRDS_SERVER_URL: ${{ needs.crds.outputs.server-url }}
CRDS_CONTEXT: ${{ needs.crds.outputs.context }}
CRDS_CLIENT_RETRY_COUNT: ${{ needs.crds.outputs.client-retry-count }}
CRDS_CLIENT_RETRY_DELAY_SECONDS: ${{ needs.crds.outputs.client-retry-delay-seconds}}
cache-path: ${{ needs.crds.outputs.path }}
cache-key: crds-${{ needs.crds.outputs.context }}
envs: |
- linux: check-dependencies
python-version: ${{ needs.supported-pythons.outputs.latest }}
- name: run tests (oldest supported Python, ubuntu-latest)
linux: py3-oldestdeps-xdist-cov
python-version: ${{ needs.supported-pythons.outputs.oldest }}
- name: run tests with coverage (latest supported Python, ubuntu-latest)
linux: py3-cov
python-version: ${{ needs.supported-pythons.outputs.latest }}
pytest-results-summary: true
coverage: codecov
- name: run tests (latest supported Python, macos-latest)
macos: py3
python-version: ${{ needs.supported-pythons.outputs.latest }}
fill: true
fill_platforms: linux
fill_factors: xdist
artifact-path: |
results.xml