From ac8dc2ee27de56fc7862a04ba344b4f95670e9a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Fri, 20 Dec 2024 12:28:46 +0100 Subject: [PATCH] ci: add actionlint in CI --- .github/workflows/__build-workflow.yaml | 38 ++++++++------- .github/workflows/__release-workflow.yaml | 1 - .github/workflows/release-bot.yaml | 2 +- .github/workflows/tests.yaml | 57 ++++++++++++----------- .tools_versions.yaml | 4 ++ Makefile | 21 +++++++++ 6 files changed, 77 insertions(+), 46 deletions(-) diff --git a/.github/workflows/__build-workflow.yaml b/.github/workflows/__build-workflow.yaml index 979f73852..62399e59a 100644 --- a/.github/workflows/__build-workflow.yaml +++ b/.github/workflows/__build-workflow.yaml @@ -70,8 +70,6 @@ on: value: ${{ jobs.build.outputs.tags }} version: value: ${{ jobs.build.outputs.version }} - artifact: - value: ${{ jobs.build.outputs.artifact }} jobs: semver: @@ -159,17 +157,21 @@ jobs: - name: Add standard tags if: ${{ inputs.tag != '' }} run: | - echo 'TAGS_STANDARD<> $GITHUB_ENV - echo 'type=raw,value=${{ needs.semver.outputs.fullversion }}' >> $GITHUB_ENV - echo 'EOF' >> $GITHUB_ENV + ( + echo 'TAGS_STANDARD<> $GITHUB_ENV - name: Add major.minor tag if: ${{ inputs.tag != '' && needs.semver.outputs.prerelease == '' }} run: | - echo 'TAGS_SUPPLEMENTAL<> $GITHUB_ENV - echo "" >> $GITHUB_ENV - echo 'type=raw,value=${{ needs.semver.outputs.major }}.${{ needs.semver.outputs.minor }}' >> $GITHUB_ENV - echo 'EOF' >> $GITHUB_ENV + ( + echo 'TAGS_SUPPLEMENTAL<> $GITHUB_ENV - name: Docker meta id: meta @@ -279,17 +281,21 @@ jobs: - name: Add standard tags if: ${{ inputs.tag != '' }} run: | - echo 'TAGS_STANDARD<> $GITHUB_ENV - echo 'type=raw,value=${{ needs.semver.outputs.fullversion }}' >> $GITHUB_ENV - echo 'EOF' >> $GITHUB_ENV + ( + echo 'TAGS_STANDARD<> $GITHUB_ENV - name: Add major.minor tag if: ${{ inputs.tag != '' && needs.semver.outputs.prerelease == '' }} run: | - echo 'TAGS_SUPPLEMENTAL<> $GITHUB_ENV - echo "" >> $GITHUB_ENV - echo 'type=raw,value=${{ needs.semver.outputs.major }}.${{ needs.semver.outputs.minor }}' >> $GITHUB_ENV - echo 'EOF' >> $GITHUB_ENV + ( + echo 'TAGS_SUPPLEMENTAL<> $GITHUB_ENV - name: Docker metadata id: meta diff --git a/.github/workflows/__release-workflow.yaml b/.github/workflows/__release-workflow.yaml index 44a34a77f..5e1887a92 100644 --- a/.github/workflows/__release-workflow.yaml +++ b/.github/workflows/__release-workflow.yaml @@ -43,7 +43,6 @@ on: release-type: description: Whether to make a created release a pre-release required: true - default: 'prerelease' # Reusable workflows do not support choice type, so we use string instead. # Allowed values: prerelease, release. type: string diff --git a/.github/workflows/release-bot.yaml b/.github/workflows/release-bot.yaml index 0c362aff9..4b97c25b7 100644 --- a/.github/workflows/release-bot.yaml +++ b/.github/workflows/release-bot.yaml @@ -73,7 +73,7 @@ jobs: uses: mukunku/tag-exists-action@v1.6.0 id: tag_exists with: - tag: ${{ steps.commit_parser.outputs.release_version }} + tag: ${{ env.VERSION }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 6b82c4e3c..41edb122e 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -163,16 +163,16 @@ jobs: GOTESTSUM_JUNITFILE: "unit-tests.xml" - name: collect test coverage - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: coverage + name: coverage-unit-tests path: coverage.unit.out - name: collect test report if: ${{ always() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: tests-report + name: tests-report-unit-tests path: unit-tests.xml envtest-tests: @@ -196,16 +196,16 @@ jobs: GOTESTSUM_JUNITFILE: "envtest-tests.xml" - name: collect test coverage - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: coverage-envtest path: coverage.envtest.out - name: collect test report if: ${{ always() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: tests-report + name: tests-report-envtest-tests path: envtest-tests.xml conformance-tests: @@ -242,15 +242,15 @@ jobs: if: ${{ always() }} uses: actions/upload-artifact@v4 with: - name: diagnostics-conformance + name: diagnostics-conformance-${{ matrix.router-flavor }} path: /tmp/ktf-diag* if-no-files-found: ignore - name: collect test report if: ${{ always() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: tests-report + name: tests-report-conformance-${{ matrix.router-flavor }} path: conformance-tests-${{ matrix.router-flavor }}.xml - name: collect conformance report @@ -302,16 +302,16 @@ jobs: if-no-files-found: ignore - name: collect test coverage - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: coverage + name: coverage-integration-webhook-enabled-${{ matrix.webhook-enabled }} path: coverage.integration.out - name: collect test report if: ${{ always() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: tests-report + name: tests-report-integration-webhook-enabled-${{ matrix.webhook-enabled }} path: integration-tests-webhook-enabled-${{ matrix.webhook-enabled }}.xml integration-tests-bluegreen: @@ -354,16 +354,16 @@ jobs: if-no-files-found: ignore - name: collect test coverage - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: coverage + name: coverage-integration-bluegreen-webhook-enabled-${{ matrix.webhook-enabled }} path: coverage.integration-bluegreen.out - name: collect test report if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: tests-report + name: tests-report-integration-bluegreen-webhook-enabled-${{ matrix.webhook-enabled }} path: integration-tests-bluegreen-webhook-enabled-${{ matrix.webhook-enabled }}.xml # Test reconciling Gateway with provisioning DataPlane failures. @@ -399,22 +399,22 @@ jobs: if: always() uses: actions/upload-artifact@v4 with: - name: diagnostics-integration-provision-fail-webhook-enabled-${{ matrix.webhook-enabled }} + name: diagnostics-integration-provision-fail path: /tmp/ktf-diag* if-no-files-found: ignore - name: collect test coverage - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: coverage + name: coverage-integration-tests-provision-fail path: coverage.integration-provision-dataplane-fail.out - name: collect test report if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: tests-report - path: integration-tests-provision-dataplane-fai.xml + name: tests-report-integration-tests-provision-fail + path: integration-tests-provision-dataplane-fail.xml e2e-tests: runs-on: ubuntu-latest @@ -457,9 +457,9 @@ jobs: - name: collect test report if: ${{ always() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: tests-report + name: tests-report-e2e path: e2e-tests.xml buildpulse-report: @@ -477,10 +477,11 @@ jobs: - name: download tests report id: download-coverage - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: tests-report + pattern: tests-report* path: report + merge-multiple: true - name: Upload test results to BuildPulse for flaky test detection if: ${{ !cancelled() }} diff --git a/.tools_versions.yaml b/.tools_versions.yaml index eb88c2f8d..672aa6be1 100644 --- a/.tools_versions.yaml +++ b/.tools_versions.yaml @@ -18,3 +18,7 @@ crd-ref-docs: "0.1.0" mockery: "2.50.0" # renovate: datasource=github-releases depName=kubernetes-sigs/controller-runtime setup-envtest: "0.19.3" +# renovate: datasource=github-releases depName=rhysd/actionlint +actionlint: "1.7.4" +# renovate: datasource=github-releases depName=koalaman/shellcheck +shellcheck: "0.10.0" diff --git a/Makefile b/Makefile index 3b88d94d2..a99748386 100644 --- a/Makefile +++ b/Makefile @@ -143,6 +143,20 @@ setup-envtest: mise ## Download setup-envtest locally if necessary. @$(MAKE) mise-plugin-install DEP=setup-envtest URL=https://github.com/pmalek/mise-setup-envtest.git @$(MISE) install setup-envtest@$(SETUP_ENVTEST_VERSION) +ACTIONLINT_VERSION = $(shell $(YQ) -r '.actionlint' < $(TOOLS_VERSIONS_FILE)) +ACTIONLINT = $(PROJECT_DIR)/bin/installs/actionlint/$(ACTIONLINT_VERSION)/bin/actionlint +.PHONY: download.actionlint +download.actionlint: mise yq ## Download actionlint locally if necessary. + @$(MISE) plugin install --yes -q actionlint + @$(MISE) install -q actionlint@$(ACTIONLINT_VERSION) + +SHELLCHECK_VERSION = $(shell $(YQ) -r '.shellcheck' < $(TOOLS_VERSIONS_FILE)) +SHELLCHECK = $(PROJECT_DIR)/bin/installs/shellcheck/$(SHELLCHECK_VERSION)/bin/shellcheck +.PHONY: download.shellcheck +download.shellcheck: mise yq ## Download shellcheck locally if necessary. + @$(MISE) plugin install --yes -q shellcheck + @$(MISE) install -q shellcheck@$(SHELLCHECK_VERSION) + .PHONY: use-setup-envtest use-setup-envtest: $(SETUP_ENVTEST) use @@ -188,6 +202,13 @@ GOLANGCI_LINT_CONFIG ?= $(PROJECT_DIR)/.golangci.yaml lint: golangci-lint $(GOLANGCI_LINT) run -v --config $(GOLANGCI_LINT_CONFIG) $(GOLANGCI_LINT_FLAGS) +.PHONY: lint.actions +lint.actions: download.actionlint download.shellcheck +# TODO: add more files to be checked + SHELLCHECK_OPTS='--exclude=SC2086,SC2155,SC2046' \ + $(ACTIONLINT) -shellcheck $(SHELLCHECK) \ + ./.github/workflows/* + .PHONY: verify verify: verify.manifests verify.generators