-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (106 loc) · 4.07 KB
/
python-test.yaml
File metadata and controls
118 lines (106 loc) · 4.07 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
name: Python Test
on:
workflow_dispatch:
inputs:
package-name:
description: "Name of the package to test"
required: true
type: string
debug_enabled:
description: "Run with tmate.io debugging enabled"
required: false
type: boolean
default: false
checkout_ref:
description: "Git ref to checkout"
required: false
type: string
default: ""
force_run:
description: "Force execution even if cached"
required: false
type: boolean
default: false
workflow_call:
inputs:
package-name:
description: "Name of the package to test"
required: true
type: string
debug_enabled:
description: "Run with tmate.io debugging enabled"
required: false
type: string
default: "false"
checkout_ref:
description: "Git ref to checkout"
required: false
type: string
default: ""
force_run:
description: "Force execution even if cached"
required: false
type: string
default: "false"
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ inputs.checkout_ref != '' && inputs.checkout_ref || github.ref }}
- name: Check execution cache
id: cache
uses: ./.github/actions/cached-ci-job
with:
check-name: test (${{ inputs.package-name }})
hash-sources: 'packages/${{ inputs.package-name }}/**/*.py packages/${{ inputs.package-name }}/pyproject.toml packages/${{ inputs.package-name }}/uv.lock justfile **/*.nix flake.lock'
force-run: ${{ inputs.force_run || 'false' }}
- name: Setup Nix
if: steps.cache.outputs.should-run == 'true'
uses: ./.github/actions/setup-nix
with:
system: x86_64-linux
extra-conf: "system-features = nixos-test benchmark big-parallel kvm"
enable-cachix: true
cachix-name: ${{ vars.CACHIX_CACHE_NAME }}
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Setup tmate debug session
if: steps.cache.outputs.should-run == 'true' && inputs.debug_enabled == 'true'
uses: mxschmitt/action-tmate@c0afd6f790e3a5564914980036ebf83216678101 # v3
- name: Sync dependencies
if: steps.cache.outputs.should-run == 'true'
run: nix develop --accept-flake-config -c just ci-sync ${{ inputs.package-name }}
- name: Lint
if: steps.cache.outputs.should-run == 'true'
run: nix develop --accept-flake-config -c just ci-lint ${{ inputs.package-name }}
- name: Test
if: steps.cache.outputs.should-run == 'true'
run: nix develop --accept-flake-config -c just ci-test ${{ inputs.package-name }}
- name: Upload coverage
if: steps.cache.outputs.should-run == 'true'
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
- name: Create job result marker
if: success() && steps.cache.outputs.should-run == 'true' && steps.cache.outputs.cache-source == 'none'
run: |
mkdir -p "${{ steps.cache.outputs.cache-path }}"
cat > "${{ steps.cache.outputs.cache-path }}/marker" <<EOF
{
"success": true,
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"commit": "${{ github.sha }}",
"run_id": "${{ github.run_id }}",
"run_attempt": "${{ github.run_attempt }}"
}
EOF
- name: Save execution cache
if: success() && steps.cache.outputs.should-run == 'true' && steps.cache.outputs.cache-source == 'none'
uses: actions/cache/save@565629816435f6c0b50676926c9b05c254113c0c # ratchet:actions/cache/save@v4
with:
path: ${{ steps.cache.outputs.cache-path }}
key: ${{ steps.cache.outputs.cache-key }}