-
Notifications
You must be signed in to change notification settings - Fork 46
116 lines (105 loc) · 3.48 KB
/
ci.yaml
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
name: CI
env:
RUFF_UNRELEASED_REF: "main"
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: |
pyproject.toml
requirements.txt
requirements-dev.txt
- name: Install dependencies
run: just install
- name: Run checks
run: just check
ruff-versions:
name: Generate test versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get install -y ripgrep
- name: Determine test versions
id: set-versions
run: |
# Get the latest release version from GitHub
LATEST=$( \
curl -L \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/astral-sh/ruff/releases/latest \
| jq '.tag_name' --raw-output \
)
# Get the oldest supported version from the pyproject.toml
OLDEST=$(rg -No '"ruff>=(.*)"' -r '$1' pyproject.toml)
UNRELEASED=${{ env.RUFF_UNRELEASED_REF }}
echo "::set-output name=latest::$LATEST"
echo "::set-output name=oldest::$OLDEST"
echo "::set-output name=dev::$UNRELEASED"
outputs:
latest: ${{ steps.set-versions.outputs.latest }}
oldest: ${{ steps.set-versions.outputs.oldest }}
dev: ${{ steps.set-versions.outputs.dev }}
test:
name: Test (python-${{ matrix.python-version }}, ruff-${{ matrix.ruff-version }}, ${{ matrix.os }})
needs: ruff-versions
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, macos-13, windows-latest]
include:
- ruff-version: ${{ needs.ruff-versions.outputs.latest }}
- ruff-version: ${{ needs.ruff-versions.outputs.oldest }}
os: ubuntu-latest
python-version: "3.7"
- ruff-version: ${{ needs.ruff-versions.outputs.dev }}
os: ubuntu-latest
python-version: "3.12"
runs-on: ${{ matrix.os }}
steps:
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
pyproject.toml
requirements.txt
requirements-dev.txt
- name: Install dependencies
run: |
pip install -U pip
just install
- name: Install test Ruff version from PyPI
if: ${{ matrix.ruff-version != env.RUFF_UNRELEASED_REF }}
run: |
pip install ruff==${{ matrix.ruff-version }}
ruff --version
- name: "Install test Ruff version from GitHub"
if: ${{ matrix.ruff-version == env.RUFF_UNRELEASED_REF }}
run: |
pip install --force-reinstall git+https://github.com/astral-sh/ruff@${{ matrix.ruff-version }}
pip show ruff
ruff version
- name: Run tests
run: just test