Files
wehub-resource-sync 5357c39144
Race tests / Go race tests (ubuntu-22.04) (push) Waiting to run
Fuzzer / Run Fuzzer (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:01:40 +08:00

294 lines
12 KiB
YAML

name: Post to Pull Request
on:
repository_dispatch:
types: [ pull-report ]
jobs:
report-pull-request:
name: Report Performance Benchmarks/Correctness on Pull Request
runs-on: ubuntu-22.04
if: ${{ github.event.client_payload.issue_number != -1 }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Print Correctness Info
run: |
echo "correctness info: is_regression: $IS_REGRESSION"
echo "correctness info: correctness_percentage: $CORRECTNESS_PERCENTAGE"
echo "correctness info: branch_ref: $BRANCH_REF"
echo "job_type: $JOB_TYPE"
env:
IS_REGRESSION: ${{ github.event.client_payload.correctness_info.is_regression }}
CORRECTNESS_PERCENTAGE: ${{ github.event.client_payload.correctness_info.correctness_percentage }}
BRANCH_REF: ${{ github.event.client_payload.correctness_info.branch_ref }}
JOB_TYPE: ${{ github.event.client_payload.job_type }}
CORRECTNESS_REGRESSION: ${{ github.event.client_payload.correctness_info.is_regression == 'true' && github.event.client_payload.job_type == 'sql-correctness' }}
- name: Get benchmark/correctness results
id: get-results
run: aws s3api get-object --bucket="$BUCKET" --key="$KEY" results.log
env:
KEY: ${{ github.event.client_payload.key }}
BUCKET: ${{ github.event.client_payload.bucket }}
- name: Post results to PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.REPO_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
script: |
const { ACTOR, FORMAT, ISSUE_NUMBER, JOB_TYPE, GITHUB_WORKSPACE } = process.env;
const { owner, repo } = context.repo;
const issue_number = parseInt(ISSUE_NUMBER, 10);
const fs = require('fs').promises;
const resData = await fs.readFile(`${GITHUB_WORKSPACE}/results.log`, 'utf8');
// Consider also deleting stale sql-correctness comments
// Both correctness and performance are posted/deleted here, they may delete each other
if (JOB_TYPE == "performance-benchmarking") {
const commentMarker = '<!-- go-run-output -->';
// List comments on the PR
const { data: comments } = await github.rest.issues.listComments({
issue_number: issue_number,
owner: context.repo.owner,
repo: context.repo.repo
});
// Find correct comment to update
let comment = null;
if (resData.includes("tpcc-scale-factor-1")) {
comment = comments.find(comment => comment.body.includes(commentMarker) && comment.body.includes("tpcc-scale-factor-1"))
} else if (resData.includes("read_tests")) {
comment = comments.find(comment => comment.body.includes(commentMarker) && comment.body.includes("read_tests"))
}
if (comment) {
// Update the existing comment
await github.rest.issues.updateComment({
comment_id: comment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: `${commentMarker}\n@${ACTOR} ${FORMAT}\n${resData}`
})
} else {
// Create a new comment
await github.rest.issues.createComment({
issue_number: issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `${commentMarker}\n@${ACTOR} ${FORMAT}\n${resData}`
});
}
} else {
await github.rest.issues.createComment({
issue_number: issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `@${ACTOR} ${FORMAT}\n${resData}`
});
}
env:
ACTOR: ${{ github.event.client_payload.actor }}
FORMAT: ${{ github.event.client_payload.noms_bin_format }}
ISSUE_NUMBER: ${{ github.event.client_payload.issue_number }}
JOB_TYPE: ${{ github.event.client_payload.job_type }}
- name: Remove Passing Labels if regression detected
if: ${{ github.event.client_payload.correctness_info.is_regression == true && github.event.client_payload.job_type == 'sql-correctness' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.REPO_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
script: |
const { ACTOR, ISSUE_NUMBER, LABEL, GITHUB_WORKSPACE } = process.env;
const issue_number = parseInt(ISSUE_NUMBER, 10);
const { owner, repo } = context.repo;
try {
const res = await github.rest.issues.listLabelsOnIssue({
issue_number,
owner,
repo,
});
if (res.data) {
const labels = res.data;
for (const label of labels) {
if (label.name === LABEL) {
await github.rest.issues.removeLabel({
issue_number,
owner,
repo,
name: label.name,
});
}
}
}
} catch(e) {
console.error(e)
}
env:
ACTOR: ${{ github.event.client_payload.actor }}
ISSUE_NUMBER: ${{ github.event.client_payload.issue_number }}
LABEL: 'correctness_approved'
- name: Add Passing Labels if no regression detected
if: ${{ github.event.client_payload.correctness_info.is_regression != true && github.event.client_payload.job_type == 'sql-correctness' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.REPO_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
script: |
const { ACTOR, ISSUE_NUMBER, LABEL, GITHUB_WORKSPACE } = process.env;
const issue_number = parseInt(ISSUE_NUMBER, 10);
const { owner, repo } = context.repo;
try {
const res = await github.rest.issues.listLabelsOnIssue({
issue_number,
owner,
repo,
});
if (res.data) {
const labels = res.data;
for (const label of labels) {
if (label.name === LABEL) {
return;
}
}
await github.rest.issues.addLabels({
issue_number,
owner,
repo,
labels: [LABEL],
});
}
} catch(e) {
console.error(e)
}
env:
ACTOR: ${{ github.event.client_payload.actor }}
ISSUE_NUMBER: ${{ github.event.client_payload.issue_number }}
LABEL: 'correctness_approved'
- name: Remove Passing Performance Labels if performance regression detected
if: ${{ github.event.client_payload.is_performance_regression == true && github.event.client_payload.job_type == 'performance-benchmarking' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.REPO_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
script: |
const { ACTOR, ISSUE_NUMBER, LABEL, GITHUB_WORKSPACE } = process.env;
const issue_number = parseInt(ISSUE_NUMBER, 10);
const { owner, repo } = context.repo;
try {
const res = await github.rest.issues.listLabelsOnIssue({
issue_number,
owner,
repo,
});
if (res.data) {
const labels = res.data;
for (const label of labels) {
if (label.name === LABEL) {
await github.rest.issues.removeLabel({
issue_number,
owner,
repo,
name: label.name,
});
}
}
}
} catch(e) {
console.error(e)
}
env:
ACTOR: ${{ github.event.client_payload.actor }}
ISSUE_NUMBER: ${{ github.event.client_payload.issue_number }}
LABEL: 'performance_approved'
- name: Add Passing Performance Labels if no regression detected
if: ${{ github.event.client_payload.is_performance_regression != true && github.event.client_payload.job_type == 'performance-benchmarking' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.REPO_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
script: |
const { ACTOR, ISSUE_NUMBER, LABEL, GITHUB_WORKSPACE } = process.env;
const issue_number = parseInt(ISSUE_NUMBER, 10);
const { owner, repo } = context.repo;
try {
const res = await github.rest.issues.listLabelsOnIssue({
issue_number,
owner,
repo,
});
if (res.data) {
const labels = res.data;
for (const label of labels) {
if (label.name === LABEL) {
return;
}
}
await github.rest.issues.addLabels({
issue_number,
owner,
repo,
labels: [LABEL],
});
}
} catch(e) {
console.error(e)
}
env:
ACTOR: ${{ github.event.client_payload.actor }}
ISSUE_NUMBER: ${{ github.event.client_payload.issue_number }}
LABEL: 'performance_approved'
update-correctness-file:
name: Update Correctness File
needs: report-pull-request
runs-on: ubuntu-22.04
if: ${{ github.event.client_payload.correctness_info.is_regression != 'true' && github.event.client_payload.job_type == 'sql-correctness' }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.event.client_payload.correctness_info.branch_ref }}
repository: ${{ github.repository }}
token: ${{ secrets.REPO_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
- name: Write new correctness file
working-directory: ./.github/scripts/sql-correctness
env:
CORRECTNESS_PERCENTAGE: ${{ github.event.client_payload.correctness_info.correctness_percentage }}
run: |
if [ -z "$CORRECTNESS_PERCENTAGE" ]; then
echo "correctness percentage was empty, something went wrong"
exit 1
fi
echo "$CORRECTNESS_PERCENTAGE" > current_correctness.txt
- name: Changes detected
id: detect-changes
run: |
changes=$(git status --porcelain)
if [ ! -z "$changes" ]; then
echo "has-changes=true" >> $GITHUB_OUTPUT
fi
- uses: EndBug/add-and-commit@v9.1.4
if: ${{ steps.detect-changes.outputs.has-changes == 'true' }}
with:
message: ${{ format('[skip actions] [ga-update-correctness] SQL Correctness updated to {0}', github.event.client_payload.correctness_info.correctness_percentage) }}
add: "./current_correctness.txt"
cwd: "./.github/scripts/sql-correctness"
pull: "--ff"