Skip to content

pin GitHub Actions to full commit SHAs and rework actions SHAs to own variables #1566

pin GitHub Actions to full commit SHAs and rework actions SHAs to own variables

pin GitHub Actions to full commit SHAs and rework actions SHAs to own variables #1566

Workflow file for this run

name: Run Tests
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
permissions:
contents: read # to fetch code (actions/checkout)
env:
LATEST_GO_VERSION: "1.26"
# https://github.com/actions/checkout/commit/df4cb1c069e1874edd31b4311f1884172cec0e10
CHECKOUT_ACTION: &checkout_action actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
# https://github.com/actions/setup-go/commit/924ae3a1cded613372ab5595356fb5720e22ba16
SETUP_GO_ACTION: &setup_go_action actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6
# https://github.com/codecov/codecov-action/commit/fb8b3582c8e4def4969c97caa2f19720cb33a72f
CODECOV_ACTION: &codecov_action codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# Each major Go release is supported until there are two newer major releases. https://golang.org/doc/devel/release.html#policy
# Echo tests with last four major releases (unless there are pressing vulnerabilities)
# As we depend on `golang.org/x/` libraries which only support the last 2 Go releases, we could have situations when
# we derive from the last four major releases promise.
go: ["1.25", "1.26"]
name: ${{ matrix.os }} @ Go ${{ matrix.go }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Code
uses: *checkout_action
- name: Set up Go ${{ matrix.go }}
uses: *setup_go_action
with:
go-version: ${{ matrix.go }}
- name: Run Tests
run: go test -race --coverprofile=coverage.coverprofile --covermode=atomic ./...
- name: Upload coverage to Codecov
if: success() && matrix.go == env.LATEST_GO_VERSION && matrix.os == 'ubuntu-latest'
uses: *codecov_action
with:
token:
fail_ci_if_error: false
benchmark:
needs: test
name: Benchmark comparison
runs-on: ubuntu-latest
steps:
- name: Checkout Code (Previous)
uses: *checkout_action
with:
ref: ${{ github.base_ref }}
path: previous
- name: Checkout Code (New)
uses: *checkout_action
with:
path: new
- name: Set up Go
uses: *setup_go_action
with:
go-version: ${{ env.LATEST_GO_VERSION }}
- name: Install Dependencies
run: go install golang.org/x/perf/cmd/benchstat@latest
- name: Run Benchmark (Previous)
run: |
cd previous
go test -run="-" -bench=".*" -count=8 ./... > benchmark.txt
- name: Run Benchmark (New)
run: |
cd new
go test -run="-" -bench=".*" -count=8 ./... > benchmark.txt
- name: Run Benchstat
run: |
benchstat previous/benchmark.txt new/benchmark.txt