-
Notifications
You must be signed in to change notification settings - Fork 10
230 lines (219 loc) · 6.63 KB
/
Copy pathci.yml
File metadata and controls
230 lines (219 loc) · 6.63 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
name: CI (build + client samples)
'on':
pull_request:
branches:
- main
# Run on demand against any branch. The sample jobs exercise LD_API_KEY against
# the real 'openapi' project, so this doubles as a check that that credential
# still works — the token audit can only confirm it reads, not that it writes.
workflow_dispatch:
env:
LD_API_KEY: ${{ secrets.LD_API_KEY }}
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
container:
image: 'ldcircleci/openapi-release:1'
options: --user 1001
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Compute TAG/SHORT_SHA and envs
id: meta
run: >
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG="${GITHUB_REF#refs/tags/}"; else TAG="0.0.1"; fi
echo "TAG=$TAG" >> "$GITHUB_ENV"
echo "SHORT_SHA=${GITHUB_SHA::7}" >> "$GITHUB_ENV"
echo "REPO_USER_URL=https://github.com/${{ github.repository_owner }}"
>> "$GITHUB_ENV"
echo "LD_RELEASE_VERSION=$TAG" >> "$GITHUB_ENV"
- name: Generating code
run: |
export REPO_USER_URL="$REPO_USER_URL"
echo "Setting version to ${TAG}"
LD_RELEASE_VERSION="${TAG}" make all
- name: Archive tgz
run: |
cd targets
tar cvfz "api-clients-${TAG}-${SHORT_SHA}.tgz" api-client-*
mkdir -p /tmp/api-clients
cp "api-clients-${TAG}-${SHORT_SHA}.tgz" /tmp/api-clients/
- name: Upload targets workspace
uses: actions/upload-artifact@v4
with:
name: targets
path: targets
- name: Upload html2
uses: actions/upload-artifact@v4
with:
name: html
path: targets/html2
- name: Upload html-plain
uses: actions/upload-artifact@v4
with:
name: html-plain
path: targets/html
- name: Upload api-clients tgz
uses: actions/upload-artifact@v4
with:
name: api-clients
path: /tmp/api-clients
selfcheck:
name: Release automation selfcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Ensure PyYAML
run: python3 -c "import yaml" 2>/dev/null || pip install --quiet pyyaml
# Trust-policy checks self-skip here: the policy lives in the private
# launchdarkly/.github-private, which GITHUB_TOKEN cannot read. Run this
# locally for the full set.
- name: Selfcheck
# GITHUB_TOKEN is enough to read the pinned action repos (all public), which
# is what the ACTION-INPUTS check needs. Without it that check resolves
# nothing and reports SKIP.
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./scripts/release/selfcheck.sh
test-go:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Download targets
uses: actions/download-artifact@v4
with:
name: targets
path: targets
- uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Run Go sample
env:
GO111MODULE: 'on'
run: |
cd samples/go
make
test-python:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Download targets
uses: actions/download-artifact@v4
with:
name: targets
path: targets
- uses: actions/setup-python@v5
with:
python-version: '3.14'
- name: Run Python sample
run: |
python -m pip install --upgrade pip
cd samples/python
pip install -e ../../targets/api-client-python
python main.py
test-ruby:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Download targets
uses: actions/download-artifact@v4
with:
name: targets
path: targets
- uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1
with:
ruby-version: '2.7'
- name: Prepare RubyGems / ffi
run: |
# Update RubyGems to a version new enough for ffi 1.17.2
gem update --system 3.4.22 || gem update --system 3.3.22
gem --version
# Install ffi pinned to the last series that supports older Ruby/RubyGems
gem install ffi -v 1.17.2 --no-document
- name: Install Gem
run: |
cd targets/api-client-ruby
gem build launchdarkly_api.gemspec
gem install ./launchdarkly_api*.gem
- name: Run Ruby sample
run: |
cd samples/ruby
ruby main.rb
test-java:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Download targets
uses: actions/download-artifact@v4
with:
name: targets
path: targets
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '8'
- name: Compute TAG
run: >
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG="${GITHUB_REF#refs/tags/}"; else TAG="0.0.1"; fi
echo "TAG=$TAG" >> "$GITHUB_ENV"
- name: Build & run Java sample
run: |
cd targets/api-client-java
mvn clean install
cd ../../samples/java
sed -i.bak -e "s/API_CLIENT_VERSION/${TAG}/g" pom.xml
mvn clean install
mvn exec:java
test-typescript:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Download targets
uses: actions/download-artifact@v4
with:
name: targets
path: targets
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Run TS sample (axios)
run: |
cd targets/api-client-typescript-axios
npm install
npm run build
npm link
cd ../../samples/typescript-axios
npm link launchdarkly-api-typescript
npm install
npm run build
npm start
check-success:
name: Check Success
needs:
- build
- selfcheck
- test-go
- test-python
- test-ruby
- test-java
- test-typescript
if: always()
runs-on: ubuntu-latest
steps:
- name: Evaluate results
run: |
if printf '${{ toJSON(needs) }}' | grep --quiet --extended-regexp --ignore-case '"result": "(failure|cancelled)"'; then
printf "Tests failed or workflow cancelled:\n\n${{ toJSON(needs) }}"
exit 1
fi