benchmark: PR 5259 (exptostd) #100
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Benchmark PR (updated linter) | |
on: | |
issues: | |
types: | |
- labeled | |
permissions: | |
issues: write | |
jobs: | |
notify-ack: | |
if: ${{ github.event.label.name == 'bench-updated-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-updated-linter' }} | |
runs-on: ubuntu-latest | |
env: | |
PR_NUMBER: ${{ fromJson(github.event.issue.body).pr }} | |
LINTER: ${{ fromJson(github.event.issue.body).linter }} | |
GOLANGCI_LINT_VERSION: ${{ fromJson(github.event.issue.body).version }} | |
MAX_ISSUES_PER_LINTER: ${{ fromJson(github.event.issue.body).maxIssuesPerLinter }} | |
MAX_LINES_PER_RUN: ${{ fromJson(github.event.issue.body).maxLinesPerRun }} | |
TARGET_DIR: /tmp/target | |
HYPERFINE_VERSION: 1.18.0 | |
strategy: | |
matrix: | |
target: | |
- org: golangci | |
repo: golangci-lint | |
- org: goreleaser | |
repo: goreleaser | |
- org: gohugoio | |
repo: hugo | |
- org: go-gitea | |
repo: gitea | |
- org: rclone | |
repo: rclone | |
- org: kubernetes | |
repo: kubernetes | |
- org: hashicorp | |
repo: terraform | |
- org: hashicorp | |
repo: consul | |
- org: etcd-io | |
repo: etcd | |
- org: go-acme | |
repo: lego | |
- org: traefik | |
repo: traefik | |
- org: spf13 | |
repo: cobra | |
- org: google | |
repo: go-github | |
- org: beego | |
repo: beego | |
- org: grpc | |
repo: grpc-go | |
- org: go-delve | |
repo: delve | |
- org: cilium | |
repo: cilium | |
# CGO inside | |
- org: pact-foundation | |
repo: pact-go | |
steps: | |
- name: Hyperfine installation | |
run: | | |
wget https://github.com/sharkdp/hyperfine/releases/download/v${HYPERFINE_VERSION}/hyperfine_${HYPERFINE_VERSION}_amd64.deb | |
sudo dpkg -i hyperfine_${HYPERFINE_VERSION}_amd64.deb | |
- 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" ${PR_NUMBER} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build golangci-lint from PR | |
# use `go build` to set ldflags (it reduces some performance differences with binaries created by goreleaser) | |
run: | | |
go build -trimpath -ldflags '-s -w' -o golangci-lint ./cmd/golangci-lint | |
mv ./golangci-lint $(go env GOPATH)/bin/golangci-lint | |
- name: Install golangci-lint ${{ fromJson(github.event.issue.body).version }} | |
run: | | |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "./temp-${GOLANGCI_LINT_VERSION}" "${GOLANGCI_LINT_VERSION}" | |
mv "temp-${GOLANGCI_LINT_VERSION}/golangci-lint" "$(go env GOPATH)/bin/golangci-lint-${GOLANGCI_LINT_VERSION}" | |
rm -rf "temp-${GOLANGCI_LINT_VERSION}" | |
- name: Clone ${{ matrix.target.org }}/${{ matrix.target.repo }} | |
run: | | |
git clone -q --depth 1 --single-branch https://github.com/${{ matrix.target.org }}/${{ matrix.target.repo }}.git ${TARGET_DIR} | |
cd ${TARGET_DIR} | |
go mod tidy | |
- name: Simple run of golangci-lint (local) on ${{ matrix.target.org }}/${{ matrix.target.repo }} (without cache) | |
run: | | |
cd ${TARGET_DIR} | |
golangci-lint cache clean | |
golangci-lint run -v --issues-exit-code=0 --max-issues-per-linter ${MAX_ISSUES_PER_LINTER:-50} --max-same-issues 10 --timeout=20m --show-stats --out-format colored-line-number,line-number:run.txt --enable-only ${LINTER} | |
- name: Simple run of golangci-lint (${{ fromJson(github.event.issue.body).version }}) on ${{ matrix.target.org }}/${{ matrix.target.repo }} (without cache) | |
run: | | |
cd ${TARGET_DIR} | |
golangci-lint-${GOLANGCI_LINT_VERSION} cache clean | |
golangci-lint-${GOLANGCI_LINT_VERSION} run -v --issues-exit-code=0 --max-issues-per-linter ${MAX_ISSUES_PER_LINTER:-50} --max-same-issues 10 --timeout=20m --show-stats --out-format colored-line-number,line-number:runprevious.txt --enable-only ${LINTER} | |
- name: Run bench on ${{ matrix.target.org }}/${{ matrix.target.repo }} (without cache) | |
run: | | |
cd ${TARGET_DIR} | |
hyperfine --export-markdown perf.md --warmup 2 \ | |
-n 'local' --prepare 'golangci-lint cache clean' "golangci-lint run --issues-exit-code=0 --timeout=20m --print-issued-lines=false --enable-only ${LINTER}" \ | |
-n "${GOLANGCI_LINT_VERSION}" --prepare "golangci-lint-${GOLANGCI_LINT_VERSION} cache clean" "golangci-lint-${GOLANGCI_LINT_VERSION} run --issues-exit-code 0 --timeout=20m --print-issued-lines=false --enable-only ${LINTER}" | |
- name: Build report for ${{ matrix.target.org }}/${{ matrix.target.repo }} | |
run: | | |
cd ${TARGET_DIR} | |
mkdir -p /tmp/outputs/${REPO}/ | |
echo "## [${ORG}/${REPO}](${{ github.server_url }}/${ORG}/${REPO})" >> ${REPORT_DEST} | |
echo >> ${REPORT_DEST} | |
if test "$( cat run.txt | wc -c )" -gt 1 | |
then | |
echo '<details><summary>local</summary>' >> ${REPORT_DEST} | |
echo >> ${REPORT_DEST} | |
echo '```' >> ${REPORT_DEST} | |
cat run.txt | head -n ${MAX_LINES_PER_RUN:-500} >> ${REPORT_DEST} | |
echo '```' >> ${REPORT_DEST} | |
echo >> ${REPORT_DEST} | |
echo '</details>' >> ${REPORT_DEST} | |
echo >> ${REPORT_DEST} | |
fi | |
if test "$( cat runprevious.txt | wc -c )" -gt 1 | |
then | |
echo "<details><summary>${GOLANGCI_LINT_VERSION}</summary>" >> ${REPORT_DEST} | |
echo >> ${REPORT_DEST} | |
echo '```' >> ${REPORT_DEST} | |
cat runprevious.txt | head -n ${MAX_LINES_PER_RUN:-500} >> ${REPORT_DEST} | |
echo '```' >> ${REPORT_DEST} | |
echo >> ${REPORT_DEST} | |
echo '</details>' >> ${REPORT_DEST} | |
echo >> ${REPORT_DEST} | |
fi | |
cat perf.md >> ${REPORT_DEST} | |
echo >> ${REPORT_DEST} | |
env: | |
ORG: ${{ matrix.target.org }} | |
REPO: ${{ matrix.target.repo }} | |
REPORT_DEST: /tmp/outputs/${{ matrix.target.repo }}/report.md | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: outputs-${{ matrix.target.repo }} | |
path: /tmp/outputs/**/report.md | |
notify-job-result: | |
runs-on: ubuntu-latest | |
needs: bench-job | |
if: ${{ github.event.label.name == 'bench-updated-linter' && always() }} | |
steps: | |
- name: Load outputs | |
if: ${{ contains(needs.*.result, 'success') }} | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: outputs-* | |
path: /tmp/outputs/ | |
- 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 "The benchmark (${{ github.workflow }}) is done!" | |
echo | |
cat /tmp/outputs/**/**/*.md | |
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 }} |