From efc8800a4fef1e3daebc08927766cc5ee73c98fe Mon Sep 17 00:00:00 2001 From: Mik-Nord Date: Thu, 1 May 2025 11:40:37 +0200 Subject: [PATCH 1/2] Added golang test suite --- .../automation-golang-test-suite.yml | 49 +++++++++++++++++++ examples/automation-golang-test-suite.yml | 10 ++++ 2 files changed, 59 insertions(+) create mode 100644 .github/workflows/automation-golang-test-suite.yml create mode 100644 examples/automation-golang-test-suite.yml diff --git a/.github/workflows/automation-golang-test-suite.yml b/.github/workflows/automation-golang-test-suite.yml new file mode 100644 index 0000000..05a28fd --- /dev/null +++ b/.github/workflows/automation-golang-test-suite.yml @@ -0,0 +1,49 @@ +name: Golang test suite + +on: + workflow_call: + +jobs: + test-suite: + name: Vet, Staticcheck, Gosec, and Test + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@master + + - name: Set up Go + uses: actions/setup-go@master + with: + go-version: '1.24' + + - name: Cache Go modules + uses: actions/cache@master + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Install dependencies + run: go mod download + + - name: Run go vet + run: go vet ./... + + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + + - name: Run staticcheck + run: staticcheck ./... + + - name: Install gosec + run: go install github.com/securego/gosec/v2/cmd/gosec@latest + + - name: Run gosec (security scanner) + run: gosec ./... + + - name: Run tests + run: go test ./... -v diff --git a/examples/automation-golang-test-suite.yml b/examples/automation-golang-test-suite.yml new file mode 100644 index 0000000..9cd645a --- /dev/null +++ b/examples/automation-golang-test-suite.yml @@ -0,0 +1,10 @@ +name: Golang test suite +description: Status check that fails if a PR with Golang code fails its test suite. + +on: + pull_request: + branches: [ master, main ] + +jobs: + shared: + uses: dfds/shared-workflows/.github/workflows/automation-golang-test-suite.yml@master From 8a32fdf82287ff0f6937bce54eb487b1335218cb Mon Sep 17 00:00:00 2001 From: README-bot Date: Thu, 1 May 2025 09:41:35 +0000 Subject: [PATCH 2/2] Update readme [skip actions] --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 46c04aa..4ffa401 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Shared workflows and actions: - [Auto release](#auto-release) - [Build lambda and upload to S3](#build-lambda-and-upload-to-s3) - [Enforce PR labels](#enforce-pr-labels) + - [Golang test suite](#golang-test-suite) - [Housekeeping](#housekeeping) - [Multi architecture docker build](#multi-architecture-docker-build) - [Block on-hold PRs](#block-on-hold-prs) @@ -110,6 +111,27 @@ jobs: uses: dfds/shared-workflows/.github/workflows/automation-enforce-release-labels.yml@master ``` +### Golang test suite + +_This is a workflow_ + +Status check that fails if a PR with Golang code fails its test suite. + +How to invoke this workflow: + +```yaml +name: Golang test suite + +on: + pull_request: + branches: [ master, main ] + +jobs: + shared: + uses: dfds/shared-workflows/.github/workflows/automation-golang-test-suite.yml@master + +``` + ### Housekeeping _This is a workflow_