/.github/workflows: add pull-report label add logic

This commit is contained in:
coffeegoddd
2024-01-11 17:02:04 -08:00
parent bc65707417
commit 9ae8fb2f70
3 changed files with 66 additions and 66 deletions
-55
View File
@@ -1,55 +0,0 @@
on:
push:
branches:
- 'db/compare'
jobs:
report-pull-request:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2.2.0
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: Remove Passing Labels if regression detected
uses: actions/github-script@v6
with:
github-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) {
console.log("found label: ", 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: '7309'
LABEL: 'correctness_approved'
+64 -10
View File
@@ -49,26 +49,80 @@ jobs:
ISSUE_NUMBER: ${{ github.event.client_payload.issue_number }}
FORMAT: ${{ github.event.client_payload.noms_bin_format }}
- name: Remove Passing Labels if regression detected
if: ${{ github.event.client_payload.is_regression == 'true' && github.event.client_payload.job_type == 'sql-correctness' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { ACTOR, ISSUE_NUMBER, GITHUB_WORKSPACE } = process.env;
const { ACTOR, ISSUE_NUMBER, LABEL, GITHUB_WORKSPACE } = process.env;
const issue_number = parseInt(ISSUE_NUMBER, 10);
const { owner, repo } = context.repo;
try {
const labels = github.rest.issues.createComment({
issue_number,
owner,
repo,
body: `@${ACTOR} ${FORMAT}\n ${data}`
});
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 }}
# if this is a regression
# first remove all correctness_approved labels from the pr
# if this
LABEL: 'correctness_approved'
- name: Add Passing Labels if regression detected
if: ${{ github.event.client_payload.is_regression !== 'true' && github.event.client_payload.job_type == 'sql-correctness' }}
uses: actions/github-script@v6
with:
github-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'
+2 -1
View File
@@ -13,11 +13,12 @@ jobs:
version: ${{ steps.set-vars.outputs.version }}
actor: ${{ steps.set-vars.outputs.actor }}
steps:
- name: Checkout PR HEAD REF
- name: Checkout BASE REF
uses: actions/checkout@v3
with:
ref: ${{ github.base_ref }}
- name: Get Current Correctness
if: ${{ needs.set-version-actor.outputs.actor == 'coffeegoddd' }}
id: regress-comp
working-directory: ./.github/scripts/sql-correctness
run: |