-
Notifications
You must be signed in to change notification settings - Fork 26
278 lines (266 loc) · 8.31 KB
/
agent.yml
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
name: build
on:
push:
branches: [ master ]
tags:
- 'v*.*.*'
pull_request:
branches: [ master ]
env:
GIMME_GO_VERSION: 1.21.0
GIMME_OS: linux
GIMME_ARCH: amd64
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.21.0'
check-latest: true
- name: fmt
run: |
make -e setup build
test -z "$(go fmt ./pkg/...)"
lint-docker:
runs-on: ubuntu-latest
env:
HADOLINT_RECURSIVE: "true"
steps:
- uses: actions/checkout@v3
- name: Lint dockerfiles
uses: hadolint/hadolint-action@v2.0.0
with:
recursive: true
ignore: "DL3018"
dockerfile: scripts/dockerfiles/Dockerfile.*
tests_coveralls:
runs-on: ubuntu-latest
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.21.0'
check-latest: true
- name: coveralls
id: coveralls
run: |
make -e setup build
make -e cover COVER_FILE=coverage.txt
- name: success
if: steps.coveralls.outcome == 'success'
run: |
go install github.com/mattn/goveralls@latest
goveralls -coverprofile=coverage.txt -service=github
tests_sourceclear:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.21.0'
check-latest: true
- name: sourceclear
env:
SRCCLR_API_TOKEN: ${{ secrets.SRCCLR_API_TOKEN }}
run: |
make -e setup build
curl -sSL https://download.sourceclear.com/ci.sh | bash -s – scan
- name: run
run: |
make -e setup build
go get -v -d ./...
tests_windows_build_ps1:
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
- name: windows build.ps1 test
id: windows_build
shell: pwsh
run: |
PowerShell -Command Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
PowerShell -File "scripts\build.ps1" noninteractive
PowerShell -File "scripts\check_exe.ps1"
- name: success
if: steps.windows_build.outcome == 'success'
run: |
scripts/upload_artifacts.sh
tests_acceptance_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.21.0'
check-latest: true
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.9
- name: Start Redis
uses: supercharge/redis-github-action@1.5.0
with:
redis-version: 4
- name: acceptance test
run: |
make -e setup build
pip install -r ./tests/acceptance/requirements.txt
MYHOST="http://localhost:8080" make test-acceptance
integration_tests:
if: ${{ startsWith(github.ref, 'refs/tags/') != true }}
uses: optimizely/agent/.github/workflows/integration_test.yml@master
secrets: inherit
tests_using_latest_tag_no_upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: '1.21.0'
check-latest: true
- name: Get the version
id: get_version
run: |
git fetch --tags --force
echo "VERSION=$(git describe --abbrev=0 --tags | tr -d '^v')" >> $GITHUB_OUTPUT
- name: Get current workspace path
id: get_workspace
run: echo "WORKSPACE=${GITHUB_WORKSPACE}" >> $GITHUB_OUTPUT
- name: set the env
run: |
echo "APP_VERSION=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_ENV
echo "TRAVIS_BUILD_DIR=${{ steps.get_workspace.outputs.WORKSPACE }}" >> $GITHUB_ENV
- name: test
env:
TRAVIS_OS_NAME: 'linux'
run: |
make -e setup build
./scripts/ci_create_packages.sh
./scripts/ci_build_generate_secret.sh
build_upload_publish_draft:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: '1.21.0'
check-latest: true
- uses: actions/checkout@v2
with:
# You should create a personal access token and store it in your repository
token: ${{ secrets.CI_USER_TOKEN }}
repository: 'optimizely/travisci-tools'
path: 'home/runner/travisci-tools'
ref: 'master'
- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
- name: Get current workspace path
id: get_workspace
run: echo "WORKSPACE=${GITHUB_WORKSPACE}" >> $GITHUB_OUTPUT
- name: set the env
run: |
TAG=${{ steps.get_version.outputs.VERSION }}
echo "APP_VERSION=${TAG#v}" >> $GITHUB_ENV
echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV
echo "TRAVIS_BUILD_DIR=${{ steps.get_workspace.outputs.WORKSPACE }}" >> $GITHUB_ENV
- name: Upload and publish draft
env:
HOME: 'home/runner'
run: |
# installs hub to ~/bin
$HOME/travisci-tools/release_github/install_hub.sh
echo "$HOME/bin:$HOME/travisci-tools/release_github" >> $GITHUB_PATH
- name: run make
env:
TRAVIS_OS_NAME: 'linux'
run: |
make -e setup build
- name: create and upload packages
env:
HOME: 'home/runner'
GITHUB_TOKEN: ${{ secrets.CI_USER_TOKEN }}
TRAVIS_OS_NAME: 'linux'
DOCKERHUB_PASS: ${{ secrets.DOCKERHUB_PASS }}
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
run: |
# now we're going to create packages & upload packages
./scripts/ci_create_packages.sh && ./scripts/ci_upload_packages.sh
# create the github release (draft)
cp $HOME/travisci-tools/release_github/release_github_v2.sh .
./release_github_v2.sh "$APP_VERSION"
# attach generate_secret to the github release
./scripts/ci_build_generate_secret.sh && ./scripts/ci_attach_generate_secret.sh
test_github_release_assets:
if: startsWith(github.ref, 'refs/tags/')
needs: build_upload_publish_draft
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-2022]
include:
- os: macos-latest
os_name: osx
TARGET: darwin-amd64
- os: ubuntu-latest
TARGET: linux-amd64
os_name: linux
- os: windows-2022
os_name: windows
TARGET: windows-amd64
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.21.0'
check-latest: true
- uses: actions/checkout@v2
with:
# You should create a personal access token and store it in your repository
token: ${{ secrets.CI_USER_TOKEN }}
repository: 'optimizely/travisci-tools'
path: 'home/runner/travisci-tools'
ref: 'master'
- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
- name: set the env
run: |
TAG=${{ steps.get_version.outputs.VERSION }}
echo "APP_VERSION=${TAG#v}" >> $GITHUB_ENV
- name: Upload and publish draft
shell: bash
env:
HOME: 'home/runner'
run: |
# installs hub to ~/bin
$HOME/travisci-tools/release_github/install_hub.sh
# echo "$HOME/bin:$HOME/travisci-tools/slack" >> $GITHUB_PATH
- name: run script
env:
GITHUB_TOKEN: ${{ secrets.CI_USER_TOKEN }}
TRAVIS_OS_NAME: ${{ matrix.os_name }}
DOCKERHUB_PASS: ${{ secrets.DOCKERHUB_PASS }}
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
id: script
shell: bash
run: |
hub release download $(git describe --abbrev=0 --tags) -i '*-${{ matrix.TARGET }}-*'
tar xvfz generate_secret-${{ matrix.TARGET }}-${APP_VERSION}.tar.gz -C /tmp
/tmp/generate_secret
# TODO: add step to publish outcome on teams.
# - name: failure
# if: steps.script.outcome != 'success'
# run: |
# SLACK_TEXT="${APP_VERSION} ${{ matrix.os_name }} assets failed verification." send_to_slack.sh