-
Notifications
You must be signed in to change notification settings - Fork 2
126 lines (108 loc) · 3.58 KB
/
codegen.yml
File metadata and controls
126 lines (108 loc) · 3.58 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
name: codegen
on:
push:
branches:
- main
paths:
- '.github/workflows/codegen.yml'
- 'codegen/**'
- 'api/*.yml'
- '!**/*.md'
pull_request:
paths:
- '.github/workflows/codegen.yml'
- 'codegen/**'
- 'api/*.yml'
- '!**/*.md'
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
tests:
if: |
${{ github.event_name == 'pull_request' || github.event_name == 'release' }}
timeout-minutes: 15
runs-on: ubuntu-latest
name: 'Test codegen'
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
with:
egress-policy: audit
- name: Checkout csolution-rpc repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 'lts/*'
- name: Install dependencies
run: npm ci
working-directory: codegen
- name: Run linter
run: npm run lint
working-directory: codegen
- name: Run tests
run: npm test
working-directory: codegen
- name: Archive test report
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: codegen-test
path: codegen/reports/junit/testreport.xml
retention-days: 1
if-no-files-found: error
- name: Archive generated interface files
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: codegen-rpc-interfaces
path: codegen/generated/*
retention-days: 1
if-no-files-found: error
release:
if: ${{ github.event_name == 'release' }}
needs: [ tests ]
timeout-minutes: 15
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
with:
egress-policy: audit
- name: Download generated files
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: codegen-rpc-interfaces
path: generated
- name: Check release version tag
run: |
version=$(grep -oP 'RPC_API_VERSION\s*=\s*"\K[^"]+' RpcInterface.h)
tag=${{ github.event.release.tag_name }}
tag="${tag#v}"
if [ "$tag" != "$version" ]; then
echo "Release version does not match the version in generated interfaces. Update csolution-openapi.yml"
exit 1
fi
working-directory: generated
- name: ZIP generated files
run: zip -r csolution-rpc.zip RpcInterface.h rpc-interface.ts
working-directory: generated
- name: TAR generated files
run: tar -czf csolution-rpc.tar.gz RpcInterface.h rpc-interface.ts
working-directory: generated
- name: Attach files to release assets
id: release_assets
uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de # v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: generated/csolution-rpc.*
tag: ${{ github.ref }}
overwrite: true
file_glob: true