From a31862f84affd95e0f35755b70d42af58ea346d2 Mon Sep 17 00:00:00 2001 From: Christoph Barbian Date: Mon, 17 Jul 2023 00:21:31 +0200 Subject: [PATCH] update workflows --- .github/workflows/build.yaml | 78 ++++++------------------------------ 1 file changed, 13 insertions(+), 65 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0f563bb..1ab3df5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -30,90 +30,38 @@ jobs: - name: Setup go uses: actions/setup-go@v4 with: - go-version-file: 'go.mod' + go-version-file: go.mod - name: Check that license header boilerplate is correct - run: | - this_year=$(date +%Y) - last_year=$((this_year-1)) - repository=$(echo ${{ github.repository }} | cut -d/ -f2) - boilerplate=hack/boilerplate.go.txt - - tempdir=$(mktemp -d) - trap 'rm -rf $tempdir' EXIT - - cat > $tempdir/boilerplate-this-year < $tempdir/boilerplate-last-year </dev/null; then - exit 0 - fi - if diff -q $boilerplate $tempdir/boilerplate-last-year >/dev/null; then - >&1 echo "Warning: license boilerplate outdated ($last_year); next year, this will result in an error." - exit 0 - fi - >&1 echo "Error: incorrect license boilerplate." - exit 1 - END + uses: ./.github/actions/check-go-license-boilerplate + with: + boilerplate-path: hack/boilerplate.go.txt - name: Check that license headers are correct - run: | - boilerplate=hack/boilerplate.go.txt - - tempdir=$(mktemp -d) - trap 'rm -rf $tempdir' EXIT - - boilerplate_linecount=$(wc -l $boilerplate | awk '{print $1}') - errors=0 - - for f in $(find . -name "*.go"); do - if head -n 1 $f | grep -q "!ignore_autogenerated"; then - continue - fi - head -n $boilerplate_linecount $f > $tempdir/out - if ! diff -q $tempdir/out $boilerplate >/dev/null; then - >&1 echo "Error: incorrect license header found in $f." - errors=$((errors+1)) - fi - rm -f $tempdir/out - done - - if [ $errors -gt 0 ]; then - exit 1 - fi + uses: ./.github/actions/check-go-license-headers + with: + boilerplate-path: hack/boilerplate.go.txt - name: Check that generated artifacts are up-to-date run: | make generate echo "Running 'git status' ..." - git status --porcelain | tee status.out - if [[ -s status.out ]]; then + if [ -z "$(git status --porcelain)" ]; then + echo "Generated artifacts are up-to-date." + else >&1 echo "Generated artifacts are not up-to-date; probably 'make generate' was not run before committing." exit 1 - else - echo "Generated artifacts are up-to-date." fi - name: Check that manifests are up-to-date run: | make manifests echo "Running 'git status' ..." - git status --porcelain | tee status.out - if [[ -s status.out ]]; then + if [ -z "$(git status --porcelain)" ]; then + echo "Manifests are up-to-date." + else >&1 echo "Manifests are not up-to-date; probably 'make manifests' was not run before committing." exit 1 - else - echo "Manifests are up-to-date." fi - name: Run tests