-
Notifications
You must be signed in to change notification settings - Fork 795
134 lines (117 loc) · 3.83 KB
/
Copy pathbuild_and_test.yml
File metadata and controls
134 lines (117 loc) · 3.83 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
126
127
128
129
130
131
132
133
134
# Builds the pyrit environment and runs all tests and pre-commit hooks
name: build_and_test
env:
PRE_COMMIT_PYTHON_VERSION: '3.11'
on:
push:
branches:
- "main"
pull_request:
branches:
- "main"
- "release/**"
merge_group:
workflow_dispatch:
concurrency:
# This ensures after each commit the old jobs are cancelled and the new ones
# run instead.
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
pre-commit:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
permissions:
contents: read
steps:
- uses: actions/checkout@v7
with:
# Full history is required so pre-commit hooks (notably
# enforce_alembic_revision_immutability) can compute merge-bases and
# diff ranges against origin/main.
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PRE_COMMIT_PYTHON_VERSION }}
- name: Cache pre-commit environments
uses: actions/cache@v6
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-${{ runner.os }}-
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
# Install a specific version of uv.
version: "0.9.17"
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
- name: Install dev extras
run: uv sync --extra all
- name: disk space
shell: bash
run: df -all -h
- name: Run pre-commit (all files)
# Always lint the ENTIRE repository on every event (pull_request,
# merge_group, push to main, workflow_dispatch). Running --all-files on
# PRs -- rather than only the files changed since origin/main -- ensures
# latent violations in untouched files, including the tests/integration,
# tests/partner_integration, and tests/end_to_end tiers, are caught before
# merge instead of only on the post-merge run against main.
run: |
git fetch origin main
uv run pre-commit run --all-files
# Main job runs only if pre-commit succeeded
main-job:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
package_name: ["pyrit"]
package_extras: ["dev", "dev_all"]
runs-on: ${{ matrix.os }}
# EnricoMi/publish-unit-test-result-action@v2 requires the following permissions
permissions:
contents: read
issues: read
checks: write
pull-requests: write
steps:
- uses: actions/checkout@v7
# Set up Python
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
# Install a specific version of uv.
version: "0.9.17"
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
# Install PyRIT with optional extras
- name: Install PyRIT with uv
# If the matrix extras is 'dev_all', then we install all extras
# otherwise just install the default dependencies
shell: bash
run: |
if [ "${{ matrix.package_extras }}" = "dev_all" ]; then
uv sync --extra all
else
uv sync
fi
- name: Run unit tests
run: make unit-test-junit
- name: Publish Pytest Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: runner.os == 'ubuntu-latest'
with:
files: '**/test-*.xml'