Skip to content

Commit 7f477d8

Browse files
authored
CI/CD: Run integration tests and GoReleaser concurrently (#3258)
1 parent c74fbd5 commit 7f477d8

File tree

3 files changed

+112
-60
lines changed

3 files changed

+112
-60
lines changed

.github/workflows/pr_build.yml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: "PR: Run Unit tests and Build artifacts for all platforms"
2+
3+
# When will this pipeline be activated?
4+
# 1. On any pull-request, or if someone pushes to a branch called
5+
# "tlim_testpr".
6+
on:
7+
pull_request:
8+
workflow_dispatch:
9+
# Want to trigger all the tests without making a PR?
10+
# Run: git push origin main:tlim_testpr --force
11+
# This will trigger a full PR test on the main branch.
12+
# See https://github.com/StackExchange/dnscontrol/actions/workflows/pr_test.yml?query=branch%3Atlim_testpr
13+
push:
14+
branches:
15+
- 'tlim_testpr'
16+
17+
# Environment Variables
18+
env:
19+
# cache-key: Change to force cache reset `pwsh > Get-Date -UFormat %s`
20+
cache-key: 1639697695
21+
# go-mod-path: Where go-mod writes temp files
22+
go-mod-path: /go/pkg/mod
23+
# BIND_DOMAIN: BIND is the one providers that we always test. By
24+
# defining this here, we know it will always be set.
25+
BIND_DOMAIN: example.com
26+
27+
jobs:
28+
29+
# Run unit tests:
30+
31+
build:
32+
runs-on: ubuntu-latest
33+
env:
34+
TEST_RESULTS: "/tmp/test-results"
35+
steps:
36+
- uses: actions/checkout@v4
37+
with:
38+
fetch-depth: 0
39+
- name: Set up Go
40+
uses: actions/setup-go@v5
41+
with:
42+
go-version: stable
43+
- name: restore_cache
44+
uses: actions/[email protected]
45+
with:
46+
key: linux-go-${{ hashFiles('go.sum') }}-${{ env.cache-key }}
47+
restore-keys: linux-go-${{ hashFiles('go.sum') }}-${{ env.cache-key }}
48+
path: ${{ env.go-mod-path }}
49+
- run: mkdir -p "$TEST_RESULTS"
50+
- name: Run unit tests
51+
run: |
52+
go install gotest.tools/gotestsum@latest
53+
gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- $PACKAGE_NAMES
54+
# - name: Enforce Go Formatted Code
55+
# run: "[ `go fmt ./... | wc -l` -eq 0 ]"
56+
- uses: actions/[email protected]
57+
with:
58+
name: unit-tests
59+
path: ${{ env.TEST_RESULTS }}
60+
61+
# build: Use GoReleaser to build binaries for all platforms.
62+
63+
# Stringer is needed because .goreleaser includes "go generate ./..."
64+
- name: Install stringer
65+
run: |
66+
go install golang.org/x/tools/cmd/stringer@latest
67+
68+
-
69+
id: build_binaries_tagged
70+
name: Build binaries (if tagged)
71+
if: github.ref_type == 'tag'
72+
uses: goreleaser/goreleaser-action@v6
73+
with:
74+
distribution: goreleaser
75+
version: latest
76+
args: build
77+
-
78+
id: build_binaries_not_tagged
79+
name: Build binaries (not tagged)
80+
if: github.ref_type != 'tag'
81+
uses: goreleaser/goreleaser-action@v6
82+
with:
83+
args: build --snapshot

.github/workflows/pr_test.yml .github/workflows/pr_integration_tests.yml

+26-59
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,37 @@
1-
name: "PR: Run all tests"
1+
name: "PR: Run integration tests"
2+
3+
# When will this pipeline be activated?
4+
# 1. On any pull-request, or if someone pushes to a branch called
5+
# "tlim_testpr".
26
on:
3-
# git push origin main:tlim_testpr --force
4-
# will trigger a full PR test on the main branch:
5-
# https://github.com/StackExchange/dnscontrol/actions/workflows/pr_test.yml?query=branch%3Atlim_testpr
7+
pull_request:
8+
workflow_dispatch:
9+
# Want to trigger all the tests without making a PR?
10+
# Run: git push origin main:tlim_testpr --force
11+
# This will trigger a full PR test on the main branch.
12+
# See https://github.com/StackExchange/dnscontrol/actions/workflows/pr_test.yml?query=branch%3Atlim_testpr
613
push:
714
branches:
815
- 'tlim_testpr'
9-
pull_request:
10-
workflow_dispatch:
1116

17+
# Environment Variables
1218
env:
13-
cache-key: 1639697695 #Change to force cache reset `pwsh > Get-Date -UFormat %s`
19+
# cache-key: Change to force cache reset `pwsh > Get-Date -UFormat %s`
20+
cache-key: 1639697695
21+
# go-mod-path: Where go-mod writes temp files
1422
go-mod-path: /go/pkg/mod
23+
# BIND_DOMAIN: BIND is the one providers that we always test. By
24+
# defining this here, we know it will always be set.
1525
BIND_DOMAIN: example.com
1626

1727
jobs:
18-
build:
19-
runs-on: ubuntu-latest
20-
env:
21-
TEST_RESULTS: "/tmp/test-results"
22-
steps:
23-
- uses: actions/checkout@v4
24-
with:
25-
fetch-depth: 0
26-
- name: Set up Go
27-
uses: actions/setup-go@v5
28-
with:
29-
go-version: stable
30-
- name: restore_cache
31-
uses: actions/[email protected]
32-
with:
33-
key: linux-go-${{ hashFiles('go.sum') }}-${{ env.cache-key }}
34-
restore-keys: linux-go-${{ hashFiles('go.sum') }}-${{ env.cache-key }}
35-
path: ${{ env.go-mod-path }}
36-
- run: mkdir -p "$TEST_RESULTS"
37-
- name: Run unit tests
38-
run: |
39-
go install gotest.tools/gotestsum@latest
40-
gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- $PACKAGE_NAMES
41-
- name: Enforce Go Formatted Code
42-
run: "[ `go fmt ./... | wc -l` -eq 0 ]"
43-
- uses: actions/[email protected]
44-
with:
45-
name: unit-tests
46-
path: ${{ env.TEST_RESULTS }}
47-
48-
# Stringer is needed because .goreleaser includes "go generate ./..."
49-
- name: Install stringer
50-
run: |
51-
go install golang.org/x/tools/cmd/stringer@latest
5228

53-
-
54-
id: build_binaries_tagged
55-
name: Build binaries (if tagged)
56-
if: github.ref_type == 'tag'
57-
uses: goreleaser/goreleaser-action@v6
58-
with:
59-
distribution: goreleaser
60-
version: latest
61-
args: build
62-
-
63-
id: build_binaries_not_tagged
64-
name: Build binaries (not tagged)
65-
if: github.ref_type != 'tag'
66-
uses: goreleaser/goreleaser-action@v6
67-
with:
68-
args: build --snapshot
29+
# integration-test-providers: Determine which providers have a _DOMAIN variable set.
30+
# That variable enables testing for the provider. The results are
31+
# stored in a JSON blob stashed in # needs.integration-test-providers.outputs.integration_test_providers
32+
# where integration-tests can pick it up.
6933
integration-test-providers:
70-
needs: build
34+
#needs: build
7135
runs-on: ubuntu-latest
7236
outputs:
7337
integration_test_providers: ${{ steps.get_integration_test_providers.outputs.integration_test_providers }}
@@ -92,6 +56,9 @@ jobs:
9256
ENV_CONTEXT: ${{ toJson(env) }}
9357
VARS_CONTEXT: ${{ toJson(vars) }}
9458
SECRETS_CONTEXT: ${{ toJson(secrets) }}
59+
60+
# integration-tests: Run the integration tests on any provider listed
61+
# in needs.integration-test-providers.outputs.integration_test_providers.
9562
integration-tests:
9663
if: github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main'
9764
runs-on: ubuntu-latest
@@ -150,7 +117,7 @@ jobs:
150117
CNR_UID: ${{ secrets.CNR_UID }}
151118
CNR_PW: ${{ secrets.CNR_PW }}
152119
CNR_ENTITY: ${{ secrets.CNR_ENTITY }}
153-
#
120+
#
154121
DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}
155122
#
156123
GANDI_V5_APIKEY: ${{ secrets.GANDI_V5_APIKEY }}

.github/workflows/release_draft.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
name: "Release: Make release candidate"
2+
13
on:
24
push:
35
tags:
46
- v[0-9]+.[0-9]+.[0-9]+
57
- v[0-9]+.[0-9]+.[0-9]+-*
68

7-
name: "Release: Make release candidate"
89
jobs:
910
draft_release:
1011
name: draft release
@@ -49,6 +50,7 @@ jobs:
4950
run: |
5051
go install golang.org/x/tools/cmd/stringer@latest
5152
53+
# use GoReleaser to build for all platforms.
5254
-
5355
id: release
5456
name: Goreleaser release

0 commit comments

Comments
 (0)