From 852a2ffd924ac47282f3e664acfae52ed81cf2d0 Mon Sep 17 00:00:00 2001 From: Luke Bakken Date: Mon, 24 Nov 2025 09:19:04 -0800 Subject: [PATCH] Update github actions versions This PR uses the [`actions-up`](https://github.com/azat-io/actions-up) tool to update all GitHub actions to their latest release version, and uses commit SHAs to ensure only that version is used. It also re-instates the Windows tests to see if they'll succeed. * Fix Windows on GHA to not use make * Build docker image as tar in separate step * Use `golangci/golangci-lint` action in a separate workflow * Move publish of go stream perf test docker image to its own workflow * Use `nproc` to set `NUM_PROCS` --- CiDockerfile => .ci/Dockerfile | 0 .ci/versions.json | 4 +- .github/workflows/build_and_test.yml | 132 +++++++++++------------- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/golangci-lint.yml | 26 +++++ .github/workflows/perf-test-publish.yml | 30 ++++++ Makefile | 14 +-- 7 files changed, 124 insertions(+), 84 deletions(-) rename CiDockerfile => .ci/Dockerfile (100%) create mode 100644 .github/workflows/golangci-lint.yml create mode 100644 .github/workflows/perf-test-publish.yml diff --git a/CiDockerfile b/.ci/Dockerfile similarity index 100% rename from CiDockerfile rename to .ci/Dockerfile diff --git a/.ci/versions.json b/.ci/versions.json index e2506775..5b137b8c 100644 --- a/.ci/versions.json +++ b/.ci/versions.json @@ -1,4 +1,4 @@ { - "erlang": "27.2", - "rabbitmq": "4.0.5" + "erlang": "27.3.4.6", + "rabbitmq": "4.2.1" } diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index c659e737..74586891 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -1,62 +1,69 @@ name: Build and Test on: + pull_request: + branches: + - main push: + branches: + - main + workflow_dispatch: + +permissions: + contents: read jobs: - test: + docker-build: runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - go: ['1.24'] steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Build and export - uses: docker/build-push-action@v5 + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + - uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 + - uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 with: context: . - file: CiDockerfile + file: ${{ github.workspace }}/.ci/Dockerfile tags: rabbitmq_tls:latest outputs: type=docker,dest=/tmp/rabbitmq_tls.tar - - name: Upload artifact - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 with: name: rabbitmq_tls path: /tmp/rabbitmq_tls.tar - - name: Download artifact - uses: actions/download-artifact@v4 + test: + runs-on: ubuntu-latest + needs: docker-build + strategy: + fail-fast: false + matrix: + go: ['1.24', '1.25'] + steps: + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + - uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 with: name: rabbitmq_tls path: /tmp - - name: Load image + - name: Load docker image run: | docker load --input /tmp/rabbitmq_tls.tar docker image ls -a docker run -d --rm --name rabbitmq-stream-client-test \ - -p 5552:5552 -p 5672:5672 -p 5671:5671 -p 5551:5551 -p 15672:15672 \ - -e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-rabbitmq_stream advertised_host localhost" \ - rabbitmq_tls - - name: wait for running + -p 5552:5552 -p 5672:5672 -p 5671:5671 -p 5551:5551 -p 15672:15672 \ + -e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-rabbitmq_stream advertised_host localhost" \ + rabbitmq_tls + - name: Wait for RabbitMQ to start run: | docker exec rabbitmq-stream-client-test /bin/bash -c 'ps -aux' docker exec rabbitmq-stream-client-test /bin/bash -c 'sleep 10' - docker exec rabbitmq-stream-client-test /bin/bash -c 'rabbitmqctl status' - docker exec rabbitmq-stream-client-test /bin/bash -c 'rabbitmqctl wait --pid 1 --timeout 70' - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 + docker exec rabbitmq-stream-client-test /bin/bash -c 'rabbitmqctl await_startup' + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + - uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 id: setup_go with: go-version: ${{ matrix.go }} check-latest: true - - name: Install golangci-lint - run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest - - run: make test GO_VERSION=${{ steps.setup_go.outputs.go-version }} - - uses: actions/checkout@main - - uses: codecov/codecov-action@v5 + - name: Get number of CPU cores + run: echo "NUM_PROCS=$(nproc)" >> $GITHUB_ENV + - run: make NUM_PROCS=$NUM_PROCS GO_VERSION=${{ steps.setup_go.outputs.go-version }} test + - uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1 with: fail_ci_if_error: false # optional (default = false) files: ./coverage.txt @@ -65,48 +72,29 @@ jobs: verbose: true # optional (default = false) env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - # temporany removed due of https://github.com/actions/checkout/issues/1186 - # test-win32: - # runs-on: windows-latest - # strategy: - # matrix: - # go: [ '1.22'] - # steps: - # - uses: actions/checkout@v4 - # - uses: actions/setup-go@v5 - # id: setup_go - # with: - # go-version: ${{ matrix.go }} - # check-latest: true - # - name: Cache installers - # uses: actions/cache@v4 - # with: - # # Note: the cache path is relative to the workspace directory - # # https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action - # path: ~/installers - # key: ${{ runner.os }}-v0-${{ hashFiles('.ci/versions.json') }} - # - name: Install and start RabbitMQ - # run: ./.ci/install.ps1 - # - name: Install GNU make - # run: choco install make - # - run: make test GO_VERSION=${{ steps.setup_go.outputs.go-version }} - publish: - runs-on: ubuntu-latest - needs: [test] + test-win32: + runs-on: windows-latest steps: - - uses: docker/setup-buildx-action@v2 - - uses: docker/login-action@v2 + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + - uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 + id: setup_go with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - uses: actions/checkout@v3 - - name: Publish Docker Image + go-version: '1.25' + check-latest: true + - name: Run Go checks + shell: pwsh run: | - set -x - VERSION=latest - export VERSION - if [[ ! $GITHUB_REF =~ "/tags/" ]] - then - VERSION=dev - fi - make perf-test-docker-push + go.exe vet ./pkg/stream + go.exe fmt ./... + - name: Cache installers + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + # Note: the cache path is relative to the workspace directory + # https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action + path: ~/installers + key: ${{ runner.os }}-v0-${{ hashFiles('.ci/versions.json') }} + - name: Install and start RabbitMQ + run: ${{ github.workspace }}/.ci/install.ps1 + - name: Run Ginkgo test suite + shell: pwsh + run: go.exe run -mod=mod github.com/onsi/ginkgo/v2/ginkgo -r --procs=$env:NUMBER_OF_PROCESSORS --compilers=$env:NUMBER_OF_PROCESSORS --randomize-all --randomize-suites --cover --coverprofile=coverage.txt --covermode=atomic --race --trace --tags debug --timeout=5m diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index b547260f..c267aef2 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -35,7 +35,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 00000000..7533e925 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,26 @@ +name: golangci-lint +on: + push: + branches: + - main + - master + pull_request: + +permissions: + contents: read + # Optional: allow read access to pull requests. Use with `only-new-issues` option. + # pull-requests: read + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + - uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 + with: + go-version: stable + - name: golangci-lint + uses: golangci/golangci-lint-action@e7fa5ac41e1cf5b7d48e45e42232ce7ada589601 # v9.1.0 + with: + version: v2.6 diff --git a/.github/workflows/perf-test-publish.yml b/.github/workflows/perf-test-publish.yml new file mode 100644 index 00000000..13db695f --- /dev/null +++ b/.github/workflows/perf-test-publish.yml @@ -0,0 +1,30 @@ +name: Publish Go Stream Perf Test + +on: + push: + branches: + - main + workflow_dispatch: + +permissions: + contents: read + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 + - uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + - name: Publish Docker Image + run: | + set -eux + export VERSION=latest + if [[ ! $GITHUB_REF =~ "/tags/" ]] + then + VERSION=dev + fi + make perf-test-docker-push diff --git a/Makefile b/Makefile index ec36f4f7..3cc47478 100644 --- a/Makefile +++ b/Makefile @@ -17,11 +17,11 @@ fmt: go fmt ./... check: - golangci-lint run --fix + golangci-lint run NUM_PROCS ?= 2 TEST_TIMEOUT ?= 3m -test: vet fmt check +test: vet fmt go run -mod=mod github.com/onsi/ginkgo/v2/ginkgo -r --procs=$(NUM_PROCS) --compilers=$(NUM_PROCS) \ --randomize-all --randomize-suites \ --cover --coverprofile=coverage.txt --covermode=atomic \ @@ -57,17 +57,16 @@ perf-test-docker-build: perf-test-build perf-test-docker-push: perf-test-docker-build $(BUILDKIT) push pivotalrabbitmq/go-stream-perf-test:$(VERSION) -RABBITMQ_OCI ?= rabbitmq:3-management +RABBITMQ_OCI ?= rabbitmq:4-management BUILDKIT_RUN_ARGS ?= --pull always .PHONY: rabbitmq-server rabbitmq-server: - $(BUILDKIT) build -t rabbitmq-tls-test -f CiDockerfile . + $(BUILDKIT) build --tag rabbitmq-tls-test --file .ci/Dockerfile . $(BUILDKIT) run -it --rm --name rabbitmq-tls-test \ -p 5552:5552 -p 5551:5551 -p 5672:5672 -p 15672:15672 \ -e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-rabbitmq_stream advertised_host localhost" \ rabbitmq-tls-test - rabbitmq-ha-proxy: cd compose/ha_tls; rm -rf tls-gen; cd compose/ha_tls; git clone https://github.com/michaelklishin/tls-gen tls-gen; cd tls-gen/basic; make @@ -87,10 +86,7 @@ rabbitmq-server-tls: -v $(shell pwd)/compose/tls/conf/:/etc/rabbitmq/ -v $(shell pwd)/compose/tls/tls-gen/basic/result/:/certs \ -e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-rabbitmq_stream advertised_host localhost" \ --pull always \ - docker.io/rabbitmq:3-management + docker.io/rabbitmq:4-management local-release: goreleaser release --skip-publish --rm-dist --skip=validate - - -