-
-
Notifications
You must be signed in to change notification settings - Fork 11
165 lines (136 loc) · 5.14 KB
/
test-generate-api-clients.yaml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Build & Test Generated API Clients
on:
push:
branches: ['main']
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
OPEN_API_GENERATOR_VERSION: 'v7.9.0'
PYTHON_VERSION_DEFAULT: '3.12'
POETRY_VERSION: '1.8.1'
jobs:
generate-library-code:
name: Generate Library Code ${{ matrix.language }}
runs-on: ubuntu-latest
strategy:
matrix:
language: ['go', 'java-webclient', 'python', 'typescript']
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v4
- name: Create Output Directory
run: mkdir out/${{ matrix.language }}
- name: Run OpenAPI Generator
uses: addnab/docker-run-action@v3
with:
image: openapitools/openapi-generator-cli:${{ env.OPEN_API_GENERATOR_VERSION }}
options: -v ${{ github.workspace }}:/local
run: /usr/local/bin/docker-entrypoint.sh batch --clean /local/spec/generators/${{ matrix.language }}.yaml
- name: Copy our scripts across too
run: cp spec/generators/*.sh ./out/${{ matrix.language }}
- name: Save to Cache
uses: actions/cache/save@v4
with:
path: out/${{ matrix.language }}
key: '${{ matrix.language }}-${{ github.run_id }}'
validate-go:
name: Validate Go Library
runs-on: ubuntu-latest
needs: generate-library-code
steps:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Get generated code from cache
uses: actions/cache/restore@v4
with:
path: out/go
key: 'go-${{ github.run_id }}'
fail-on-cache-miss: true
- name: Build Go API Client
run: go build -v ./
working-directory: out/go
- name: Install test dependencies & run generated tests
run: |
go get github.com/stretchr/testify/assert
go test -v ./test/
working-directory: out/go
validate-java-webclient:
name: Validate Java Webclient
runs-on: ubuntu-latest
needs: generate-library-code
steps:
- name: Set up JDK 17 for x64
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
architecture: x64
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.4
- name: Get generated code from cache
uses: actions/cache/restore@v4
with:
path: out/java-webclient
key: 'java-webclient-${{ github.run_id }}'
fail-on-cache-miss: true
- name: Build & Test Java Webclient API Client
run: |
./update-pom.sh pom.xml
mvn clean test
working-directory: out/java-webclient
validate-python:
name: Validate Python Library
runs-on: ubuntu-latest
needs: generate-library-code
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
- name: Install poetry
# see https://github.com/marketplace/actions/setup-poetry
uses: Gr1N/setup-poetry@v9
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Get generated code from cache
uses: actions/cache/restore@v4
with:
path: out/python
key: 'python-${{ github.run_id }}'
fail-on-cache-miss: true
- name: Install dependencies
run: poetry install --no-root
working-directory: out/python
- name: Ensure build successful
run: poetry build
working-directory: out/python
- name: Run Tests
run: |
pip install -r test-requirements.txt
poetry run pytest
working-directory: out/python
validate-typescript:
name: Validate Typescript Library
runs-on: ubuntu-latest
needs: generate-library-code
steps:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: latest
- name: Get generated code from cache
uses: actions/cache/restore@v4
with:
path: out/typescript
key: 'typescript-${{ github.run_id }}'
fail-on-cache-miss: true
- name: Build Typescript API Client
run: npm i && npm run build
working-directory: out/typescript