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: migrate CI to label-driven CI #374

Merged
merged 1 commit into from
Jun 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 28 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
---
name: Build examples
on:
push:
pull_request:
branches:
- master
branches:
- master
types:
- labeled
- synchronize

# include workflow_dispatch to enable manual trigger from Web UI.
workflow_dispatch:
Expand All @@ -18,18 +20,32 @@ jobs:
# if: ${{ needs.pre_build.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
should_skip: ${{ steps.skip_check.outputs.result }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v3.4.0
uses: actions/github-script@v6
with:
concurrent_skipping: same_content

# if the change includes documentation, or ruby files changes only, skip.
paths_ignore: '["docs/**", "**/*.md", "*.md", "**/*.rb"]'

# but do not skip if the triggered event is one of these.
do_not_skip: '["workflow_dispatch", "schedule", "pull_request"]'
result-encoding: string
script: |
console.log(JSON.stringify(context, null, 2))
let should_skip = false;

switch(context.payload.action) {
// when the added label is not "area:components", skip
case "labeled":
if (context.payload.label.name != "area:components" && context.payload.label.name != "area:ci") {
should_skip = true;
}
break;
// when the PR branch is updated, but "area:components" label is not found, skip
case "synchronize":
let labels = context.payload.pull_request.labels.map(label => { return label.name });
if (!labels.includes("area:components") && !labels.includes("area:ci")) {
should_skip = true;
}
break;
}
return should_skip;

# XXX create multiple jobs for major versions
#
Expand Down
36 changes: 27 additions & 9 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
---
name: "Build the documentation"
on:
- pull_request
- push
pull_request:
branches:
- master
types:
- labeled
- synchronize

jobs:
pre_build:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
should_skip: ${{ steps.skip_check.outputs.result }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v3.4.0
uses: actions/github-script@v6
with:
result-encoding: string
script: |
console.log(JSON.stringify(context, null, 2))
let should_skip = false;

# if the content does not change, skip.
concurrent_skipping: same_content

# but do not skip if the triggered event is one of these.
do_not_skip: '["workflow_dispatch", "schedule"]'
switch(context.payload.action) {
case "labeled":
if (context.payload.label.name != "area:docs" && context.payload.label.name != "area:ci") {
should_skip = true;
}
break;
case "synchronize":
let labels = context.payload.pull_request.labels.map(label => { return label.name });
if (!labels.includes("area:docs") && !labels.includes("area:ci")) {
should_skip = true;
}
break;
}
return should_skip;
docs:
runs-on: ubuntu-latest
needs: pre_build
Expand Down
38 changes: 37 additions & 1 deletion .github/workflows/metadata.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
---
name: Metadata
on: [push, pull_request]
on:
pull_request:
branches:
- master
types:
- labeled
- synchronize
jobs:
pre_build:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.result }}
steps:
- id: skip_check
uses: actions/github-script@v6
with:
result-encoding: string
script: |
console.log(JSON.stringify(context, null, 2))
let should_skip = false;

switch(context.payload.action) {
case "labeled":
if (context.payload.label.name != "area:components" && context.payload.label.name != "area:ci") {
should_skip = true;
}
break;
case "synchronize":
let labels = context.payload.pull_request.labels.map(label => { return label.name });
if (!labels.includes("area:components") && !labels.includes("are:ci")) {
should_skip = true;
}
break;
}
return should_skip;
test:
runs-on: ubuntu-latest
needs: pre_build
if: ${{ needs.pre_build.outputs.should_skip != 'true' }}
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
Expand Down