-
-
Notifications
You must be signed in to change notification settings - Fork 31
134 lines (117 loc) · 4.24 KB
/
Copy pathci.yml
File metadata and controls
134 lines (117 loc) · 4.24 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
name: CI — Test Suite
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
python-tests:
name: Python Tests (${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12"]
outputs:
passed: ${{ steps.results.outputs.passed }}
failed: ${{ steps.results.outputs.failed }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-timeout graphql-core tiktoken pyyaml
- name: Run test suite
run: |
set -o pipefail
python -m pytest tests/ -q --timeout=60 --ignore=tests/test_integration.py 2>&1 | tee pytest-output.txt
timeout-minutes: 10
- name: Run integration tests (allow failure)
continue-on-error: true
run: |
python -m pytest tests/test_integration.py -q --timeout=120
timeout-minutes: 5
- name: Parse test results
if: always() && matrix.python-version == '3.12'
id: results
run: |
SUMMARY=$(grep -E '(\d+ passed|\d+ failed)' pytest-output.txt | tail -1)
PASSED=$(echo "$SUMMARY" | grep -oP '\d+(?= passed)' || echo "0")
FAILED=$(echo "$SUMMARY" | grep -oP '\d+(?= failed)' || echo "0")
echo "passed=${PASSED}" >> $GITHUB_OUTPUT
echo "failed=${FAILED}" >> $GITHUB_OUTPUT
typescript-tests:
name: TypeScript SDK Tests (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ["18", "20"]
outputs:
passed: ${{ steps.results.outputs.passed }}
steps:
- uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
working-directory: sdks/typescript
run: npm ci
- name: Generate test fixtures
run: |
mkdir -p output
pip install pyyaml
python -c "
from lap.core.compilers.openapi import compile_openapi
spec = compile_openapi('examples/verbose/openapi/stripe-charges.yaml')
with open('output/stripe-charges.lap', 'w') as f:
f.write(spec.to_lap())
"
- name: Run test suite
working-directory: sdks/typescript
run: |
set -o pipefail
npm test 2>&1 | tee test-output.txt
timeout-minutes: 10
- name: Parse test results
if: always() && matrix.node-version == '20'
id: results
working-directory: sdks/typescript
run: |
PASSED=$(grep -oP '# pass \K\d+' test-output.txt | paste -sd+ | bc || echo "0")
echo "passed=${PASSED}" >> $GITHUB_OUTPUT
update-badge:
name: Update test badge
needs: [python-tests, typescript-tests]
if: always() && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Calculate totals
id: totals
run: |
PY_PASSED="${{ needs.python-tests.outputs.passed }}"
PY_FAILED="${{ needs.python-tests.outputs.failed }}"
TS_PASSED="${{ needs.typescript-tests.outputs.passed }}"
PY_PASSED=${PY_PASSED:-0}
PY_FAILED=${PY_FAILED:-0}
TS_PASSED=${TS_PASSED:-0}
TOTAL=$((PY_PASSED + TS_PASSED))
if [ "$PY_FAILED" = "0" ] || [ -z "$PY_FAILED" ]; then
echo "color=brightgreen" >> $GITHUB_OUTPUT
echo "message=${TOTAL} passed" >> $GITHUB_OUTPUT
else
echo "color=red" >> $GITHUB_OUTPUT
echo "message=${TOTAL} passed, ${PY_FAILED} failed" >> $GITHUB_OUTPUT
fi
- name: Update badge gist
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ vars.BADGE_GIST_ID }}
filename: lap-test-results.json
label: tests
message: ${{ steps.totals.outputs.message }}
color: ${{ steps.totals.outputs.color }}