Skip to content

benchmark: this is a test #19

benchmark: this is a test

benchmark: this is a test #19

name: Benchmark PR (new linter)
on:
issues:
types:
- labeled
permissions:
issues: write
jobs:
notify-ack:
if: ${{ github.event.label.name == 'bench-new-linter' }}
runs-on: ubuntu-latest
steps:
- name: Put a reaction
run: |
gh api graphql --silent --raw-field query="mutation AddReaction {addReaction(input:{subjectId:\"$NODE_ID\",content:EYES}){reaction{content}subject{id}}}"
gh api graphql --silent --raw-field query="mutation RemoveReaction {removeReaction(input:{subjectId:\"$NODE_ID\",content:CONFUSED}){reaction{content}subject{id}}}" | true
gh api graphql --silent --raw-field query="mutation RemoveReaction {removeReaction(input:{subjectId:\"$NODE_ID\",content:ROCKET}){reaction{content}subject{id}}}" | true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_ID: ${{ github.event.issue.node_id }}
bench-job:
needs: notify-ack
if: ${{ github.event.label.name == 'bench-new-linter' }}
runs-on: ubuntu-latest
strategy:
matrix:
repository:
- 'golangci/golangci-lint'
- 'goreleaser/goreleaser'
- 'gohugoio/hugo'
- 'go-gitea/gitea'
- 'rclone/rclone'
- 'syncthing/syncthing'
# - 'moby/moby' # no go.mod (custom approach vendor.mod)
- 'kubernetes/kubernetes'
- 'hashicorp/terraform'
- 'hashicorp/consul'
- 'grafana/grafana'
- 'etcd-io/etcd'
- 'go-acme/lego'
- 'traefik/traefik'
- 'spf13/cobra'
- 'google/go-github'
- 'beego/beego'
- 'grpc/grpc-go'
- 'go-delve/delve'
- 'ethereum/go-ethereum'
- 'pact-foundation/pact-go' # CGO inside
steps:
- uses: actions/checkout@v4
with:
repository: 'golangci/golangci-lint'
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Checkout PR
run: |
gh pr checkout --detach --repo "golangci/golangci-lint" ${{fromJson(github.event.issue.body).pr}}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build golangci-lint
run: |
make build
cp ./golangci-lint $(go env GOPATH)/bin/golangci-lint
- name: Clone ${{ matrix.repository }}
run: |
git clone -q --depth 1 --single-branch https://github.com/${{ matrix.repository }}.git /tmp/target
cd /tmp/target
go mod tidy
- name: Run Bench ${{ matrix.repository }}
run: |
cd /tmp/target
golangci-lint cache clean
golangci-lint run --issues-exit-code=0 --timeout=30m --enable-only ${{fromJson(github.event.issue.body).linter}}
# golangci-lint run --no-config --issues-exit-code=0 --timeout=30m --disable-all --enable ${{fromJson(github.event.issue.body).linter}}
notify-job-result:
runs-on: ubuntu-latest
needs: bench-job
if: ${{ github.event.label.name == 'bench-new-linter' && always() }}
steps:
- name: Notify on Success
if: ${{ contains(needs.*.result, 'success') }}
run: |
gh api graphql --silent --raw-field query="mutation AddReaction {addReaction(input:{subjectId:\"$NODE_ID\",content:ROCKET}){reaction{content}subject{id}}}"
gh api graphql --silent --raw-field query="mutation RemoveReaction {removeReaction(input:{subjectId:\"$NODE_ID\",content:CONFUSED}){reaction{content}subject{id}}}" | true
gh api graphql --silent --raw-field query="mutation RemoveReaction {removeReaction(input:{subjectId:\"$NODE_ID\",content:EYES}){reaction{content}subject{id}}}" | true
(
echo "**${{ github.workflow }}**"
echo "The benchmark is done!"
echo
echo "You can find the workflow here:"
echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
) | \
gh issue comment "${ISSUE_NUMBER}" --repo ${{ github.repository }} -F -
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
NODE_ID: ${{ github.event.issue.node_id }}
- name: Notify on Failure
if: ${{ contains(needs.*.result, 'failure') }}
run: |
gh api graphql --silent --raw-field query="mutation AddReaction {addReaction(input:{subjectId:\"$NODE_ID\",content:CONFUSED}){reaction{content}subject{id}}}"
gh api graphql --silent --raw-field query="mutation RemoveReaction {removeReaction(input:{subjectId:\"$NODE_ID\",content:ROCKET}){reaction{content}subject{id}}}" | true
gh api graphql --silent --raw-field query="mutation RemoveReaction {removeReaction(input:{subjectId:\"$NODE_ID\",content:EYES}){reaction{content}subject{id}}}" | true
(
echo "**${{ github.workflow }}**"
echo "**Something went wrong!**"
echo
echo "**Details:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
) | \
gh issue comment "${ISSUE_NUMBER}" --repo ${{ github.repository }} -F -
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
NODE_ID: ${{ github.event.issue.node_id }}