Skip to content

Commit be3c50a

Browse files
authored
feat: add enterprise wrapper and image + ci (#9)
1 parent 68a42f8 commit be3c50a

32 files changed

+3558
-396
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: enterprise-release
2+
on:
3+
push:
4+
tags:
5+
- "v*"
6+
workflow_dispatch:
7+
inputs:
8+
snapshot:
9+
description: Force a dev version to be generated, implies dry_run.
10+
type: boolean
11+
required: true
12+
dry_run:
13+
description: Perform a dry-run release.
14+
type: boolean
15+
required: true
16+
17+
permissions:
18+
# Required to publish a release
19+
contents: write
20+
# Necessary to push docker images to ghcr.io.
21+
packages: write
22+
23+
env:
24+
CODER_RELEASE: ${{ github.event.inputs.snapshot && 'false' || 'true' }}
25+
26+
jobs:
27+
release:
28+
runs-on: ubuntu-latest
29+
env:
30+
# Necessary for Docker manifest
31+
DOCKER_CLI_EXPERIMENTAL: "enabled"
32+
steps:
33+
- uses: actions/checkout@v3
34+
35+
- name: Docker Login
36+
uses: docker/login-action@v2
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- uses: actions/setup-go@v3
43+
with:
44+
go-version: "^1.20.7"
45+
46+
- name: Build binaries
47+
run: |
48+
set -euxo pipefail
49+
go mod download
50+
51+
version=$(./scripts/version.sh)
52+
make -j \
53+
enterprise/build/exectrace_"$version"_linux_{amd64,arm64,armv7}
54+
55+
- name: Build Docker images
56+
run: |
57+
set -euxo pipefail
58+
59+
version=$(./scripts/version.sh)
60+
make -j \
61+
enterprise/build/exectrace_"$version"_linux_{amd64,arm64,armv7}.tag
62+
63+
- name: Push Docker images
64+
if: ${{ !github.event.inputs.snapshot && !github.event.inputs.dry_run }}
65+
run: |
66+
set -euxo pipefail
67+
68+
make -j \
69+
enterprise/build/exectrace_"$version"_linux_{amd64,arm64,armv7}.tag.pushed
70+
71+
# Tag as latest and push
72+
for arch in amd64 arm64 armv7; do
73+
versioned_tag=$(cat enterprise/build/exectrace_"$version"_linux_"$arch".tag)
74+
latest_tag=$(./enterprise/scripts/image_tag.sh --arch "$arch" --version latest)
75+
76+
docker tag "$versioned_tag" "$latest_tag"
77+
docker push "$latest_tag"
78+
done
79+
80+
- name: Build and push multi-arch Docker image
81+
if: ${{ !github.event.inputs.snapshot && !github.event.inputs.dry_run }}
82+
run: |
83+
set -euxo pipefail
84+
85+
version=$(./scripts/version.sh)
86+
make -j \
87+
enterprise/build/exectrace_"$version"_linux.tag.pushed
88+
89+
# Tag as latest and push
90+
versioned_tag=$(cat enterprise/build/exectrace_"$version"_linux.tag)
91+
latest_tag=$(./enterprise/scripts/image_tag.sh --version latest)
92+
93+
docker tag "$versioned_tag" "$latest_tag"
94+
docker push "$latest_tag"

.github/workflows/enterprise.yaml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# This workflow file is adapted from coder/coder.
2+
name: enterprise
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
pull_request:
10+
11+
workflow_dispatch:
12+
13+
permissions:
14+
actions: none
15+
checks: none
16+
contents: read
17+
deployments: none
18+
issues: none
19+
packages: none
20+
pull-requests: none
21+
repository-projects: none
22+
security-events: none
23+
statuses: none
24+
25+
# Cancel in-progress runs for pull requests when developers push additional
26+
# changes
27+
concurrency:
28+
group: ${{ github.workflow }}-${{ github.ref }}
29+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
30+
31+
jobs:
32+
test-go:
33+
name: "test/go"
34+
runs-on: ubuntu-latest
35+
timeout-minutes: 20
36+
steps:
37+
- uses: actions/checkout@v3
38+
- uses: actions/setup-go@v3
39+
with:
40+
go-version: "^1.20.7"
41+
42+
- name: Echo Go Cache Paths
43+
id: go-cache-paths
44+
run: |
45+
echo "::set-output name=go-build::$(go env GOCACHE)"
46+
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
47+
48+
- name: Go Build Cache
49+
uses: actions/cache@v3
50+
with:
51+
path: ${{ steps.go-cache-paths.outputs.go-build }}
52+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.**', '**.go') }}
53+
54+
- name: Go Mod Cache
55+
uses: actions/cache@v3
56+
with:
57+
path: ${{ steps.go-cache-paths.outputs.go-mod }}
58+
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
59+
60+
- name: Install gotestsum
61+
uses: jaxxstorm/action-install-gh-release@v1.9.0
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
with:
65+
repo: gotestyourself/gotestsum
66+
tag: v1.10.1
67+
68+
- name: Test
69+
shell: bash
70+
run: |
71+
set +e
72+
gotestsum \
73+
--junitfile="gotests.xml" \
74+
--jsonfile="gotestsum.json" \
75+
--packages="./..." \
76+
--debug \
77+
-- \
78+
-exec sudo \
79+
-parallel=8 \
80+
-timeout=5m \
81+
-short \
82+
-failfast \
83+
-covermode=atomic \
84+
-coverprofile="gotests.coverage" \
85+
-coverpkg=./...
86+
ret=$?
87+
set -e
88+
if ((ret)); then
89+
# Eternalize test timeout logs because "re-run failed" erases
90+
# artifacts and gotestsum doesn't always capture it:
91+
# https://github.com/gotestyourself/gotestsum/issues/292
92+
# Multiple test packages could've failed, each one may or may
93+
# not run into the edge case. PS. Don't summon ShellCheck here.
94+
for testWithStack in $(grep 'panic: test timed out' gotestsum.json | grep -E -o '("Test":[^,}]*)'); do
95+
if [ -n "$testWithStack" ] && grep -q "${testWithStack}.*PASS" gotestsum.json; then
96+
echo "Conditions met for gotestsum stack trace missing bug, outputting panic trace:"
97+
grep -A 999999 "${testWithStack}.*panic: test timed out" gotestsum.json
98+
fi
99+
done
100+
fi
101+
exit $ret
102+
103+
- uses: actions/upload-artifact@v3
104+
if: success() || failure()
105+
with:
106+
name: gotestsum-debug.json
107+
path: ./gotestsum.json
108+
retention-days: 7
109+
110+
- uses: actions/upload-artifact@v3
111+
if: success() || failure()
112+
with:
113+
name: gotests.xml
114+
path: ./gotests.xml
115+
retention-days: 30

.github/workflows/quality.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Install Go
3737
uses: actions/setup-go@v2
3838
with:
39-
go-version: "^1.16.12"
39+
go-version: "^1.20.7"
4040

4141
- name: Run make fmt/go
4242
run: make fmt/go
@@ -54,7 +54,7 @@ jobs:
5454
- name: Install Node.js
5555
uses: actions/setup-node@v2
5656
with:
57-
node-version: "14"
57+
node-version: "18"
5858

5959
- name: Install prettier
6060
run: npm install --global prettier
@@ -75,12 +75,12 @@ jobs:
7575
- name: Install Go
7676
uses: actions/setup-go@v2
7777
with:
78-
go-version: "^1.16.12"
78+
go-version: "^1.20.7"
7979

8080
- name: Install golangci-lint
8181
run: |
8282
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
83-
| sh -s -- -b $(go env GOPATH)/bin v1.43.0
83+
| sh -s -- -b $(go env GOPATH)/bin v1.53.2
8484
8585
# Linting needs to be done on each build variation of GOOS.
8686
- name: Run make lint/go/linux

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@
2525

2626
# Make outputs
2727
.clang-image
28+
29+
build
30+
31+
*.tfstate
32+
*.tfstate.backup
33+
*.tfplan
34+
*.lock.hcl
35+
.terraform/

0 commit comments

Comments
 (0)