Skip to content

Commit

Permalink
.github: Have CI check that make clobber works for everything we do…
Browse files Browse the repository at this point in the history
… in CI [ci-skip]

This is marked [ci-skip] because (as this PR reveals) `make clobber`
is currently broken.

Signed-off-by: Luke Shumaker <[email protected]>
  • Loading branch information
LukeShu committed May 19, 2022
1 parent 41939ab commit cbe9db6
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 18 deletions.
37 changes: 37 additions & 0 deletions .github/actions/after-job/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'Post-job actions'
description: >-
Perform generic post-job actions that should be performed for every
job.
inputs:
jobname:
default: ${{ github.job }}
runs:
using: "composite"
steps:
- uses: ./.github/actions/collect-logs
if: always()
with:
jobname: ${{ inputs.jobname }}

- name: "Check that the job didn't change any files"
uses: ./.github/actions/git-dirty-check

- run: make ci/teardown-k3d
shell: bash

# `make clean`
- run: make clean
shell: bash
- name: "Check that `make clean` didn't change any files"
uses: ./.github/actions/git-dirty-check
# There's no way to test that `make clean` did everything it was
# supposed to, since it's a 90% solution for `make clobber`

# `make clobber`
- run: make clobber
shell: bash
- name: "Check that `make clobber` didn't change any files"
uses: ./.github/actions/git-dirty-check
- name: "Check that `make clobber` did everything it's supposed to"
shell: bash
run: $GITHUB_ACTION_PATH/check-clobber.sh
33 changes: 33 additions & 0 deletions .github/actions/after-job/check-clobber.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
#shellcheck disable=SC2016

r=0
if [[ -n "$(git clean --dry-run -d -x)" ]]; then
echo
echo 'There are files that `make clobber` did not remove that it should have:'
git clean --dry-run -d -x | sed 's/^Would remove / /'
echo
r=1
fi
if docker image list --format='{{ .Repository }}:{{ .Tag }}' | grep -q '\.local/'; then
echo
echo 'There are Docker images that `make clobber` did not remove that it should have:'
docker image list | grep '\.local/'
echo
r=1
fi
if [[ -n "$(docker container list --all --quiet)" ]]; then
echo
echo 'There are Docker containers that `make clobber` did not remove:'
docker container list --all
echo
r=1
fi
if [[ -n "$(docker volume list --quiet)" ]]; then
echo
echo 'There are Docker volumes that `make clobber` did not remove:'
docker volume list
echo
r=1
fi
exit "$r"
26 changes: 8 additions & 18 deletions .github/workflows/execute-tests-and-promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- shell: bash
run: |
make lint
- uses: ./.github/actions/after-job

generate: ####################################################################
runs-on: ubuntu-latest
Expand Down Expand Up @@ -59,6 +60,7 @@ jobs:
make generate
- uses: ./.github/actions/git-dirty-check
name: "Check Git not dirty from 'make generate' (again!)"
- uses: ./.github/actions/after-job

check-envoy-version: #########################################################
runs-on: ubuntu-latest
Expand All @@ -85,6 +87,7 @@ jobs:
username: ${{ secrets.GH_DOCKER_BUILD_USERNAME }}
password: ${{ secrets.GH_DOCKER_BUILD_TOKEN }}
- run: make check-envoy-version
- uses: ./.github/actions/after-job

