-
Notifications
You must be signed in to change notification settings - Fork 1
163 lines (155 loc) · 5.61 KB
/
update-client.yml
File metadata and controls
163 lines (155 loc) · 5.61 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
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
name: Update Client
# Set environment variables available in all jobs and steps
env:
python_version: "3.9"
go_module: "client"
on:
workflow_dispatch:
inputs:
branch:
description:
"Branch to commit updated client changes to:"
type: string
required: true
workflow_call:
inputs:
branch:
description:
"Branch to commit updated client changes to:"
type: string
required: true
jobs:
get-all-service-definition:
name: Get all-service definition
runs-on: ubuntu-latest
steps:
- name: Checkout API-Uniform-Contract repo
uses: actions/checkout@v6.0.1
with:
token: ${{ secrets.GIT_SECRET }}
repository: Arm-Debug/API-Uniform-Contract
path: API-Uniform-Contract
ref: main
# FIXME set to `production`
- uses: actions/upload-artifact@v6.0.0
with:
name: all-service-flat
path: API-Uniform-Contract/all/1/
update-go:
name: Update Go
runs-on: ubuntu-latest
needs: update-client
steps:
- uses: actions/checkout@v6.0.1
with:
# So that we have correct GIT_TOKEN to push back to branch as we need workflow permissions
token: ${{ secrets.GIT_SECRET }}
ref: ${{ inputs.branch || github.head_ref || github.ref }}
- name: Checkout Update Go action
uses: actions/checkout@v6.0.1
with:
repository: Arm-Debug/update-go-action
ref: refs/tags/latest
token: ${{ secrets.GIT_SECRET }}
persist-credentials: false
path: ./.github/workflows/update-go-action
- name: Update Go
uses: ./.github/workflows/update-go-action
with:
dockerfile: Dockerfile.client
branch: ${{ inputs.branch || github.head_ref || github.ref }}
update-client:
name: Update client
runs-on: ubuntu-latest
needs: get-all-service-definition
steps:
- name: Setup python
uses: actions/setup-python@v6
with:
python-version: ${{ env.python_version }}
- name: Install continuous-delivery-scripts
run: |
pip install continuous-delivery-scripts
- uses: actions/checkout@v6.0.1
with:
ref: ${{ inputs.branch || github.head_ref || github.ref }}
- name: Download all-service-flat artefact
uses: actions/download-artifact@v7.0.0
with:
name: all-service-flat
path: all-service-definition
- name: Download openapi-generator
run: |
mkdir -p /usr/local/bin/
curl https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/bin/utils/openapi-generator-cli.sh > /usr/local/bin/openapi-generator
chmod u+x /usr/local/bin/openapi-generator
- name: Clean up previously generated client
run: |
mkdir -p ${{ env.go_module }}
rm -rf ${{ env.go_module }}/*
- name: Generate client
run: |
ls all-service-definition
chmod +x ./scripts/generate-client.sh
./scripts/generate-client.sh -i all-service-definition/all-def-flat.yaml -o ${{ env.go_module }} -d
- name: Generate pagination extensions
run: |
cd generator
go mod tidy
go run main.go -i ../all-service-definition/all-def-flat.yaml -o ../extensions/extension_entities.gen.go -t templates/entities.go.tmpl -g collections -c ../client
go run main.go -i ../all-service-definition/all-def-flat.yaml -o ../extensions/extension_jobs.gen.go -t templates/jobs.go.tmpl -g jobs -c ../client
go run main.go -i ../all-service-definition/all-def-flat.yaml -o ../extensions/extension_link_followers.gen.go -t templates/linkfollowers.go.tmpl -g links -c ../client
- name: Copy extensions to client
run: |
if [ -d ./extensions/ ]; then
cp -r extensions/. ${{ env.go_module }}/
echo "EXTENSIONS_EXISTS=true" >> $GITHUB_ENV
fi
ls -l ${{ env.go_module }}/*
- name: Upload extensions
if: ${{ env.EXTENSIONS_EXISTS == 'true' }}
uses: actions/upload-artifact@v6.0.0
with:
name: extensions
path: extensions/
retention-days: 1
- name: License files
run: |
cd-license-files
- name: Check for client changes
run: |
SERVER_UPDATE="$(if [[ $(git status ${{ env.go_module }}/* --porcelain | grep -v go.mod | grep -v go.sum) ]] ; then echo '✨ New server autogenerated files' ; fi)"
if [[ $SERVER_UPDATE ]] ; then echo "SERVER_UPDATE=$SERVER_UPDATE" >> $GITHUB_ENV ; fi
- name: Generate News File
if: env.SERVER_UPDATE != ''
run: |
if [[ "${{ env.SERVER_UPDATE }}" ]] ; then cd-create-news-file --type feature "Updated client due to schema changes" ; fi
- name: Commit changes
if: env.SERVER_UPDATE != ''
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: ":sparkles: Automatic changes -> ${{ env.SERVER_UPDATE }} [ci skip]"
file_pattern: ${{ env.go_module }}/* changes/* extensions/*
commit_user_name: monty-bot
commit_user_email: monty-bot@arm.com
build-and-test:
name: Build and Test
needs:
- update-go
- update-client
uses: ./.github/workflows/build-and-test.yml
secrets: inherit
with:
branch: ${{ inputs.branch || github.head_ref || github.ref }}
release:
name: Release if necessary
runs-on: ubuntu-latest
needs:
- build-and-test
steps:
- uses: actions/checkout@v6.0.1
- name: Trigger release
if: contains(${{ inputs.branch || github.head_ref || github.ref }} , 'main')
run: gh workflow run release.yml -f release_type=release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}