Skip to content

Commit

Permalink
ci: add actionlint in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed Dec 20, 2024
1 parent 7330aac commit ac8dc2e
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 46 deletions.
38 changes: 22 additions & 16 deletions .github/workflows/__build-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ on:
value: ${{ jobs.build.outputs.tags }}
version:
value: ${{ jobs.build.outputs.version }}
artifact:
value: ${{ jobs.build.outputs.artifact }}

jobs:
semver:
Expand Down Expand Up @@ -159,17 +157,21 @@ jobs:
- name: Add standard tags
if: ${{ inputs.tag != '' }}
run: |
echo 'TAGS_STANDARD<<EOF' >> $GITHUB_ENV
echo 'type=raw,value=${{ needs.semver.outputs.fullversion }}' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
(
echo 'TAGS_STANDARD<<EOF'
echo 'type=raw,value=${{ needs.semver.outputs.fullversion }}'
echo 'EOF'
) >> $GITHUB_ENV
- name: Add major.minor tag
if: ${{ inputs.tag != '' && needs.semver.outputs.prerelease == '' }}
run: |
echo 'TAGS_SUPPLEMENTAL<<EOF' >> $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<<EOF'
echo ""
echo 'type=raw,value=${{ needs.semver.outputs.major }}.${{ needs.semver.outputs.minor }}'
echo 'EOF'
) >> $GITHUB_ENV
- name: Docker meta
id: meta
Expand Down Expand Up @@ -279,17 +281,21 @@ jobs:
- name: Add standard tags
if: ${{ inputs.tag != '' }}
run: |
echo 'TAGS_STANDARD<<EOF' >> $GITHUB_ENV
echo 'type=raw,value=${{ needs.semver.outputs.fullversion }}' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
(
echo 'TAGS_STANDARD<<EOF'
echo 'type=raw,value=${{ needs.semver.outputs.fullversion }}'
echo 'EOF'
) >> $GITHUB_ENV
- name: Add major.minor tag
if: ${{ inputs.tag != '' && needs.semver.outputs.prerelease == '' }}
run: |
echo 'TAGS_SUPPLEMENTAL<<EOF' >> $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<<EOF'
echo ""
echo 'type=raw,value=${{ needs.semver.outputs.major }}.${{ needs.semver.outputs.minor }}'
echo 'EOF'
) >> $GITHUB_ENV
- name: Docker metadata
id: meta
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/__release-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-bot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
uses: mukunku/[email protected]
id: tag_exists
with:
tag: ${{ steps.commit_parser.outputs.release_version }}
tag: ${{ env.VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
57 changes: 29 additions & 28 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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() }}
Expand Down
4 changes: 4 additions & 0 deletions .tools_versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit ac8dc2e

Please sign in to comment.