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

.github: Skip unnecessary workflow steps #16157

Merged
merged 5 commits into from
May 20, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 32 additions & 1 deletion .github/workflows/aks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,42 @@ env:
check_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

jobs:
check_changes:
name: Deduce required tests from code changes
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers: This job could also be integrated into installation-and-connectivity to reduce the number of different jobs displayed for each pull request. The downside of that approach is that the job would not be clearly marked as skipped (since only a subset of steps would be skipped).

runs-on: ubuntu-latest
outputs:
tested: ${{ steps.tested-tree.outputs.src }}
steps:
- name: Retrieve pull request's base and head
id: pr
run: |
curl ${{ github.event.issue.pull_request.url }} > pr.json
echo "::set-output name=base::$(jq -r '.base.sha' pr.json)"
echo "::set-output name=head::$(jq -r '.head.sha' pr.json)"
# Because we run on issue comments, we need to checkout the code for
# paths-filter to work.
- name: Checkout code
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
persist-credentials: false
- name: Check code changes
uses: dorny/paths-filter@78ab00f87740f82aec8ed8826eb4c3c851044126
id: tested-tree
with:
base: ${{ steps.pr.outputs.base }}
ref: ${{ steps.pr.outputs.head }}
filters: |
src:
- '!(test|Documentation)/**'

# When the test-me-please trigger is used, this job is skipped if the only
# modified files were under test/ or Documentation/.
installation-and-connectivity:
needs: check_changes
if: |
(github.event.issue.pull_request && (
startsWith(github.event.comment.body, 'ci-aks') ||
startsWith(github.event.comment.body, 'test-me-please')
(startsWith(github.event.comment.body, 'test-me-please') && (needs.check_changes.outputs.tested == 'true'))
)) ||
(github.event_name == 'schedule' && github.repository == 'cilium/cilium') ||
github.event.label.name == 'ci-run/aks'
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/bpf-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@ concurrency:
cancel-in-progress: true

jobs:
check_changes:
name: Deduce required tests from code changes
runs-on: ubuntu-latest
outputs:
bpf-tree: ${{ steps.changes.outputs.bpf-tree }}
coccinelle: ${{ steps.changes.outputs.coccinelle }}
steps:
- name: Check code changes
uses: dorny/paths-filter@78ab00f87740f82aec8ed8826eb4c3c851044126
id: changes
with:
base: ${{ github.event.pull_request.base.sha || github.event.before }}
filters: |
bpf-tree:
- 'bpf/**'
coccinelle:
- 'contrib/coccinelle/**'

checkpatch:
name: checkpatch
runs-on: ubuntu-latest
Expand All @@ -31,7 +49,11 @@ jobs:
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took # selectable (default: repo,message)
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

# Runs only if code under bpf/ or contrib/coccinnelle/ is changed.
coccicheck:
needs: check_changes
if: ${{ needs.check_changes.outputs.bpf-tree == 'true' || needs.check_changes.outputs.coccinelle == 'true' }}
name: coccicheck
runs-on: ubuntu-latest
steps:
Expand All @@ -49,7 +71,11 @@ jobs:
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took # selectable (default: repo,message)
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

# Runs only if code under bpf/ is changed.
build_all:
needs: check_changes
if: ${{ needs.check_changes.outputs.bpf-tree == 'true' }}
name: build datapath
runs-on: ubuntu-latest
steps:
Expand Down
23 changes: 22 additions & 1 deletion .github/workflows/build_commits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,28 @@ jobs:
${{ github.event.pull_request.commits_url }})
PR_FIRST_SHA=$(echo "$PR_COMMITS_API_JSON" | jq -r ".[0].sha")
PR_PARENT_SHA=$(git rev-parse "${PR_FIRST_SHA}^")
git rebase --exec "make build -j $(nproc) && make -C bpf build_all -j $(nproc)" $PR_PARENT_SHA
git rebase --exec "make build -j $(nproc)" $PR_PARENT_SHA

- name: Check code changes
uses: dorny/paths-filter@78ab00f87740f82aec8ed8826eb4c3c851044126
id: bpf-tree
with:
base: ${{ github.event.pull_request.base.sha }}
filters: |
src:
- 'bpf/**'

# Runs only if code under bpf/ is changed.
- name: Check if datapath build works for every commit
if: steps.bpf-tree.outputs.src == 'true'
run: |
PR_COMMITS_API_JSON=$(curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
${{ github.event.pull_request.commits_url }})
PR_FIRST_SHA=$(echo "$PR_COMMITS_API_JSON" | jq -r ".[0].sha")
PR_PARENT_SHA=$(git rev-parse "${PR_FIRST_SHA}^")
git rebase --exec "make -C bpf build_all -j $(nproc)" $PR_PARENT_SHA

- name: Failed commit during the build
if: ${{ failure() }}
Expand Down
18 changes: 17 additions & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,26 @@ name: Documentation Updates

# Any change in triggers needs to be reflected in the concurrency group.
on:
pull_request: {}
pull_request:
paths:
- 'Documentation/**'
- 'bugtool/cmd/**'
- 'cilium/cmd/**'
- 'cilium-health/cmd/**'
- 'daemon/cmd/**'
- 'hubble-relay/cmd/**'
- 'operator/cmd/**'
push:
branches:
- master
paths:
- 'Documentation/**'
- 'bugtool/cmd/**'
- 'cilium/cmd/**'
- 'cilium-health/cmd/**'
- 'daemon/cmd/**'
- 'hubble-relay/cmd/**'
- 'operator/cmd/**'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
Expand Down
33 changes: 32 additions & 1 deletion .github/workflows/eks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,42 @@ env:
check_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

