Repository navigation
123 lines (123 loc) · 5.85 KB
/
Copy path_tests.yml
File metadata and controls
123 lines (123 loc) · 5.85 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
---
# ─────────────────────────────────────────────────────────────────────────────
# _tests.yml
#
# Executes the project test suite using specified types and levels.
#
# Inputs:
# test_types (required) — Comma-separated list: smoke, sanity, regression
# test_levels (required) — Comma-separated list: unit, integration, e2e
# generate_coverage (optional) — Generate test coverage report (default: false)
# publish_results (optional) — Upload test results/coverage (default: true)
# retention_days (optional) — Days to retain artifacts (default: 7)
#
# Outputs:
# results_location — Path to the uploaded test results artifact
# coverage_location — Path to the uploaded coverage artifact
#
# Callers: development.yml, main.yml, nightly.yml, release.yml, weekly.yml
# ─────────────────────────────────────────────────────────────────────────────
name: "Test Runner (Reusable)"
on:
workflow_call:
inputs:
test_matrix:
description: "JSON array of test levels and types (e.g., '[{\"level\": \"unit\", \"\
types\": \"smoke, sanity\"}]')"
required: true
type: string
python_versions:
description: "JSON array of Python versions"
required: true
type: string
generate_coverage:
description: "Generate test coverage report"
required: false
type: boolean
default: false
publish_results:
description: "Publish test results as artifacts"
required: false
type: boolean
default: true
retention_days:
description: "Days to retain test artifacts"
required: false
type: number
default: 7
outputs:
results_location:
description: "Path to the test results artifact"
value: ${{ jobs.run-tests.outputs.results_location }}
coverage_location:
description: "Path to the coverage artifact"
value: ${{ jobs.run-tests.outputs.coverage_location }}
permissions:
contents: read
jobs:
run-tests:
name: "Run ${{ matrix.test-config.level }} Tests (Python ${{ matrix.python-version }})"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJson(inputs.python_versions) }}
test-config: ${{ fromJson(inputs.test_matrix) }}
outputs:
results_location: "reports/"
coverage_location: "coverage/"
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: "Set up Python ${{ matrix.python-version }}"
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{ matrix.python-version }}
- name: "Install uv"
run: pip install uv
- name: "Set up toolchain"
uses: pypa/hatch@install
- name: "Run tests"
run: |
# ───────────────────────────────────────────────────────────────────
# Level: ${{ matrix.test-config.level }}
# Types: ${{ matrix.test-config.types }}
# Coverage: ${{ inputs.generate_coverage }} / ${{ matrix.test-config.coverage }}
# ───────────────────────────────────────────────────────────────────
TYPES="${{ matrix.test-config.types }}"
MARKERS=$(echo "$TYPES" | sed 's/, / or /g' | sed 's/,/ or /g')
GENERATE_COVERAGE="false"
if [ "${{ inputs.generate_coverage }}" == "true" ] || [ "${{ matrix.test-config.coverage }}" == "true" ]; then
GENERATE_COVERAGE="true"
fi
if [[ -z "$TYPES" ]] || [[ "$TYPES" == *"smoke"* && "$TYPES" == *"sanity"* && "$TYPES" == *"regression"* ]]; then
if [ "$GENERATE_COVERAGE" == "true" ]; then
hatch run test:${{ matrix.test-config.level }}-cov --cov-report=xml:coverage/coverage.xml --cov-report=html:coverage/htmlcov --junitxml=reports/test-report.xml
else
hatch run test:${{ matrix.test-config.level }} --junitxml=reports/test-report.xml
fi
else
if [ "$GENERATE_COVERAGE" == "true" ]; then
hatch run test:${{ matrix.test-config.level }}-cov -m "$MARKERS" --cov-report=xml:coverage/coverage.xml --cov-report=html:coverage/htmlcov --junitxml=reports/test-report.xml
else
hatch run test:${{ matrix.test-config.level }} -m "$MARKERS" --junitxml=reports/test-report.xml
fi
fi
- name: Upload test results
if: ${{ inputs.publish_results }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: test-results-${{ matrix.test-config.level }}-py${{ matrix.python-version }}-${{
github.run_id }}
path: reports/
retention-days: ${{ inputs.retention_days }}
if-no-files-found: warn
- name: Upload coverage report
if: ${{ inputs.publish_results && (inputs.generate_coverage == true || matrix.test-config.coverage == true) }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: coverage-report-${{ matrix.test-config.level }}-py${{ matrix.python-version
}}-${{ github.run_id }}
path: coverage/
retention-days: ${{ inputs.retention_days }}
if-no-files-found: warn