From 5928c768f6fe8ea57e07d3af24ddd945c1d92be1 Mon Sep 17 00:00:00 2001 From: James Rasell Date: Wed, 8 Jul 2026 09:18:54 +0100 Subject: [PATCH] ci: Update to use modern Go and add copywrite headers workflow. This change updates CI to use stable and oldstable rather than an old and unsupported version of Go. A new copywrite workflow has been added and makefile target. The makefile also includes some standard targets which are useful for local development. Dependabot PRs are now grouped, so that maintenance is easier with less overhead. --- .copywrite.hcl | 6 ++++ .github/dependabot.yaml | 12 ++++++-- .github/workflows/build_test.yml | 52 ++++++++++++++++++-------------- .github/workflows/copywrite.yml | 24 +++++++++++++++ Makefile | 24 +++++++++++++++ 5 files changed, 93 insertions(+), 25 deletions(-) create mode 100644 .copywrite.hcl create mode 100644 .github/workflows/copywrite.yml create mode 100644 Makefile diff --git a/.copywrite.hcl b/.copywrite.hcl new file mode 100644 index 0000000..ca1fe5c --- /dev/null +++ b/.copywrite.hcl @@ -0,0 +1,6 @@ +schema_version = 1 + +project { + license = "MPL-2.0" + copyright_year = 2014 +} diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index 9b2a997..cf23b1e 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -1,4 +1,4 @@ -# Copyright IBM Corp. 2014, 2025 +# Copyright IBM Corp. 2014, 2026 # SPDX-License-Identifier: MPL-2.0 version: 2 @@ -10,10 +10,18 @@ updates: interval: "weekly" commit-message: prefix: "[chore] : " + groups: + github-actions: + patterns: + - "*" - package-ecosystem: "gomod" directory: "/" schedule: interval: "weekly" commit-message: - prefix: "[chore] : " \ No newline at end of file + prefix: "[chore] : " + groups: + go: + patterns: + - "*" diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index b9ddd18..a4cf8a6 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -1,30 +1,36 @@ name: Build and Test Workflow -on: +on: pull_request: + push: branches: [master] jobs: - build: - runs-on: ubuntu-latest + build: + runs-on: ubuntu-latest + strategy: + matrix: + go-version: + - "oldstable" + - "stable" - steps: - - name: Checkout Code - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 - - name: Setup Go - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 - with: - go-version: '1.24' - - name: Run golangci-lint - uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a - - name: Run test and generate coverage report - run: go test -v ./... -coverprofile=coverage.out - - name: Upload Coverage Report - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a - with: - name: coverage-report - path: coverage.out - - name: Display Coverage result - run: go tool cover -func=coverage.out - - name: Build Go - run: go build ./... \ No newline at end of file + steps: + - name: Checkout Code + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + - name: Setup Go + uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 + with: + go-version: ${{ matrix.go-version }} + - name: Run golangci-lint + uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 + - name: Run test and generate coverage report + run: go test -v -race ./... -coverprofile=coverage.out + - name: Upload Coverage Report + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a + with: + name: coverage-report + path: coverage.out + - name: Display Coverage result + run: go tool cover -func=coverage.out + - name: Build Go + run: go build ./... diff --git a/.github/workflows/copywrite.yml b/.github/workflows/copywrite.yml new file mode 100644 index 0000000..ebadf95 --- /dev/null +++ b/.github/workflows/copywrite.yml @@ -0,0 +1,24 @@ +name: Check Copywrite Headers + +on: + pull_request: + push: + branches: + - "main" + +jobs: + copywrite: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + fetch-depth: 0 + - uses: hashicorp/setup-copywrite@32638da2d4e81d56a0764aa1547882fc4d209636 # v1.1.3 + name: Setup Copywrite + with: + version: v0.25.3 + archive-checksum: e43f4b72fff3f219c5a5f883438d63edd5b68f5bea90a5d18abb3001c8c3aedc + - name: Check Header Compliance + run: make copywriteheaders +permissions: + contents: read diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f0af107 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +default: copywriteheaders lint test + +.PHONY: copywriteheaders +copywriteheaders: + @echo "==> Running copywrite headers plan..." + @copywrite headers --plan + @echo "==> Done" + +.PHONY: deps +deps: + @go install github.com/hashicorp/copywrite@b3e6599f43beff698f471c6f46888045453fa030 # v0.25.3 + @go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@c0d3ddc9cf3faa61a4e378e879ece580256d76e5 # v2.12.2 + +.PHONY: lint +lint: + @echo "==> Running linters..." + @golangci-lint run + @echo "==> Done" + +.PHONY: test +test: + @echo "==> Running tests..." + @go test -v -race ./... + @echo "==> Done"