jobs:
check_changes:
name: Deduce required tests from code changes
runs-on: ubuntu-latest
outputs:
tested: ${{ steps.tested-tree.outputs.src }}
steps:
- name: Retrieve pull request's base and head
id: pr
run: |
curl ${{ github.event.issue.pull_request.url }} > pr.json
echo "::set-output name=base::$(jq -r '.base.sha' pr.json)"
echo "::set-output name=head::$(jq -r '.head.sha' pr.json)"
# Because we run on issue comments, we need to checkout the code for
# paths-filter to work.
- name: Checkout code
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
persist-credentials: false
- name: Check code changes
uses: dorny/paths-filter@78ab00f87740f82aec8ed8826eb4c3c851044126
id: tested-tree
with:
base: ${{ steps.pr.outputs.base }}
ref: ${{ steps.pr.outputs.head }}
filters: |
src:
- '!(test|Documentation)/**'

# When the test-me-please trigger is used, this job is skipped if the only
# modified files were under test/ or Documentation/.
installation-and-connectivity:
needs: check_changes
if: |
(github.event.issue.pull_request && (
startsWith(github.event.comment.body, 'ci-eks') ||
startsWith(github.event.comment.body, 'test-me-please')
(startsWith(github.event.comment.body, 'test-me-please') && (needs.check_changes.outputs.tested == 'true'))
)) ||
(github.event_name == 'schedule' && github.repository == 'cilium/cilium') ||
github.event.label.name == 'ci-run/eks'
Expand Down
33 changes: 32 additions & 1 deletion .github/workflows/gke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,42 @@ env:
check_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

jobs:
check_changes:
name: Deduce required tests from code changes
runs-on: ubuntu-latest
outputs:
tested: ${{ steps.tested-tree.outputs.src }}
steps:
- name: Retrieve pull request's base and head
id: pr
run: |
curl ${{ github.event.issue.pull_request.url }} > pr.json
echo "::set-output name=base::$(jq -r '.base.sha' pr.json)"
echo "::set-output name=head::$(jq -r '.head.sha' pr.json)"
# Because we run on issue comments, we need to checkout the code for
# paths-filter to work.
- name: Checkout code
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
persist-credentials: false
- name: Check code changes
uses: dorny/paths-filter@78ab00f87740f82aec8ed8826eb4c3c851044126
id: tested-tree
with:
base: ${{ steps.pr.outputs.base }}
ref: ${{ steps.pr.outputs.head }}
filters: |
src:
- '!(test|Documentation)/**'

# When the test-me-please trigger is used, this job is skipped if the only
# modified files were under test/ or Documentation/.
installation-and-connectivity:
needs: check_changes
if: |
(github.event.issue.pull_request && (
startsWith(github.event.comment.body, 'ci-gke') ||
startsWith(github.event.comment.body, 'test-me-please')
(startsWith(github.event.comment.body, 'test-me-please') && (needs.check_changes.outputs.tested == 'true'))
)) ||
(github.event_name == 'schedule' && github.repository == 'cilium/cilium') ||
github.event.label.name == 'ci-run/gke'
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/kind-1.19.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ name: ConformanceKind1.19

# Any change in triggers needs to be reflected in the concurrency group.
on:
pull_request: {}
pull_request:
paths-ignore:
- 'Documentation/**'
- 'test/**'
push:
branches:
- master
paths-ignore:
- 'Documentation/**'
- 'test/**'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
Expand Down
33 changes: 32 additions & 1 deletion .github/workflows/multicluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,42 @@ env:
check_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

jobs:
check_changes:
name: Deduce required tests from code changes
runs-on: ubuntu-latest
outputs:
tested: ${{ steps.tested-tree.outputs.src }}
steps:
- name: Retrieve pull request's base and head
id: pr
run: |
curl ${{ github.event.issue.pull_request.url }} > pr.json
echo "::set-output name=base::$(jq -r '.base.sha' pr.json)"
echo "::set-output name=head::$(jq -r '.head.sha' pr.json)"
# Because we run on issue comments, we need to checkout the code for
# paths-filter to work.
- name: Checkout code
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
persist-credentials: false
- name: Check code changes
uses: dorny/paths-filter@78ab00f87740f82aec8ed8826eb4c3c851044126
id: tested-tree
with:
base: ${{ steps.pr.outputs.base }}
ref: ${{ steps.pr.outputs.head }}
filters: |
src:
- '!(test|Documentation)/**'

# When the test-me-please trigger is used, this job is skipped if the only
# modified files were under test/ or Documentation/.
installation-and-connectivity:
needs: check_changes
if: |
(github.event.issue.pull_request && (
startsWith(github.event.comment.body, 'ci-multicluster') ||
startsWith(github.event.comment.body, 'test-me-please')
(startsWith(github.event.comment.body, 'test-me-please') && (needs.check_changes.outputs.tested == 'true'))
)) ||
(github.event_name == 'schedule' && github.repository == 'cilium/cilium') ||
github.event.label.name == 'ci-run/multicluster'
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/smoke-test-ipv6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ name: Smoke Test with IPv6

# Any change in triggers needs to be reflected in the concurrency group.
on:
pull_request: {}
pull_request:
paths-ignore:
- 'Documentation/**'
- 'test/**'
push:
branches:
- master
paths-ignore:
- 'Documentation/**'
- 'test/**'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/smoke-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ name: Smoke test

# Any change in triggers needs to be reflected in the concurrency group.
on:
pull_request: {}
pull_request:
paths-ignore:
- 'Documentation/**'
- 'test/**'
push:
branches:
- master
paths-ignore:
- 'Documentation/**'
- 'test/**'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
Expand Down