-
Notifications
You must be signed in to change notification settings - Fork 8
149 lines (142 loc) · 4.84 KB
/
pr.yaml
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
name: PR
on:
pull_request:
branches:
- main
merge_group:
types:
- checks_requested
# HINT(lukasmalkmus): Make sure the workflow is only ever run for the latest
# changes in the PR.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
gen-diff:
name: Codegen diff
runs-on: ubuntu-latest
strategy:
matrix:
go:
- "1.22"
- "1.23"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- run: make generate
- run: git diff --exit-code
lint:
name: Lint
needs: gen-diff
runs-on: ubuntu-latest
strategy:
matrix:
go:
- "1.22"
- "1.23"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: false
- run: echo "GOLANGCI_LINT_VERSION=$(go list -m -f '{{.Version}}' github.com/golangci/golangci-lint)" >> $GITHUB_ENV
- uses: golangci/golangci-lint-action@v6
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
only-new-issues: true
# HINT(lukasmalkmus): Unit tests are only run for PRs originating from forks
# and thus are only run for different Go versions but not for different
# environments (as we don't want to pass secrets to forks).
test-unit:
name: Test
needs: lint
runs-on: ubuntu-latest
# HINT(lukasmalkmus): Only run unit tests for PRs originating from forks.
if: github.event.pull_request.head.repo.full_name != github.repository
strategy:
fail-fast: false
matrix:
go:
- "1.22"
- "1.23"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Test
run: make test
# HINT(lukasmalkmus): Integration tests are only run for PRs originating from
# the upstream repository and thus are also run for different environments.
# Running integration tests also includes running unit tests so there is no
# need to run them separately.
test-integration:
name: Test
needs: lint
runs-on: ubuntu-latest
# HINT(lukasmalkmus): Only run integration tests for PRs originating in the
# upstream repository.
if: github.event.pull_request.head.repo.full_name == github.repository
# HINT(lukasmalkmus): Make sure the job is only ever run once per
# environment, across all active jobs and workflows. Errors on the
# development environment will not cancel the matrix jobs on the staging
# environment (and thus not affect the overall workflow status).
concurrency:
group: ${{ matrix.environment }}
cancel-in-progress: false
continue-on-error: ${{ matrix.environment == 'development' }}
strategy:
fail-fast: true
matrix:
go:
- "1.22"
- "1.23"
environment:
- development
- staging
include:
- environment: development
slug: DEV
- environment: staging
slug: STAGING
env:
AXIOM_URL: ${{ secrets[format('TESTING_{0}_API_URL', matrix.slug)] }}
AXIOM_TOKEN: ${{ secrets[format('TESTING_{0}_TOKEN', matrix.slug)] }}
AXIOM_ORG_ID: ${{ secrets[format('TESTING_{0}_ORG_ID', matrix.slug)] }}
AXIOM_DATASET_SUFFIX: ${{ github.run_id }}-${{ matrix.go }}
TELEMETRY_TRACES_URL: ${{ secrets.TELEMETRY_TRACES_URL }}
TELEMETRY_TRACES_TOKEN: ${{ secrets.TELEMETRY_TRACES_TOKEN }}
TELEMETRY_TRACES_DATASET: ${{ vars[format('TELEMETRY_{0}_TRACES_DATASET', matrix.slug)] }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Test
run: make test-integration
- name: Cleanup (On Test Failure)
if: failure()
run: |
curl -sL $(curl -s https://api.github.com/repos/axiomhq/cli/releases/tags/v0.10.0 | grep "http.*linux_amd64.tar.gz" | awk '{print $2}' | sed 's|[\"\,]*||g') | tar xzvf - --strip-components=1 --wildcards -C /usr/local/bin "axiom_*_linux_amd64/axiom"
axiom dataset list -f=json | jq '.[] | select(.id | contains("${{ github.run_id }}-${{ matrix.go }}")).id' | xargs -r -n1 axiom dataset delete -f
ci-pass:
name: CI Pass
needs:
- gen-diff
- lint
- test-unit
- test-integration
runs-on: ubuntu-latest
if: always()
steps:
# HINT(lukasmalkmus): "Codegen diff" and "Lint" need to pass as well as
# one of the "Test" jobs (either integration or unit tests).
- if: |
needs.gen-diff.result != 'success' ||
needs.lint.result != 'success' ||
!(needs.test-unit.result == 'success' ||
needs.test-integration.result == 'success')
run: exit 1