-
-
Notifications
You must be signed in to change notification settings - Fork 15
268 lines (261 loc) · 12.4 KB
/
build.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
name: CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
inputs:
version:
description: 'Version of the Release'
changelog:
description: 'Changelog of the Release'
skip-packaging:
description: 'Skip packaging'
type: boolean
env:
RUNNER_DEV_VERSION: "0.6.x"
RUNNER_SERVER_VERSION: "3.11.5"
jobs:
build:
runs-on: ubuntu-latest
strategy:
#
fail-fast: false
matrix:
include:
# go tool dist list -json to get the source
- {GOOS: android, GOARCH: 386, TARGET: i686-linux-android }
- {GOOS: android, GOARCH: amd64, TARGET: x86_64-linux-android }
- {GOOS: android, GOARCH: arm, TARGET: armv7a-linux-androideabi }
- {GOOS: android, GOARCH: arm64, TARGET: aarch64-linux-android }
- {GOOS: darwin, GOARCH: amd64 }
- {GOOS: darwin, GOARCH: arm64 }
- {GOOS: dragonfly, GOARCH: amd64 }
- {GOOS: freebsd, GOARCH: 386 }
- {GOOS: freebsd, GOARCH: amd64 }
- {GOOS: freebsd, GOARCH: arm }
- {GOOS: freebsd, GOARCH: arm64 }
- {GOOS: illumos, GOARCH: amd64 }
- {GOOS: linux, GOARCH: 386 }
- {GOOS: linux, GOARCH: amd64 }
- {GOOS: linux, GOARCH: arm }
- {GOOS: linux, GOARCH: arm, GOARM: 5 }
- {GOOS: linux, GOARCH: arm64 }
- {GOOS: linux, GOARCH: ppc64 }
- {GOOS: linux, GOARCH: ppc64le }
- {GOOS: linux, GOARCH: mips }
- {GOOS: linux, GOARCH: mipsle }
- {GOOS: linux, GOARCH: mips64 }
- {GOOS: linux, GOARCH: mips64le }
- {GOOS: linux, GOARCH: riscv64 }
- {GOOS: linux, GOARCH: s390x }
- {GOOS: netbsd, GOARCH: 386 }
- {GOOS: netbsd, GOARCH: amd64 }
- {GOOS: netbsd, GOARCH: arm }
- {GOOS: netbsd, GOARCH: arm64 }
- {GOOS: openbsd, GOARCH: 386, }
- {GOOS: openbsd, GOARCH: amd64, }
- {GOOS: openbsd, GOARCH: arm, }
- {GOOS: openbsd, GOARCH: arm64, }
- {GOOS: openbsd, GOARCH: mips64 }
- {GOOS: plan9, GOARCH: 386 }
- {GOOS: plan9, GOARCH: amd64 }
- {GOOS: plan9, GOARCH: arm }
- {GOOS: solaris, GOARCH: amd64 }
- {GOOS: windows, GOARCH: 386, suffix: .exe}
- {GOOS: windows, GOARCH: amd64, suffix: .exe}
- {GOOS: windows, GOARCH: arm, suffix: .exe}
- {GOOS: windows, GOARCH: arm64, suffix: .exe}
env:
CGO_ENABLED: 0 # Only android should build with cgo
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "${{matrix.GOVERSION || vars.GOVERSION || '^1.16.0'}}"
- name: Setup cgo ndk
if: matrix.GOOS == 'android'
run: |
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
# Set this to your minSdkVersion.
export API=21
# Configure and build.
echo "AR=$TOOLCHAIN/bin/llvm-ar" >> $GITHUB_ENV
echo "CC=$TOOLCHAIN/bin/$TARGET$API-clang" >> $GITHUB_ENV
echo "AS=$CC" >> $GITHUB_ENV
echo "CXX=$TOOLCHAIN/bin/$TARGET$API-clang++" >> $GITHUB_ENV
echo "LD=$TOOLCHAIN/bin/ld" >> $GITHUB_ENV
echo "RANLIB=$TOOLCHAIN/bin/llvm-ranlib" >> $GITHUB_ENV
echo "STRIP=$TOOLCHAIN/bin/llvm-strip" >> $GITHUB_ENV
echo "CGO_ENABLED=1" >> $GITHUB_ENV
env:
TARGET: ${{ matrix.TARGET }}
- name: Build
run: |
go build -ldflags "-X main.version=${{ github.event.inputs.version || format('{0}-dev-{1}', env.RUNNER_DEV_VERSION, github.sha) }}" -o github-act-runner-${{matrix.GOOS}}-${{matrix.GOARCH}}${{matrix.GOARM}}${{matrix.suffix}}
mkdir output
cp github-act-runner-${{matrix.GOOS}}-${{matrix.GOARCH}}${{matrix.GOARM}}${{matrix.suffix}} output/github-act-runner${{matrix.suffix}}
env:
GOOS: ${{matrix.GOOS}}
GOARCH: ${{matrix.GOARCH}}
GOARM: ${{matrix.GOARM}}
- name: Package tar
if: ${{ github.event.inputs.skip-packaging != 'true' && matrix.GOOS != 'windows' }}
run: |
cp compat/*.sh output/
cd output
tar czf ../binary-${{matrix.GOOS}}-${{matrix.GOARCH}}${{matrix.GOARM}}.tar.gz ./*
- name: Package zip
if: ${{ github.event.inputs.skip-packaging != 'true' && matrix.GOOS == 'windows' }}
run: |
cp compat/*.cmd output/
cd output
zip ../binary-${{matrix.GOOS}}-${{matrix.GOARCH}}${{matrix.GOARM}}.zip ./*
- uses: actions/upload-artifact@v3
with:
name: binary-${{matrix.GOOS}}-${{matrix.GOARCH}}${{matrix.GOARM}}
path: github-act-runner-${{matrix.GOOS}}-${{matrix.GOARCH}}${{matrix.GOARM}}${{matrix.suffix}}
- uses: actions/upload-artifact@v3
if: ${{ github.event.inputs.skip-packaging != 'true' }}
with:
name: bundle-${{matrix.GOOS}}-${{matrix.GOARCH}}${{matrix.GOARM}}
path: 'binary-${{matrix.GOOS}}-${{matrix.GOARCH}}${{matrix.GOARM}}.*'
#######################################
########## publish to github ##########
#######################################
publish-to-github:
name: deploy to github
runs-on: ubuntu-latest
needs: build
if: ${{ github.event.inputs.skip-packaging != 'true' && github.event.inputs.version }}
continue-on-error: true
steps:
- uses: actions/download-artifact@v3
with:
path: "artifacts"
- uses: ncipollo/release-action@v1
with:
artifacts: "artifacts/**/*.zip,artifacts/**/*.tar.gz"
token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ github.event.inputs.version }}
commit: ${{ github.sha }}
body: |
# Changes
${{ fromJSON(github.event.inputs.changelog) || 'No changelog provided' }}
# Using your self hosted runner
Download and extract the self-hosted runner artifact for your system, then [follow the official Documentation](https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners) (follow the linux instruction if your system isn't listed).
If your system doesn't have bash installed and isn't windows then:
|replace|with|
---|---
|`./config.sh`|`./github-act-runner configure`|
|`./config.sh remove`|`./github-act-runner remove`|
|`./run.sh`|`./github-act-runner run`|
The runner configuration is saved in / loaded from your current working directory, while using the `github-act-runner` command directly.
#########################################
########## publish to deb repo ##########
#########################################
build-and-publish-to-deb-repo:
needs: build
runs-on: ubuntu-latest
name: build and deploy to deb repo
if: ${{ github.event.inputs.skip-packaging != 'true' }}
env:
DEPLOY_ARCHS: "amd64 i386 armel armhf arm64 ppc64 ppc64el mips mipsel mips64el riscv64 s390x" # architectures from https://wiki.debian.org/SupportedArchitectures
steps:
- name: git clone
uses: actions/checkout@v3
with: {submodules: false}
- uses: actions/download-artifact@v3
with:
path: "artifacts"
- name: add cppfw repo to install myci scripts from
uses: myci-actions/add-deb-repo@master
with:
repo: deb https://gagis.hopto.org/repo/cppfw/$(lsb_release --id --short | tr '[:upper:]' '[:lower:]') $(lsb_release --codename --short) main
repo-name: cppfw
keys-asc: https://gagis.hopto.org/repo/cppfw/pubkey.gpg
- name: install debian package tools
run: |
sudo apt --quiet update
sudo apt --quiet install --assume-yes dpkg-dev debhelper devscripts myci
- name: add entry to debian/changelog
run: dch --newversion="${{ github.event.inputs.version || format('{0}-dev-{1}', env.RUNNER_DEV_VERSION, github.sha) }}" "another release"
- name: create deb package
run: |
for arch in $DEPLOY_ARCHS; do
dpkg-buildpackage --build=binary --no-sign --host-arch $arch
done
mkdir -p debs
cp ../*.deb debs/
- uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: debs
path: 'debs/*.deb'
- name: deploy packages to deb repo
if: ${{ github.event.inputs.version && fromJSON(env.HAVE_MYCI_REPO_SSH_KEY) }}
env:
HAVE_MYCI_REPO_SSH_KEY: ${{ toJSON(secrets.MYCI_REPO_SSH_KEY != '') }}
run: |
echo "${{ secrets.MYCI_REPO_SSH_KEY }}" > repo_key_rsa && chmod 600 repo_key_rsa
myci-deploy-debian-ssh-freight.sh --key repo_key_rsa --server gagis.hopto.org --user chrishx --repo chrishx/deb --distro all --component main ../*.deb
run-tests:
needs: build
runs-on: ubuntu-latest
if: ${{ github.event.inputs.skip-packaging != 'true' }}
steps:
- uses: actions/checkout@v3
- name: Prepare actions-runner
run: |
# Create a folder
mkdir actions-runner && cd actions-runner
# Download the latest runner package
curl -O -L https://github.com/ChristopherHX/runner.server/releases/download/v${{env.RUNNER_SERVER_VERSION}}/runner.server-linux-x64.tar.gz
# Extract the installer
tar xzf "runner.server-linux-x64.tar.gz"
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: bundle-linux-amd64
path: runner
- name: Unpack Artifact
run: |
tar xzf ./binary-linux-amd64.tar.gz
working-directory: runner
- name: Run Tests
run: |
./actions-runner/Runner.Server&
sleep 2
./runner/config.sh --unattended --url http://localhost:5000/runner/test --token WhichToken
./runner/run.sh&
# Check for leaks during run (#41)
sudo prlimit --pid $! --nofile=256:256
sleep 2
# Show test commands
set -x
./actions-runner/Runner.Client --server http://localhost:5000 -W ./.github/testworkflows --log-output-dir ./logs
./actions-runner/Runner.Client --server http://localhost:5000 -W ./.github/failingtestworkflows/test_container_fail_step.yml --log-output-dir ./logs && exit 1 || [[ "$?" = "1" ]]
./actions-runner/Runner.Client --server http://localhost:5000 -W ./.github/failingtestworkflows/test_host_fail_step.yml --log-output-dir ./logs && exit 1 || [[ "$?" = "1" ]]
./actions-runner/Runner.Client --server http://localhost:5000 -W ./.github/failingtestworkflows/test_unsupported_job_env.yml --log-output-dir ./logs && exit 1 || [[ "$?" = "1" ]]
./actions-runner/Runner.Client --server http://localhost:5000 -W ./.github/failingtestworkflows/test_unsupported_step_env.yml --log-output-dir ./logs && exit 1 || [[ "$?" = "1" ]]
./actions-runner/Runner.Client --server http://localhost:5000 -W ./.github/failingtestworkflows/test_unsupported_step_with.yml --log-output-dir ./logs && exit 1 || [[ "$?" = "1" ]]
./actions-runner/Runner.Client workflow_dispatch --server http://localhost:5000 -W ./.github/testworkflows/test-full-contextdata/workflow.yml --log-output-dir ./logs --var WORKSPACE=$PWD -s GITHUB_TOKEN=somevalue
# Run the cache action with debug logs
./actions-runner/Runner.Client --server http://localhost:5000 -W ./.github/testworkflows/cache-action.yml --log-output-dir ./logs -s ACTIONS_STEP_DEBUG=true
# Show debug logs of loglevel test
./actions-runner/Runner.Client --server http://localhost:5000 -W ./.github/testworkflows/loglevel.yml --log-output-dir ./logs -s ACTIONS_STEP_DEBUG=true
- name: Archive Test Results
if: ${{always()}}
run: tar czf ../logs.tar.gz .
working-directory: logs
- name: Upload Test Results
if: ${{always()}}
uses: actions/upload-artifact@v3
with:
name: test-results-linux-amd64
path: 'logs.tar.gz'