Skip to content

Commit

Permalink
[ci] Use GH actions to expand OS test matrix (#174)
Browse files Browse the repository at this point in the history
Expand testing to all OS versions available on GitHub actions
(macos-{11,12,13} on amd64, ubuntu-{20.04,22.04}, windows-{2019,2022}).
Jenkins will remain for testing on macOS on arm64 and ubuntu-18.

Add github workflow to generate releases with release notes. There is no
more CHANGELOG.md. Instead there is a tool used to generate the release
notes from individual changelog entries found in
`.changelog/{pr_number}.txt`.

Replace goimports and golint with a roughly equivalent golangci-lint
configuration. This will be expanded to be more thorough in a separate
change.

Add check that go.mod is tidy.

Add CONTRIBUTING.md.
  • Loading branch information
andrewkroh committed May 18, 2023
1 parent c0d4d10 commit 451c7aa
Show file tree
Hide file tree
Showing 17 changed files with 308 additions and 391 deletions.
3 changes: 3 additions & 0 deletions .changelog/172.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
darwin: Prevent possible runtime panic while reading process arguments.
```
20 changes: 5 additions & 15 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ pipeline {
axes {
axis {
name 'GO_VERSION'
values '1.18.10', '1.19.5'
values '1.20.4'
}
axis {
name 'PLATFORM'
values 'ubuntu-18 && immutable', 'windows-2019 && immutable', 'orka && darwin && x86_64', 'orka && darwin && arm64'
values 'ubuntu-18 && immutable', 'orka && darwin && arm64'
}
axis {
name 'CGO_ENABLED'
Expand All @@ -51,22 +51,12 @@ pipeline {
excludes {
exclude {
axis {
name 'GO_VERSION'
values '1.18.10'
name 'CGO_ENABLED'
values '1'
}
axis {
name 'PLATFORM'
values 'orka && darwin && arm64'
}
}
exclude {
axis {
name 'GO_VERSION'
values '1.19.5'
}
axis {
name 'PLATFORM'
notValues 'orka && darwin && arm64'
values 'ubuntu-18 && immutable'
}
}
}
Expand Down
43 changes: 43 additions & 0 deletions .ci/release/changelog.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if .NotesByType.note -}}
NOTES:
{{range .NotesByType.note -}}
* {{ template "note" .}}
{{ end -}}
{{- end -}}

{{- if .NotesByType.deprecation -}}
DEPRECATIONS:
{{range .NotesByType.deprecation -}}
* {{ template "note" .}}
{{ end -}}
{{- end -}}

{{- if index .NotesByType "breaking-change" -}}
BREAKING CHANGES:
{{range index .NotesByType "breaking-change" -}}
* {{ template "note" .}}
{{ end -}}
{{- end -}}

{{- $features := combineTypes .NotesByType.feature (index .NotesByType "new-resource" ) (index .NotesByType "new-datasource") (index .NotesByType "new-data-source") -}}
{{- if $features }}
FEATURES:
{{range $features | sort -}}
* {{ template "note" . }}
{{ end -}}
{{- end -}}

{{- $improvements := combineTypes .NotesByType.improvement .NotesByType.enhancement -}}
{{- if $improvements }}
IMPROVEMENTS:
{{range $improvements | sort -}}
* {{ template "note" . }}
{{ end -}}
{{- end -}}

{{- if .NotesByType.bug }}
BUG FIXES:
{{range .NotesByType.bug -}}
* {{ template "note" . }}
{{ end -}}
{{- end -}}
3 changes: 3 additions & 0 deletions .ci/release/release-note.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- define "note" -}}
{{if eq "new-resource" .Type}}**New Resource:** {{else if eq "new-datasource" .Type}}**New Data Source:** {{ end }}{{.Body}} ([GH-{{- .Issue -}}])
{{- end -}}
40 changes: 40 additions & 0 deletions .ci/scripts/check-changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
set -uo pipefail

if [[ -z "${PR_NUMBER}" ]]; then
echo "PR_NUMBER must be set."
exit 1
fi

if [[ -z "${BASE_REF}" ]]; then
echo "BASE_REF must be set."
exit 1
fi

docs_url="https://github.com/GoogleCloudPlatform/magic-modules/blob/2834761fec3acbf35cacbffe100530f82eada650/.ci/RELEASE_NOTES_GUIDE.md#expected-format"

# Version of https://github.com/hashicorp/go-changelog.
go_changelog_version=ba40b3a
go_changelog_check="go run github.com/hashicorp/go-changelog/cmd/changelog-check@${go_changelog_version}"

expected_changelog_file=.changelog/${PR_NUMBER}.txt

# Verify file is present.
if [ ! -e "${expected_changelog_file}" ]; then
echo "Changelog file missing at ${expected_changelog_file}.
Please add a changelog entry following the format described [here](${docs_url}).
If this change does not require a changelog entry then label the pull request
with skip-changelog.
" >> $GITHUB_STEP_SUMMARY
exit 1
fi

# Check the format.
if ! ${go_changelog_check} "${expected_changelog_file}"; then
echo "Changelog format is invalid. See build log." >> $GITHUB_STEP_SUMMARY
exit 1
fi

echo "Changelog is valid." >> $GITHUB_STEP_SUMMARY
26 changes: 26 additions & 0 deletions .ci/scripts/check-cross-compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -xeuo pipefail

export CGO_ENABLED=0

# Test that there are no compilation issues when not using CGO. This does
# not imply that all of these targets are supported without CGO. It's only
# a sanity check for build tag issues.
GOOS=aix GOARCH=ppc64 go build ./...
GOOS=darwin GOARCH=amd64 go build ./...
GOOS=darwin GOARCH=arm64 go build ./...
GOOS=linux GOARCH=386 go build ./...
GOOS=linux GOARCH=amd64 go build ./...
GOOS=linux GOARCH=arm go build ./...
GOOS=linux GOARCH=arm64 go build ./...
GOOS=linux GOARCH=mips go build ./...
GOOS=linux GOARCH=mips64 go build ./...
GOOS=linux GOARCH=mips64le go build ./...
GOOS=linux GOARCH=mipsle go build ./...
GOOS=linux GOARCH=ppc64 go build ./...
GOOS=linux GOARCH=ppc64le go build ./...
GOOS=linux GOARCH=riscv64 go build ./...
GOOS=linux GOARCH=s390x go build ./...
GOOS=windows GOARCH=amd64 go build ./...
GOOS=windows GOARCH=arm go build ./...
GOOS=windows GOARCH=arm64 go build ./...
61 changes: 0 additions & 61 deletions .ci/scripts/check_format.go

This file was deleted.

80 changes: 0 additions & 80 deletions .ci/scripts/check_lint.go

This file was deleted.

6 changes: 0 additions & 6 deletions .ci/scripts/test.bat
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
go install github.com/elastic/go-licenser@latest
go install gotest.tools/gotestsum@latest

go mod verify
go-licenser -d
go run .ci/scripts/check_format.go
go run .ci/scripts/check_lint.go

mkdir -p build
SET OUT_FILE=build\output-report.out
gotestsum --format testname --junitfile build\junit-%GO_VERSION%.xml -- ./...
31 changes: 0 additions & 31 deletions .ci/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,8 @@
#!/usr/bin/env bash
set -euxo pipefail

go install github.com/elastic/go-licenser@latest
go install gotest.tools/gotestsum@latest

go mod verify
go-licenser -d
go run .ci/scripts/check_format.go
go run .ci/scripts/check_lint.go

# Cross-compile checks (only execute on Linux to avoid running this multiple times).
if [[ $(go env GOOS) == "linux" ]]; then
# Test that there are no compilation issues when not using CGO. This does
# not imply that all of these targets are supported without CGO. It's only
# a sanity check for build tag issues.
CGO_ENABLED=0 GOOS=aix GOARCH=ppc64 go build ./...
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build ./...
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=mips go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=ppc64 go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=riscv64 go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=s390x go build ./...
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build ./...
CGO_ENABLED=0 GOOS=windows GOARCH=arm go build ./...
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build ./...
fi

# Run the tests
export OUT_FILE="build/test-report.out"
mkdir -p build
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: changelog

on:
pull_request:
types: [opened, synchronize, labeled, unlabeled]
branches:
- main

jobs:
check:
if: "!contains(github.event.pull_request.labels.*.name, 'skip-changelog')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: changelog
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
BASE_REF: ${{ github.event.pull_request.base.ref }}
run: .ci/scripts/check-changelog.sh

0 comments on commit 451c7aa

Please sign in to comment.