Skip to content

Commit 98efaa2

Browse files
committed
gh nox action
1 parent e55d369 commit 98efaa2

2 files changed

Lines changed: 88 additions & 10 deletions

File tree

.github/workflows/nox.yaml

Lines changed: 73 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,87 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16+
generate-matrix:
17+
runs-on: ubuntu-24.04
18+
19+
outputs:
20+
sessions: ${{ steps.set-matrix.outputs.sessions }}
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: "Set up Python"
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version-file: "pyproject.toml"
30+
31+
- name: Install uv
32+
uses: astral-sh/setup-uv@v6
33+
34+
- id: set-matrix
35+
name: Set nox sessions for matrix
36+
run: |
37+
set -euo pipefail
38+
echo "sessions=$(uv run --only-group nox -- tasks/gh-nox-sessions)" >> $GITHUB_OUTPUT
39+
env:
40+
PYTHONPATH: './src'
41+
1642
nox:
17-
runs-on: ubuntu-latest
43+
needs: generate-matrix
44+
runs-on: ubuntu-24.04
45+
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
session: ${{ fromJson(needs.generate-matrix.outputs.sessions) }}
1850

19-
# Runs all steps inside this container
20-
container:
21-
image: ghcr.io/level12/ubuntu-mive:24-3.12
22-
options: --user root
51+
services:
52+
postgres:
53+
image: postgres:17
54+
env:
55+
POSTGRES_HOST_AUTH_METHOD: trust
56+
ports:
57+
- 5432:5432
58+
options: >-
59+
--health-cmd="pg_isready -U postgres"
60+
--health-interval=3s
61+
--health-timeout=3s
62+
--health-retries=15
63+
64+
mssql:
65+
image: mcr.microsoft.com/mssql/server:2019-latest
66+
env:
67+
ACCEPT_EULA: Y
68+
SA_PASSWORD: Docker-sa-password
69+
ports:
70+
- 1433:1433
71+
options: >-
72+
--health-cmd="/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U SA -P Docker-sa-password -Q \"select 'ok'\""
73+
--health-interval=3s
74+
--health-timeout=3s
75+
--health-retries=15
2376
2477
env:
2578
UV_LINK_MODE: copy
2679

2780
steps:
28-
- name: Checkout Code
81+
- name: Checkout
2982
uses: actions/checkout@v4
3083

31-
- name: Mark repo as safe for Git
32-
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
84+
- name: "Set up Python"
85+
uses: actions/setup-python@v5
86+
with:
87+
python-version-file: "pyproject.toml"
88+
89+
- name: Install uv
90+
uses: astral-sh/setup-uv@v6
91+
92+
# MSSQL sessions need ODBC driver in the runner
93+
- name: Install MS ODBC driver (Ubuntu)
94+
if: contains(matrix.session, 'pytest_mssql')
95+
run: tasks/odbc-driver-install
3396

34-
- name: Run Tests
97+
- name: Run Nox session
3598
run: |
36-
uv run --only-group nox -- nox
99+
uv run --only-group nox -- nox -s "${{ matrix.session }}"

tasks/gh-nox-sessions

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
# mise description='Nox session list for GH CI'
3+
import json
4+
5+
from webgrid_tasks_lib import sub_run
6+
7+
8+
def main():
9+
result = sub_run('nox', '--list-sessions', '--json', capture=True)
10+
sessions = json.loads(result.stdout)
11+
print(json.dumps([rec['session'] for rec in sessions]))
12+
13+
14+
if __name__ == '__main__':
15+
main()

0 commit comments

Comments
 (0)