Skip to content

Commit

Permalink
ci-datapath: Fix issue where test were wrongly reported as passing
Browse files Browse the repository at this point in the history
Before this commit, the ci-datapath workflow would update the PR status
for each `setup-and-test` matrix job. That however lead to the PR being
marked as green as soon as the first matrix job succeeded, even though
later tests might fail.

Worse, if an earlier matrix job failed, and a later one succeeded, the
latter job masked the failure of the earlier job and marked the PR as
green as well.

This commit fixes the issue by only updating the commit status once all
jobs have run. This technique is taken from #23865 and has
been used for the BPF verifier workflow for a while.

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
  • Loading branch information
gandro committed Apr 11, 2023
1 parent bb7d150 commit 4813172
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 74 deletions.
96 changes: 59 additions & 37 deletions .github/workflows/conformance-datapath-v1.13.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,40 @@ jobs:
src:
- '!(test|Documentation)/**'
setup-report:
runs-on: ubuntu-latest
needs: check_changes
name: Set commit status
outputs:
sha: ${{ steps.vars.outputs.sha }}
steps:
- name: Set up job variables
id: vars
run: |
if [ ${{ github.event.issue.pull_request || github.event.pull_request }} ]; then
PR_API_JSON=$(curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
${{ github.event.issue.pull_request.url || github.event.pull_request.url }})
SHA=$(echo "$PR_API_JSON" | jq -r ".head.sha")
else
SHA=${{ github.sha }}
fi
echo "sha=${SHA}" >> $GITHUB_OUTPUT
- name: Set commit status to pending
uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.vars.outputs.sha }}
context: ${{ github.workflow }}
description: Datapath tests in progress...
state: pending
target_url: ${{ env.check_url }}

setup-and-test:
runs-on: ubuntu-latest-4cores-16gb
needs: check_changes
needs: setup-report
name: Setup & Test
if: |
(github.event_name == 'issue_comment' && (
Expand Down Expand Up @@ -190,18 +221,7 @@ jobs:
- name: Set up job variables
id: vars
run: |
if [ ${{ github.event.issue.pull_request || github.event.pull_request }} ]; then
PR_API_JSON=$(curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
${{ github.event.issue.pull_request.url || github.event.pull_request.url }})
SHA=$(echo "$PR_API_JSON" | jq -r ".head.sha")
else
SHA=${{ github.sha }}
fi
echo "sha=${SHA}" >> $GITHUB_OUTPUT
SHA="${{ needs.setup-report.outputs.sha }}"
CILIUM_INSTALL_DEFAULTS="--wait \
--chart-directory=./install/kubernetes/cilium \
--helm-set=image.repository=quay.io/${{ github.repository_owner }}/cilium-ci \
Expand Down Expand Up @@ -239,20 +259,10 @@ jobs:
CONFIG="${CILIUM_INSTALL_DEFAULTS} ${TUNNEL} ${LB_MODE} ${ENDPOINT_ROUTES} ${IPV6}"
echo "cilium_install_defaults=${CONFIG}" >> $GITHUB_OUTPUT
- name: Set commit status to pending
uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.vars.outputs.sha }}
context: ${{ github.workflow }}
description: Cilium Datapath Conformance test in progress...
state: pending
target_url: ${{ env.check_url }}

- name: Checkout pull request for Helm chart
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
with:
ref: ${{ steps.vars.outputs.sha }}
ref: ${{ needs.setup-report.outputs.sha }}
persist-credentials: false

- name: Install cilium-cli
Expand Down Expand Up @@ -284,7 +294,7 @@ jobs:
shell: bash
run: |
for image in cilium-ci operator-generic-ci hubble-relay-ci ; do
until docker manifest inspect quay.io/${{ github.repository_owner }}/$image:${{ steps.vars.outputs.sha }} &> /dev/null; do sleep 45s; done
until docker manifest inspect quay.io/${{ github.repository_owner }}/$image:${{ needs.setup-report.outputs.sha }} &> /dev/null; do sleep 45s; done
done
- name: Run kube-proxy tests
Expand Down Expand Up @@ -340,34 +350,46 @@ jobs:
path: cilium-sysdump-*.zip
retention-days: 5

- name: Set commit status to success
if: ${{ success() }}
uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
report-success:
runs-on: ubuntu-latest
needs: [setup-report, setup-and-test]
name: Set commit status to success
if: ${{ success() }}
steps:
- uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.vars.outputs.sha }}
sha: ${{ needs.setup-report.outputs.sha }}
context: ${{ github.workflow }}
description: Datapath tests successful
state: success
target_url: ${{ env.check_url }}

- name: Set commit status to failure
if: ${{ failure() }}
uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
report-failure:
runs-on: ubuntu-latest
needs: [setup-report, setup-and-test]
name: Set commit status to failure
if: ${{ failure() }}
steps:
- uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.vars.outputs.sha }}
sha: ${{ needs.setup-report.outputs.sha }}
context: ${{ github.workflow }}
description: Datapath tests failed
state: failure
target_url: ${{ env.check_url }}

