-
Notifications
You must be signed in to change notification settings - Fork 165
118 lines (99 loc) · 3.31 KB
/
test-library.yml
File metadata and controls
118 lines (99 loc) · 3.31 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
name: Test Python library
on:
push:
branches: ['main', 'release', 'dev_rest_session']
paths:
- 'meraki/**'
- 'tests/unit/**'
- 'tests/integration/**'
- 'pyproject.toml'
- 'uv.lock'
pull_request:
branches: ['main', 'release', 'dev_rest_session']
paths:
- 'meraki/**'
- 'tests/unit/**'
- 'tests/integration/**'
- 'pyproject.toml'
- 'uv.lock'
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
run: uv python install 3.13
- name: Install dependencies
run: uv sync --python 3.13
- name: Lint with flake8
run: |
uv run flake8 . --count --select=E9,F63,F7,F82 --ignore=F405,W391,W291,C901,E501,E303,W293 --exclude=examples,generator,.venv --show-source --statistics
uv run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --exclude=examples,generator,.venv --statistics
unit-test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --python ${{ matrix.python-version }}
- name: Unit tests with coverage
run: uv run pytest tests/unit --cov --cov-report=term-missing --cov-fail-under=90
assign-orgs:
runs-on: ubuntu-latest
outputs:
assignments: ${{ steps.shuffle.outputs.assignments }}
steps:
- name: Shuffle org assignments
id: shuffle
run: |
python3 -c "
import json, random
versions = ['3.11', '3.12', '3.13', '3.14']
indices = list(range(4))
random.shuffle(indices)
assignments = dict(zip(versions, indices))
print(f'assignments={json.dumps(assignments)}')
" >> "$GITHUB_OUTPUT"
integration-test:
needs: [assign-orgs]
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
strategy:
fail-fast: true
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --python ${{ matrix.python-version }}
- name: Integration tests
env:
ORG_0: ${{ secrets.TEST_ORG_ID }}
ORG_1: ${{ secrets.TEST_ORG_ID_1 }}
ORG_2: ${{ secrets.TEST_ORG_ID_2 }}
ORG_3: ${{ secrets.TEST_ORG_ID_3 }}
run: |
INDEX=$(echo '${{ needs.assign-orgs.outputs.assignments }}' | jq -r '.["${{ matrix.python-version }}"]')
VAR_NAME="ORG_${INDEX}"
ORG_ID="${!VAR_NAME}"
uv run pytest tests/integration -v --tb=short --apikey ${{ secrets.TEST_ORG_API_KEY }} --o "$ORG_ID"