Skip to content

Commit 30c1766

Browse files
authored
Migrate from CircleCI to GitHub Actions for tests and releases (#27)
This also enables linting via `actionlint` and `golangci-lint`. The Contributing Guide is updated with information how to run tooling locally and prepare releases using the new process.
1 parent b476773 commit 30c1766

File tree

12 files changed

+247
-305
lines changed

12 files changed

+247
-305
lines changed

.circleci/config.yml

Lines changed: 0 additions & 164 deletions
This file was deleted.

.github/CONTRIBUTING.md

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,61 @@ We belive that one should "leave the campsite cleaner than you found it", so
127127
you are welcome to clean up cosmetic issues in the neighbourhood when
128128
submitting a patch that makes functional changes or fixes.
129129

130+
## Linting
131+
132+
GitHub Actions workflow bug and style checking is performed via [`actionlint`](https://github.com/rhysd/actionlint).
133+
134+
To run the GitHub Actions linters locally, install the `actionlint` tool, and run:
135+
136+
```shell
137+
actionlint
138+
```
139+
140+
Go code bug and style checking is performed via [`golangci-lint`](https://golangci-lint.run/).
141+
142+
To run the Go linters locally, install the `golangci-lint` tool, and run:
143+
144+
```shell
145+
golangci-lint run ./...
146+
```
147+
130148
## Testing
131149

132150
Code contributions should be supported by unit tests wherever possible.
133151

134-
### Unit tests
152+
### GitHub Actions Tests
153+
154+
GitHub Actions workflow testing is performed via [`act`](https://github.com/nektos/act).
155+
156+
To run the GitHub Actions testing locally (setting appropriate event):
157+
158+
```shell
159+
act --artifact-server-path /tmp --env ACTIONS_RUNTIME_TOKEN=test -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest pull_request
160+
```
161+
162+
The command options can be added to a `~/.actrc` file:
163+
164+
```text
165+
--artifact-server-path /tmp
166+
--env ACTIONS_RUNTIME_TOKEN=test
167+
-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest
168+
```
169+
170+
So they do not need to be specified every invocation:
171+
172+
```shell
173+
act pull_request
174+
```
175+
176+
### Go Unit Tests
177+
178+
Go code unit testing is perfomed via Go's built-in testing functionality.
179+
180+
To run the Go unit testing locally:
181+
182+
```shell
183+
go test ./...
184+
```
135185

136186
This codebase follows Go conventions for unit testing. Some guidelines include:
137187

@@ -163,3 +213,37 @@ func TestExample(t *testing.T) {
163213
}
164214
}
165215
```
216+
217+
## Maintainers Guide
218+
219+
This section is dedicated to the maintainers of this project.
220+
221+
### Releases
222+
223+
Before running a release, the changelog must be constructed from unreleased entries in the `.changelog` directory.
224+
225+
Install the latest version of the [`changelog-build`](https://pkg.go.dev/github.com/hashicorp/go-changelog/cmd/changelog-build) command, if it not already available:
226+
227+
```shell
228+
go install github.com/hashicorp/go-changelog/cmd/changelog-build
229+
```
230+
231+
Run the [`changelog-build`](https://pkg.go.dev/github.com/hashicorp/go-changelog/cmd/changelog-build) command from the root directory of the repository:
232+
233+
```shell
234+
changelog-build -changelog-template .changelog.tmpl -entries-dir .changelog -last-release $(git describe --tags --abbrev=0) -note-template .changelog-note.tmpl -this-release HEAD
235+
```
236+
237+
This will generate a section of Markdown text for the next release. Open the `CHANGELOG.md` file, add a `# X.Y.Z` header as the first line, then add the output from the `changelog-build` command.
238+
239+
Commit, push, create a release Git tag, and push the tag:
240+
241+
```shell
242+
git add CHANGELOG.md
243+
git commit -m "Update CHANGELOG for v1.2.3"
244+
git push
245+
git tag v1.2.3
246+
git push --tags
247+
```
248+
249+
GitHub Actions will pick up the new release tag and kick off the release workflow.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Continuous integration handling for GitHub Actions workflows
2+
name: ci-github-actions
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- .github/workflows/*.yml
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
actionlint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- id: go-version
18+
# Reference: https://github.com/actions/setup-go/issues/23
19+
run: echo "::set-output name=version::$(cat ./.go-version)"
20+
- uses: actions/setup-go@v2
21+
with:
22+
go-version: ${{ steps.go-version.outputs.version }}
23+
- run: go install github.com/rhysd/actionlint/cmd/actionlint@latest
24+
- run: actionlint

.github/workflows/ci-go.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Continuous integration handling for Go
2+
name: ci-go
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- .github/workflows/test.yml
8+
- .golangci.yml
9+
- .go-version
10+
- go.mod
11+
- '**.go'
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
golangci-lint:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v2
21+
- id: go-version
22+
# Reference: https://github.com/actions/setup-go/issues/23
23+
run: echo "::set-output name=version::$(cat ./.go-version)"
24+
- uses: actions/setup-go@v2
25+
with:
26+
go-version: ${{ steps.go-version.outputs.version }}
27+
- run: go mod download
28+
- uses: golangci/golangci-lint-action@v2
29+
with:
30+
skip-go-installation: true
31+
test:
32+
name: test (Go v${{ matrix.go-version }})
33+
runs-on: ubuntu-latest
34+
strategy:
35+
matrix:
36+
go-version: [ '1.17', '1.16' ]
37+
steps:
38+
- uses: actions/checkout@v2
39+
- uses: actions/setup-go@v2
40+
with:
41+
go-version: ${{ matrix.go-version }}
42+
- run: go mod download
43+
- run: go test -coverprofile=coverage.out ./...
44+
- run: go tool cover -html=coverage.out -o coverage.html
45+
- uses: actions/upload-artifact@v2
46+
with:
47+
name: go-${{ matrix.go-version }}-coverage
48+
path: coverage.html
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Continuous integration handling for GoReleaser
2+
name: ci-goreleaser
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- .goreleaser.yml
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
check:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- id: go-version
18+
# Reference: https://github.com/actions/setup-go/issues/23
19+
run: echo "::set-output name=version::$(cat ./.go-version)"
20+
- uses: actions/setup-go@v2
21+
with:
22+
go-version: ${{ steps.go-version.outputs.version }}
23+
- uses: goreleaser/goreleaser-action@v2
24+
with:
25+
args: check

0 commit comments

Comments
 (0)