From bfa3c18e8a34ab81fa2c7b443183a5a464a212c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Fri, 20 Dec 2024 12:10:30 +0100 Subject: [PATCH] ci: add actionlint in CI (#199) --- .github/workflows/release.yaml | 2 +- .github/workflows/tests.yaml | 13 +++++++++++++ .tools_versions.yaml | 4 ++++ Makefile | 18 ++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 430800f..437d6e8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,5 +1,5 @@ name: Create release -run-name: "Release ${{ format('{0} (type: {1}) (branch: {2})', inputs.tag, inputs.release_type, github.ref_name) }} " +run-name: "Release ${{ format('{0} (branch: {1})', inputs.tag, github.ref_name) }} " on: workflow_dispatch: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d45bea3..8578ca7 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -21,6 +21,18 @@ on: workflow_call: {} jobs: + actionlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: jdx/mise-action@v2 + with: + install: false + + - name: Run lint.actions + run: make lint.actions + test-unit: runs-on: ubuntu-latest steps: @@ -125,6 +137,7 @@ jobs: - generate - apply - lint + - actionlint - CRDs-validation if: always() steps: diff --git a/.tools_versions.yaml b/.tools_versions.yaml index f782aa6..eaca6e2 100644 --- a/.tools_versions.yaml +++ b/.tools_versions.yaml @@ -12,3 +12,7 @@ yq: "4.44.6" gotestsum: "1.12.0" # renovate: datasource=github-releases depName=golangci/golangci-lint golangci-lint: "1.62.2" +# 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 8771dbc..0c9fc1d 100644 --- a/Makefile +++ b/Makefile @@ -110,6 +110,20 @@ golangci-lint: mise yq ## Download golangci-lint locally if necessary. @$(MISE) plugin install --yes -q golangci-lint @$(MISE) install -q golangci-lint@$(GOLANGCI_LINT_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) + # ------------------------------------------------------------------------------ # Verify steps # ------------------------------------------------------------------------------ @@ -193,6 +207,10 @@ 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 + $(ACTIONLINT) -shellcheck $(SHELLCHECK) ./.github/workflows/* + .PHONY: test.samples test.samples: kustomize find ./config/samples -not -name "kustomization.*" -type f | sort | xargs -I{} bash -c "kubectl apply -f {}; kubectl delete -f {}"