Repository navigation
125 lines (113 loc) · 3.74 KB
/
Copy path_tests-on-pr.yml
File metadata and controls
125 lines (113 loc) · 3.74 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
name: Tests on PR
on:
workflow_call:
inputs:
submodules:
description: 'Submodules to check out: false, true, or recursive'
default: 'false'
required: false
type: string
project:
description: 'Name of the project to test'
default: 'PROJECT_NAME'
required: false
type: string
python_version:
description: 'Python version for Conda environment. If not provided (or set to 0), the latest version will be read from pyproject.toml'
default: 0
required: false
type: number
c_extension:
description: 'Whether the project has a C extension'
default: false
required: false
type: boolean
headless:
description: 'Whether to run headless tests'
default: false
required: false
type: boolean
run:
description: 'Extra CLI commands to run after installing the project'
default: 'echo "No extra commands"'
required: false
type: string
upload_coverage:
description: 'Upload coverage to Codecov from within this workflow. Set to false for callers in a different GitHub organization, where cross-org secret passing is unsupported. Those callers should instead add a separate upload-coverage job using the coverage-report artifact produced here.'
default: true
required: false
type: boolean
secrets:
CODECOV_TOKEN:
description: 'Codecov token'
required: false
jobs:
get-python-version:
uses: ./.github/workflows/_get-python-version-latest.yml
with:
python_version: ${{ inputs.python_version }}
validate:
needs: get-python-version
defaults:
run:
shell: bash -l {0}
runs-on: ubuntu-latest
steps:
- name: Check out ${{ inputs.project }}
uses: actions/checkout@v6
with:
submodules: ${{ inputs.submodules }}
- name: Initialize miniconda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: test
channels: conda-forge
auto-update-conda: true
auto-activate-base: false
python-version: ${{ needs.get-python-version.outputs.latest_python_version }}
- name: Conda config
run: >-
conda config --set always_yes yes
--set changeps1 no
- name: Install ${{ inputs.project }} and requirements
run: |
conda install --file requirements/conda.txt
conda install --file requirements/tests.txt
if ${{ inputs.c_extension }}; then
conda install --file requirements/build.txt
fi
conda install pip
python -m pip install . --no-deps
- name: Run extra user-defined CLI commands
run: |
echo "${{ inputs.run }}" > user-commands.sh
bash user-commands.sh
- name: Start Xvfb
if: ${{ inputs.headless }}
run: |
sudo apt-get install -y xvfb
export DISPLAY=:99
Xvfb :99 -screen 0 1024x768x16 &
- name: Validate ${{ inputs.project }}
run: |
if ${{ inputs.headless }}; then
export DISPLAY=:99
fi
pytest --cov
coverage report -m
coverage xml
- name: Upload coverage report artifact
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml
retention-days: 1
- name: Upload coverage to Codecov
if: inputs.upload_coverage
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
verbose: true
fail_ci_if_error: true
slug: ${{ github.repository }}