- name: Set commit status to cancelled
if: ${{ cancelled() }}
uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
report-cancelled:
runs-on: ubuntu-latest
needs: [setup-report, setup-and-test]
name: Set commit status to cancelled
if: ${{ cancelled() }}
steps:
- uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.vars.outputs.sha }}
sha: ${{ needs.setup-report.outputs.sha }}
context: ${{ github.workflow }}
description: Datapath tests cancelled
state: error
Expand Down
96 changes: 59 additions & 37 deletions .github/workflows/conformance-datapath.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,40 @@ jobs:
src:
- '!(test|Documentation)/**'
setup-report:
runs-on: ubuntu-latest
needs: check_changes
name: Set commit status
outputs:
sha: ${{ steps.vars.outputs.sha }}
steps:
- name: Set up job variables
id: vars
run: |
if [ ${{ github.event.issue.pull_request || github.event.pull_request }} ]; then
PR_API_JSON=$(curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
${{ github.event.issue.pull_request.url || github.event.pull_request.url }})
SHA=$(echo "$PR_API_JSON" | jq -r ".head.sha")
else
SHA=${{ github.sha }}
fi
echo "sha=${SHA}" >> $GITHUB_OUTPUT
- name: Set commit status to pending
uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.vars.outputs.sha }}
context: ${{ github.workflow }}
description: Datapath tests in progress...
state: pending
target_url: ${{ env.check_url }}

setup-and-test:
runs-on: ubuntu-latest-4cores-16gb
needs: check_changes
needs: setup-report
name: Setup & Test
if: |
(github.event_name == 'issue_comment' && (
Expand Down Expand Up @@ -271,18 +302,7 @@ jobs:
- name: Set up job variables
id: vars
run: |
if [ ${{ github.event.issue.pull_request || github.event.pull_request }} ]; then
PR_API_JSON=$(curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
${{ github.event.issue.pull_request.url || github.event.pull_request.url }})
SHA=$(echo "$PR_API_JSON" | jq -r ".head.sha")
else
SHA=${{ github.sha }}
fi
echo "sha=${SHA}" >> $GITHUB_OUTPUT
SHA="${{ needs.setup-report.outputs.sha }}"
CILIUM_INSTALL_DEFAULTS="--wait \
--chart-directory=./install/kubernetes/cilium \
--helm-set=image.repository=quay.io/${{ github.repository_owner }}/cilium-ci \
Expand Down Expand Up @@ -342,20 +362,10 @@ jobs:
CONFIG="${CILIUM_INSTALL_DEFAULTS} ${TUNNEL} ${LB_MODE} ${ENDPOINT_ROUTES} ${IPV6} ${EGRESS_GATEWAY} ${ENCRYPT} ${HOST_FW} ${LB_ACCELERATION}"
echo "cilium_install_defaults=${CONFIG}" >> $GITHUB_OUTPUT
- name: Set commit status to pending
uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.vars.outputs.sha }}
context: ${{ github.workflow }}
description: Cilium Datapath Conformance test in progress...
state: pending
target_url: ${{ env.check_url }}

- name: Checkout pull request for Helm chart
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
with:
ref: ${{ steps.vars.outputs.sha }}
ref: ${{ needs.setup-report.outputs.sha }}
persist-credentials: false

- name: Install cilium-cli
Expand Down Expand Up @@ -387,7 +397,7 @@ jobs:
shell: bash
run: |
for image in cilium-ci operator-generic-ci hubble-relay-ci ; do
until docker manifest inspect quay.io/${{ github.repository_owner }}/$image:${{ steps.vars.outputs.sha }} &> /dev/null; do sleep 45s; done
until docker manifest inspect quay.io/${{ github.repository_owner }}/$image:${{ needs.setup-report.outputs.sha }} &> /dev/null; do sleep 45s; done
done
- name: Run tests
Expand Down Expand Up @@ -428,34 +438,46 @@ jobs:
path: cilium-sysdump-*.zip
retention-days: 5

- name: Set commit status to success
if: ${{ success() }}
uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
report-success:
runs-on: ubuntu-latest
needs: [setup-report, setup-and-test]
name: Set commit status to success
if: ${{ success() }}
steps:
- uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.vars.outputs.sha }}
sha: ${{ needs.setup-report.outputs.sha }}
context: ${{ github.workflow }}
description: Datapath tests successful
state: success
target_url: ${{ env.check_url }}

- name: Set commit status to failure
if: ${{ failure() }}
uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
report-failure:
runs-on: ubuntu-latest
needs: [setup-report, setup-and-test]
name: Set commit status to failure
if: ${{ failure() }}
steps:
- uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.vars.outputs.sha }}
sha: ${{ needs.setup-report.outputs.sha }}
context: ${{ github.workflow }}
description: Datapath tests failed
state: failure
target_url: ${{ env.check_url }}

- name: Set commit status to cancelled
if: ${{ cancelled() }}
uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
report-cancelled:
runs-on: ubuntu-latest
needs: [setup-report, setup-and-test]
name: Set commit status to cancelled
if: ${{ cancelled() }}
steps:
- uses: Sibz/github-status-action@650dd1a882a76dbbbc4576fb5974b8d22f29847f # v1.1.6
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.vars.outputs.sha }}
sha: ${{ needs.setup-report.outputs.sha }}
context: ${{ github.workflow }}
description: Datapath tests cancelled
state: error
Expand Down

0 comments on commit 4813172

Please sign in to comment.