# Tests ######################################################################
check-gotest:
Expand Down Expand Up @@ -112,10 +115,7 @@ jobs:
export TEST_XML_DIR=/tmp/test-logs/xml/
mkdir -p ${TEST_XML_DIR}
make gotest
- uses: ./.github/actions/git-dirty-check
name: "Check git not dirty from testing"
- uses: ./.github/actions/collect-logs
if: always()
- uses: ./.github/actions/after-job
check-pytest:
runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -173,10 +173,7 @@ jobs:
export DEV_REGISTRY=${{ secrets.DEV_REGISTRY }}
mkdir -p ${TEST_XML_DIR}
make pytest-${{ matrix.test }}
- uses: ./.github/actions/git-dirty-check
name: "Check git not dirty from testing"
- uses: ./.github/actions/collect-logs
if: always()
- uses: ./.github/actions/after-job
with:
jobname: check-pytest-${{ matrix.test }}
check-pytest-unit:
Expand Down Expand Up @@ -219,10 +216,7 @@ jobs:
export DEV_REGISTRY=${{ secrets.DEV_REGISTRY }}
mkdir -p ${TEST_XML_DIR}
make pytest-${{ matrix.test }}
- uses: ./.github/actions/git-dirty-check
name: "Check git not dirty from testing"
- uses: ./.github/actions/collect-logs
if: always()
- uses: ./.github/actions/after-job
with:
jobname: check-pytest-${{ matrix.test }}
check-chart:
Expand Down Expand Up @@ -257,10 +251,7 @@ jobs:
export DEV_KUBECONFIG=~/.kube/config
make test-chart
- uses: ./.github/actions/git-dirty-check
name: "Check git not dirty from testing"
- uses: ./.github/actions/collect-logs
if: always()
- uses: ./.github/actions/after-job

build: #######################################################################
runs-on: ubuntu-latest
Expand Down Expand Up @@ -293,8 +284,7 @@ jobs:
shell: bash
run: |
make push-dev
- uses: ./.github/actions/git-dirty-check
name: "Check git not dirty (from make push + make push-dev)"
- uses: ./.github/actions/after-job

##############################################################################
pass:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/promote-ga.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- name: "make release/promote-oss/to-ga"
run: |
make release/promote-oss/to-ga
- uses: ./.github/actions/end-job
- name: Slack notification
if: always()
uses: edge/simple-slack-notify@master
Expand All @@ -44,6 +45,7 @@ jobs:
{ "title": "Branch", "value": "${env.GITHUB_REF}", "short": true },
{ "title": "Action URL", "value": "${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}"}
]
- uses: ./.github/actions/after-job
create-gh-release:
runs-on: ubuntu-latest
needs: [promote-to-ga]
Expand Down Expand Up @@ -78,3 +80,4 @@ jobs:
{ "title": "Branch", "value": "${env.GITHUB_REF}", "short": true },
{ "title": "Action URL", "value": "${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}"}
]
- uses: ./.github/actions/after-job
1 change: 1 addition & 0 deletions .github/workflows/promote-rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ jobs:
{ "title": "Branch", "value": "${env.GITHUB_REF}", "short": true },
{ "title": "Action URL", "value": "${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}"}
]
- uses: ./.github/actions/after-job
2 changes: 2 additions & 0 deletions .github/workflows/publish-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
{ "title": "Branch", "value": "${env.GITHUB_REF}", "short": true },
{ "title": "Action URL", "value": "${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}"}
]
- uses: ./.github/actions/after-job
chart-create-gh-release:
if: ${{ ! contains(github.ref, '-') }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -73,3 +74,4 @@ jobs:
{ "title": "Branch", "value": "${env.GITHUB_REF}", "short": true },
{ "title": "Action URL", "value": "${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}"}
]
- uses: ./.github/actions/after-job
1 change: 1 addition & 0 deletions .github/workflows/repatriate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ jobs:
[{ "title": "Repository", "value": "${{ github.repository }}", "short": true },
{ "title": "Branch", "value": "${{ github.ref }}", "short": true},
{ "title": "Pull Request", "value": "${{ steps.step-create-pr.outputs.pr_url }}"}]
- uses: ./.github/actions/after-job
4 changes: 4 additions & 0 deletions build-aux/ci.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ ci/setup-k3d: $(tools/k3d) $(tools/kubectl)
while ! $(tools/kubectl) get serviceaccount default >/dev/null; do sleep 1; done
$(tools/kubectl) version
.PHONY: ci/setup-k3d

ci/teardown-k3d: $(tools/k3d)
$(tools/k3d) cluster delete || true
.PHONY: ci/teardown-k3d

0 comments on commit cbe9db6

Please sign in to comment.