Repository navigation
114 lines (100 loc) · 3.75 KB
/
Copy pathci-test-python.yml
File metadata and controls
114 lines (100 loc) · 3.75 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
#############################
## GitHub Actions CI Tests ##
#############################
#
# This is a reusable workflow to make CI tests more modular.
# See: https://docs.github.com/en/actions/using-workflows/reusing-workflows
#
# Called by ci-tests.yml
# This one does the python tests
#
name: Modular SQLFluff python test workflow
on:
workflow_call:
inputs:
python-version:
required: true
type: string
marks:
required: false
type: string
default: "not integration"
coverage:
required: false
type: boolean
default: false
with-rust:
required: true
type: string
secrets:
gh_token:
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.python-version }}-${{ inputs.marks }}-${{ inputs.coverage }}-${{ inputs.with-rust }}
cancel-in-progress: true
jobs:
modular-python-test:
runs-on: ubuntu-latest
name: py${{ inputs.python-version }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: |
requirements_dev.txt
pyproject.toml
constraints/*.txt
- name: Download built wheels
# Reuse the Linux x86_64 abi3 wheel across all supported CPython versions.
if: ${{ inputs.with-rust == '-rust' }}
uses: actions/download-artifact@v4
with:
path: ./dist
name: wheels-linux-x86_64
- name: Install dependencies
run: uv pip install --system tox tox-uv
- name: Parse Python Version
id: py_version
run: |
PYVERSION=$(echo "${{ inputs.python-version }}" | sed -e 's/\.//g')
echo "PYVERSION=$PYVERSION" >> $GITHUB_OUTPUT
# Run test process (with or without coverage).
# Arguments after the "--" are passed through to pytest:
# --cov=... The library to include in coverage reporting.
# -n 2 Runs with two parallel processes.
# test The path to detect tests within.
# -m ... The pytest marks to filter tests.
# --durations=16 Displays the 16 slowest runs to help with performance debugging.
- name: Run the tests (with coverage)
# NOTE: We have a separate job for coverage reporting because
# it impacts performance and slows the test suite significantly.
if: ${{ inputs.coverage }}
run: tox -e py${{ steps.py_version.outputs.PYVERSION }}${{ inputs.with-rust }} -- --cov=sqlfluff -n 2 test -m "${{ inputs.marks }}" --durations=16 --verbosity=0
- name: Run the tests (without coverage)
if: ${{ !inputs.coverage }}
run: tox -e py${{ steps.py_version.outputs.PYVERSION }}${{ inputs.with-rust }} -- -n 2 test -m "${{ inputs.marks }}" --durations=16 --verbosity=0
- name: Rename coverage files with suffix
# NOTE: We do this because we're using the same tox environment for multiple
# test jobs and we need to make sure that their coverage files don't collide.s
id: cov_suffix
if: ${{ inputs.coverage }}
run: |
COVSUFFIX=$(echo "${{ inputs.marks }}" | sed -e 's/ /-/g')
echo "COVSUFFIX=$COVSUFFIX" >> $GITHUB_OUTPUT
for file in .coverage.*; do mv "$file" "$file.$COVSUFFIX"; done;
- name: Upload coverage data (github)
uses: actions/upload-artifact@v4
if: ${{ inputs.coverage }}
with:
name: coverage-data-py${{ inputs.python-version }}-${{ inputs.marks }}${{ inputs.with-rust }}
path: ".coverage.*"
if-no-files-found: ignore
include-hidden-files: true