forked from meraki/dashboard-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (109 loc) · 3.95 KB
/
Copy pathtest-library.yml
File metadata and controls
129 lines (109 loc) · 3.95 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
name: Test Python library
on:
workflow_call:
workflow_dispatch:
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
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@v7
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@v7
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_GA_0: ${{ secrets.TEST_ORG_GA_00_ID }}
ORG_GA_1: ${{ secrets.TEST_ORG_GA_01_ID }}
ORG_GA_2: ${{ secrets.TEST_ORG_GA_02_ID }}
ORG_GA_3: ${{ secrets.TEST_ORG_GA_03_ID }}
ORG_BETA_0: ${{ secrets.TEST_ORG_BETA_00_ID }}
ORG_BETA_1: ${{ secrets.TEST_ORG_BETA_01_ID }}
ORG_BETA_2: ${{ secrets.TEST_ORG_BETA_02_ID }}
ORG_BETA_3: ${{ secrets.TEST_ORG_BETA_03_ID }}
ORG_DEV_0: ${{ secrets.TEST_ORG_DEV_00_ID }}
ORG_DEV_1: ${{ secrets.TEST_ORG_DEV_01_ID }}
ORG_DEV_2: ${{ secrets.TEST_ORG_DEV_02_ID }}
ORG_DEV_3: ${{ secrets.TEST_ORG_DEV_03_ID }}
run: |
BRANCH="${{ github.head_ref || github.ref_name }}"
BASE="${{ github.base_ref }}"
case "$BRANCH" in
main|release) PREFIX="GA" ;;
beta|beta-release) PREFIX="BETA" ;;
httpx|httpx-release) PREFIX="DEV" ;;
*)
case "$BASE" in
main) PREFIX="GA" ;;
beta) PREFIX="BETA" ;;
httpx) PREFIX="DEV" ;;
*) echo "Unknown branch: $BRANCH (base: $BASE)" && exit 1 ;;
esac
;;
esac
INDEX=$(echo '${{ needs.assign-orgs.outputs.assignments }}' | jq -r '.["${{ matrix.python-version }}"]')
VAR_NAME="ORG_${PREFIX}_${INDEX}"
ORG_ID="${!VAR_NAME}"
uv run pytest tests/integration -v --tb=short --apikey ${{ secrets.TEST_ORG_API_KEY }} --o "$ORG_ID"