# //.github/workflows:trunk.yml
#
# This file exists to define the steps executed for a push to the default tree.
# For configuring the steps that occur after a push to all other branches under
# the refs/heads namespace, see `//.github/workflows:presubmit.yml`.
---
name: trunk

on:
  push:
    branches:
      - trunk

concurrency:
  group: ${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  build-and-test:
    uses: ./.github/workflows/build-and-test.yml
    secrets: inherit

  benchmark:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      deployments: write
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

      - uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
        with:
          go-version: 1.24.2

      - name: Run benchmark
        run: go test -v ./... -bench=. -run=xxx -benchmem | tee output.txt

      - name: Store benchmark result
        uses: benchmark-action/github-action-benchmark@d48d326b4ca9ba73ca0cd0d59f108f9e02a381c7 # v1.20.4
        with:
          tool: 'go'
          output-file-path: output.txt
          github-token: ${{ secrets.GITHUB_TOKEN }}
          comment-on-alert: true
          auto-push: true
