Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(label): skip duplicated build on PR creation #3155

Merged
merged 27 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d613257
ci(label): skip triggering build for PRs that created with matched la…
clearloop Aug 22, 2023
1622888
ci(label): display source branch that triggers build
clearloop Aug 22, 2023
a085833
ci(label): embed the details of the dispatched workflow
clearloop Aug 22, 2023
26b9e30
ci(label): skip dispatching by default
clearloop Aug 22, 2023
a6801f5
ci(label): use PR info for build run name
clearloop Aug 22, 2023
c2cca8c
ci(label): trigger build
clearloop Aug 22, 2023
27f5a5e
ci(label): pass PR info from env
clearloop Aug 22, 2023
38fd356
ci(label): concat string with gh expression
clearloop Aug 22, 2023
d58fa53
Merge branch 'master' into cl/issue-3148-2
clearloop Aug 23, 2023
3331046
ci(label): clean typos
clearloop Aug 23, 2023
dc70d84
ci(label): support A4-insubstantial
clearloop Aug 23, 2023
c54078b
ci(label): log check runs
clearloop Aug 23, 2023
a8f1d03
Merge branch 'master' into cl/issue-3148-2
clearloop Aug 23, 2023
ef6ca34
ci(label): support mergeongreen
clearloop Aug 23, 2023
3217f76
ci(label): use expr contains
clearloop Aug 23, 2023
d0920ca
ci(label): chain conditions
clearloop Aug 23, 2023
9517e1f
ci(label): use == instead of ===
clearloop Aug 23, 2023
5d7ccc9
ci(label): use single quote for mergeoncegreen
clearloop Aug 23, 2023
c62fcf3
ci(label): passing core to function skip
clearloop Aug 23, 2023
a4b946f
ci(label): fix issue from #3154
clearloop Aug 23, 2023
016cf6e
ci(PR): support A4-insubstantial in PR
clearloop Aug 23, 2023
9d4ac66
ci(label): introduce timeout
clearloop Aug 23, 2023
0b0ce4c
ci(label): skip timeout for completed jobs
clearloop Aug 24, 2023
b09fc04
ci(label): the last test on triggering with labelling
clearloop Aug 24, 2023
5fe8456
ci(label): return on complete
clearloop Aug 24, 2023
f687051
ci(label): remove timeout since now we keeping the run histories
clearloop Aug 24, 2023
8325300
ci(PR): trigger
clearloop Aug 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions .github/actions/label/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

const [owner, repo] = ["gear-tech", "gear"];
const { LABEL, REF, HEAD_SHA } = process.env;
const { LABEL, REF, HEAD_SHA, TITLE, NUMBER } = process.env;
const linux = LABEL === "A0-pleasereview";
const checks = linux ? ["linux", "win-cross"] : ["x86"];
const workflow_id = linux
Expand Down Expand Up @@ -31,12 +31,17 @@ const skip = async ({ github }) => {
? check_runs.filter((run) => run.name === "build" || run.name === "build / linux")
: check_runs.filter((run) => run.name === "build / macox-x86");

if (runs.length === 0) return false;
// Skip this action by default.
let skipped = false;
for (run of runs) {
if (run.conclusion !== "skipped") return true;
// Process this action only if the previous build has been skipped.
if (run.name === "build" && run.conclusion === "skipped") skipped = true;

// If there is already a build, skip this action without more conditions.
if (run.name === "build / linux" || run.name === "build / macox-x86") return true;
clearloop marked this conversation as resolved.
Show resolved Hide resolved
}

return false;
return !skipped;
};

/**
Expand Down Expand Up @@ -72,8 +77,13 @@ const dispatchWorkflow = async ({ core, github }) => {
repo,
workflow_id,
ref: REF,
inputs: {
title: TITLE,
number: NUMBER,
}
});

// Wait for the workflow to be dispatched.
await sleep(10000);

// Get the target workflow run
Expand Down Expand Up @@ -128,6 +138,7 @@ module.exports = async ({ github, core }) => {
}

const run = await dispatchWorkflow({ core, github });
core.info(`Dispatched workflow ${run.html_url}`);
let labelChecks = await createChecks({ core, github });

while (true) {
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ on:
type: boolean
default: false
workflow_dispatch:
inputs:
title:
type: string
description: "Pull request title that triggers this workflow."
number:
type: string
description: "Pull reqeust number that triggers this workflow"
clearloop marked this conversation as resolved.
Show resolved Hide resolved

run-name: ${{ inputs.title }} ( ${{ format('#{0}', inputs.number) }} )

env:
CARGO_INCREMENTAL: 0
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
LABEL: ${{ github.event.label.name }}
REF: ${{ github.head_ref || github.ref_name }}
TITLE: ${{ github.event.pull_request.title }}
NUMBER: ${{ github.event.number }}
with:
script: |
const script = require('./.github/actions/label/build.js');
Expand Down
Loading