1+ name : Build & Test Generated API Clients
2+
3+ on :
4+ push :
5+ branches : ['main']
6+ workflow_dispatch :
7+
8+ concurrency :
9+ group : ${{ github.workflow }}-${{ github.ref }}
10+ cancel-in-progress : true
11+
12+ env :
13+ OPEN_API_GENERATOR_VERSION : ' v7.9.0'
14+ PYTHON_VERSION_DEFAULT : ' 3.12'
15+ POETRY_VERSION : ' 1.8.1'
16+
17+ jobs :
18+ generate-library-code :
19+ name : Generate Library Code ${{ matrix.language }}
20+ runs-on : ubuntu-latest
21+ strategy :
22+ matrix :
23+ language : ['go', 'java-webclient', 'python', 'typescript']
24+ steps :
25+ - name : Checkout
26+ # see https://github.com/actions/checkout
27+ uses : actions/checkout@v4
28+
29+ - name : Create Output Directory
30+ run : mkdir out/${{ matrix.language }}
31+
32+ - name : Run OpenAPI Generator
33+ uses : addnab/docker-run-action@v3
34+ with :
35+ image : openapitools/openapi-generator-cli:${{ env.OPEN_API_GENERATOR_VERSION }}
36+ options : -v ${{ github.workspace }}:/local
37+ run : /usr/local/bin/docker-entrypoint.sh batch --clean /local/spec/generators/${{ matrix.language }}.yaml
38+
39+ - name : Copy our scripts across too
40+ run : cp spec/generators/*.sh ./out/${{ matrix.language }}
41+
42+ - name : Save to Cache
43+ uses : actions/cache/save@v4
44+ with :
45+ path : out/${{ matrix.language }}
46+ key : ' ${{ matrix.language }}-${{ github.run_id }}'
47+
48+ validate-go :
49+ name : Validate Go Library
50+ runs-on : ubuntu-latest
51+ needs : generate-library-code
52+
53+ steps :
54+ - name : Setup Go
55+ uses : actions/setup-go@v5
56+ with :
57+ go-version : 1.22
58+
59+ - name : Get generated code from cache
60+ uses : actions/cache/restore@v4
61+ with :
62+ path : out/go
63+ key : ' go-${{ github.run_id }}'
64+ fail-on-cache-miss : true
65+
66+ - name : Build Go API Client
67+ run : go build -v ./
68+ working-directory : out/go
69+
70+ - name : Install test dependencies & run generated tests
71+ run : |
72+ go get github.com/stretchr/testify/assert
73+ go test -v ./test/
74+ working-directory : out/go
75+
76+ validate-java-webclient :
77+ name : Validate Java Webclient
78+ runs-on : ubuntu-latest
79+ needs : generate-library-code
80+
81+ steps :
82+ - name : Set up JDK 17 for x64
83+ uses : actions/setup-java@v4
84+ with :
85+ java-version : ' 17'
86+ distribution : ' temurin'
87+ architecture : x64
88+
89+ - name : Set up Maven
90+ uses : stCarolas/setup-maven@v5
91+ with :
92+ maven-version : 3.9.4
93+
94+ - name : Get generated code from cache
95+ uses : actions/cache/restore@v4
96+ with :
97+ path : out/java-webclient
98+ key : ' java-webclient-${{ github.run_id }}'
99+ fail-on-cache-miss : true
100+
101+ - name : Build & Test Java Webclient API Client
102+ run : |
103+ ./update-pom.sh pom.xml
104+ mvn clean test
105+ working-directory : out/java-webclient
106+
107+ validate-python :
108+ name : Validate Python Library
109+ runs-on : ubuntu-latest
110+ needs : generate-library-code
111+
112+ steps :
113+ - name : Set up Python
114+ uses : actions/setup-python@v5
115+ with :
116+ python-version : ${{ env.PYTHON_VERSION_DEFAULT }}
117+
118+ - name : Install poetry
119+ # see https://github.com/marketplace/actions/setup-poetry
120+ uses : Gr1N/setup-poetry@v9
121+ with :
122+ poetry-version : ${{ env.POETRY_VERSION }}
123+
124+ - name : Get generated code from cache
125+ uses : actions/cache/restore@v4
126+ with :
127+ path : out/python
128+ key : ' python-${{ github.run_id }}'
129+ fail-on-cache-miss : true
130+
131+ - name : Install dependencies
132+ run : poetry install --no-root
133+ working-directory : out/python
134+
135+ - name : Ensure build successful
136+ run : poetry build
137+ working-directory : out/python
138+
139+ - name : Run Tests
140+ run : |
141+ pip install -r test-requirements.txt
142+ poetry run pytest
143+ working-directory : out/python
144+
145+ validate-typescript :
146+ name : Validate Typescript Library
147+ runs-on : ubuntu-latest
148+ needs : generate-library-code
149+
150+ steps :
151+ - name : Setup Node
152+ uses : actions/setup-node@v4
153+ with :
154+ node-version : latest
155+
156+ - name : Get generated code from cache
157+ uses : actions/cache/restore@v4
158+ with :
159+ path : out/typescript
160+ key : ' typescript-${{ github.run_id }}'
161+ fail-on-cache-miss : true
162+
163+ - name : Build Typescript API Client
164+ run : npm i && npm run build
165+ working-directory : out/typescript
0 commit comments