Skip to content

Commit 0a1fd69

Browse files
authored
feat: CI integration — acceptance test matrix & release workflow (#504)
feat: CI integration — acceptance test matrix & release workflow
2 parents 2ffc854 + 9fff899 commit 0a1fd69

2 files changed

Lines changed: 141 additions & 0 deletions

File tree

.github/workflows/go-release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: 'Go Edition Release'
2+
3+
on:
4+
push:
5+
tags:
6+
- 'go/v*'
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
14+
release:
15+
name: 'Release'
16+
runs-on: 'ubuntu-latest'
17+
steps:
18+
- uses: 'actions/checkout@v4'
19+
with:
20+
fetch-depth: 0
21+
- uses: 'actions/setup-go@v5'
22+
with:
23+
go-version-file: 'go/go.mod'
24+
cache-dependency-path: 'go/go.sum'
25+
- uses: 'goreleaser/goreleaser-action@v6'
26+
with:
27+
distribution: 'goreleaser'
28+
version: '~> v2'
29+
args: 'release --clean'
30+
workdir: 'go'
31+
env:
32+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'

.github/workflows/go-test.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: 'Go Edition Tests'
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'go/**'
7+
- '.github/workflows/go-test.yml'
8+
push:
9+
branches:
10+
- 'master'
11+
- 'feat/488-go-edition'
12+
paths:
13+
- 'go/**'
14+
- '.github/workflows/go-test.yml'
15+
schedule:
16+
- cron: '0 4 * * *'
17+
workflow_dispatch:
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
24+
unit-tests:
25+
name: 'Unit Tests (${{ matrix.os }})'
26+
runs-on: '${{ matrix.os }}'
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
os:
31+
- 'ubuntu-latest'
32+
- 'macos-latest'
33+
- 'windows-latest'
34+
steps:
35+
- uses: 'actions/checkout@v4'
36+
- uses: 'actions/setup-go@v5'
37+
with:
38+
go-version-file: 'go/go.mod'
39+
cache-dependency-path: 'go/go.sum'
40+
- name: 'Run unit tests'
41+
working-directory: 'go'
42+
run: 'go test -v -race -count=1 ./internal/...'
43+
- name: 'Vet'
44+
working-directory: 'go'
45+
run: 'go vet ./...'
46+
47+
acceptance-tests:
48+
name: 'Acceptance (${{ matrix.edition }}, ${{ matrix.os }})'
49+
runs-on: '${{ matrix.os }}'
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
edition:
54+
- 'bash'
55+
- 'go'
56+
os:
57+
- 'ubuntu-latest'
58+
- 'macos-latest'
59+
- 'windows-latest'
60+
exclude:
61+
# Bash edition does not work on Windows natively
62+
- edition: 'bash'
63+
os: 'windows-latest'
64+
steps:
65+
- uses: 'actions/checkout@v4'
66+
- uses: 'actions/setup-go@v5'
67+
with:
68+
go-version-file: 'go/go.mod'
69+
cache-dependency-path: 'go/go.sum'
70+
71+
- name: 'Build Go edition binary'
72+
if: matrix.edition == 'go'
73+
working-directory: 'go'
74+
run: 'go build -o tfenv-go ./cmd/tfenv'
75+
76+
- name: 'Set TFENV_TEST_BINARY (Go edition, Unix)'
77+
if: matrix.edition == 'go' && runner.os != 'Windows'
78+
run: echo "TFENV_TEST_BINARY=${{ github.workspace }}/go/tfenv-go" >> "$GITHUB_ENV"
79+
80+
- name: 'Set TFENV_TEST_BINARY (Go edition, Windows)'
81+
if: matrix.edition == 'go' && runner.os == 'Windows'
82+
run: echo "TFENV_TEST_BINARY=${{ github.workspace }}\go\tfenv-go.exe" >> $env:GITHUB_ENV
83+
84+
- name: 'Set TFENV_TEST_BINARY (Bash edition)'
85+
if: matrix.edition == 'bash'
86+
run: echo "TFENV_TEST_BINARY=${{ github.workspace }}/bin/tfenv" >> "$GITHUB_ENV"
87+
88+
- name: 'Run acceptance tests'
89+
working-directory: 'go'
90+
run: 'go test -v -race -count=1 ./test/acceptance/...'
91+
92+
integration-tests:
93+
name: 'Integration Tests'
94+
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
95+
runs-on: 'ubuntu-latest'
96+
steps:
97+
- uses: 'actions/checkout@v4'
98+
- uses: 'actions/setup-go@v5'
99+
with:
100+
go-version-file: 'go/go.mod'
101+
cache-dependency-path: 'go/go.sum'
102+
- name: 'Build Go edition'
103+
working-directory: 'go'
104+
run: 'go build -o tfenv-go ./cmd/tfenv'
105+
- name: 'Run integration tests'
106+
working-directory: 'go'
107+
env:
108+
TFENV_TEST_BINARY: '${{ github.workspace }}/go/tfenv-go'
109+
run: 'go test -v -tags=integration -count=1 ./test/acceptance/...'

0 commit comments

Comments
 (0)