Skip to content

Commit

Permalink
.github: Skip unnecessary ci-xxx tests
Browse files Browse the repository at this point in the history
We don't need to run the ci-xxx end-to-end tests if only Documentation/
or test/ are touched. We therefore skip them in case of the trigger
phrase 'test-me-please'. If these tests are explicitly requested via the
'ci-xxx' trigger phrase, we run them.

Obviously, we could extend this beyond these two directories, but the
goal here is to keep the list simple while catching the most common
cases.

Signed-off-by: Paul Chaignon <paul@cilium.io>
  • Loading branch information
pchaigno authored and aanm committed May 20, 2021
1 parent 71400ba commit 50df544
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 4 deletions.
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
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
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
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

0 comments on commit 50df544

Please sign in to comment.