Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add actionlint in CI #6884

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/_docker_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ jobs:

- name: Add major.minor tag
id: add-major-minor-tag
if: ${{ steps.parse-semver-tag.outputs.prerelease == '' }}
if: ${{ steps.parse-semver-tag.outputs.prerelease == '' && inputs.tag != '' }}
run: |
echo "tag=type=raw,value=${{ steps.parse-semver-tag.outputs.major }}.${{ steps.parse-semver-tag.outputs.minor }}" >> $GITHUB_OUTPUT

- name: Merge tags
id: merge-tags
run: |
echo "tags<<EOF" >> $GITHUB_OUTPUT
if [ -n "${{ steps.major-minor-tag.outputs.tag }}" ]; then
if [ -n "${{ steps.add-major-minor-tag.outputs.tag }}" ]; then
echo "${{ steps.add-major-minor-tag.outputs.tag }}" >> $GITHUB_OUTPUT
fi
echo "${{ steps.add-standard-tag.outputs.tag }}" >> $GITHUB_OUTPUT
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/_e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ jobs:
id: split
env:
KONG: ${{ inputs.kong-image }}
CONTROLLER: ${{ inputs.controller-image }}
run: |
if [ "${{ inputs.kong-image }}" != "" ]; then
export kong_image=$(echo ${{ inputs.kong-image }} | awk '{split($0,a,":"); print a[1]}')
Expand Down Expand Up @@ -246,7 +245,6 @@ jobs:
id: split
env:
KONG: ${{ inputs.kong-image }}
CONTROLLER: ${{ inputs.controller-image }}
run: |
if [ "${{ inputs.kong-image }}" != "" ]; then
export kong_image=$(echo ${{ inputs.kong-image }} | awk '{split($0,a,":"); print a[1]}')
Expand Down Expand Up @@ -368,7 +366,6 @@ jobs:
id: split
env:
KONG: ${{ inputs.kong-image }}
CONTROLLER: ${{ inputs.controller-image }}
run: |
if [ "${{ inputs.kong-image }}" != "" ]; then
export kong_image=$(echo ${{ inputs.kong-image }} | awk '{split($0,a,":"); print a[1]}')
Expand Down
28 changes: 17 additions & 11 deletions .github/workflows/_integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ jobs:
- id: set-versions
name: Set versions
run: |
echo "kind=$(yq -ojson -r '.integration.kind' < .github/test_dependencies.yaml )" >> $GITHUB_OUTPUT
echo "kong-ee=$(yq -ojson -r '.integration.kong-ee' < .github/test_dependencies.yaml )" >> $GITHUB_OUTPUT
echo "kong-oss=$(yq -ojson -r '.integration.kong-oss' < .github/test_dependencies.yaml )" >> $GITHUB_OUTPUT
echo "helm-kong=$(yq -ojson -r '.integration.helm.kong' < .github/test_dependencies.yaml )" >> $GITHUB_OUTPUT
(
echo "kind=$(yq -ojson -r '.integration.kind' < .github/test_dependencies.yaml )"
echo "kong-ee=$(yq -ojson -r '.integration.kong-ee' < .github/test_dependencies.yaml )"
echo "kong-oss=$(yq -ojson -r '.integration.kong-oss' < .github/test_dependencies.yaml )"
echo "helm-kong=$(yq -ojson -r '.integration.helm.kong' < .github/test_dependencies.yaml )"
) >> $GITHUB_OUTPUT

integration-tests:
timeout-minutes: ${{ fromJSON(vars.GHA_EXTENDED_TIMEOUT_MINUTES || 60) }}
Expand Down Expand Up @@ -161,14 +163,18 @@ jobs:
fi

if [ "${{ matrix.enterprise }}" == "true" ]; then
echo "TEST_KONG_IMAGE=${{ inputs.kong-enterprise-container-repo }}" >> $GITHUB_ENV
echo "TEST_KONG_TAG=${kong_ee_tag}" >> $GITHUB_ENV
echo "TEST_KONG_EFFECTIVE_VERSION=${{ inputs.kong-enterprise-effective-version }}" >> $GITHUB_ENV
echo "TEST_KONG_ENTERPRISE=true" >> $GITHUB_ENV
(
echo "TEST_KONG_IMAGE=${{ inputs.kong-enterprise-container-repo }}"
echo "TEST_KONG_TAG=${kong_ee_tag}"
echo "TEST_KONG_EFFECTIVE_VERSION=${{ inputs.kong-enterprise-effective-version }}"
echo "TEST_KONG_ENTERPRISE=true"
) >> $GITHUB_ENV
else
echo "TEST_KONG_IMAGE=${{ inputs.kong-container-repo }}" >> $GITHUB_ENV
echo "TEST_KONG_TAG=${kong_oss_tag}" >> $GITHUB_ENV
echo "TEST_KONG_EFFECTIVE_VERSION=${{ inputs.kong-oss-effective-version }}" >> $GITHUB_ENV
(
echo "TEST_KONG_IMAGE=${{ inputs.kong-container-repo }}"
echo "TEST_KONG_TAG=${kong_oss_tag}"
echo "TEST_KONG_EFFECTIVE_VERSION=${{ inputs.kong-oss-effective-version }}"
) >> $GITHUB_ENV
fi

- name: checkout repository
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/_linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,20 @@ jobs:

- name: Verify generators consistency
run: make verify.generators

actionlint:
timeout-minutes: ${{ fromJSON(vars.GHA_DEFAULT_TIMEOUT || 10) }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: jdx/mise-action@v2
with:
install: false

- name: Run actionlint
env:
MISE_VERBOSE: 1
MISE_DEBUG: 1
run: make lint.actions
3 changes: 0 additions & 3 deletions .github/workflows/_performance_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ jobs:
id: split
env:
KONG: ${{ inputs.kong-image }}
CONTROLLER: ${{ inputs.controller-image }}
run: |
if [ "${{ inputs.kong-image }}" != "" ]; then
export kong_image=$(echo ${{ inputs.kong-image }} | awk '{split($0,a,":"); print a[1]}')
Expand Down Expand Up @@ -157,7 +156,6 @@ jobs:
id: split
env:
KONG: ${{ inputs.kong-image }}
CONTROLLER: ${{ inputs.controller-image }}
run: |
if [ "${{ inputs.kong-image }}" != "" ]; then
export kong_image=$(echo ${{ inputs.kong-image }} | awk '{split($0,a,":"); print a[1]}')
Expand All @@ -172,7 +170,6 @@ jobs:
echo "kic-tag=$kic_tag" >> $GITHUB_OUTPUT
fi


- name: run performance tests
run: make test.performance
env:
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ jobs:
- name: Add standard tags
id: tags-standard
run: |
echo 'TAGS_STANDARD<<EOF' >> $GITHUB_OUTPUT
echo 'type=raw,value=nightly' >> $GITHUB_OUTPUT
echo "type=raw,value={{date 'YYYY-MM-DD'}}" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
(
echo 'TAGS_STANDARD<<EOF'
echo 'type=raw,value=nightly'
echo "type=raw,value={{date 'YYYY-MM-DD'}}"
echo 'EOF'
) >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/regenerate_on_deps_bump.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ jobs:
timeout-minutes: ${{ fromJSON(vars.GHA_DEFAULT_TIMEOUT || 10) }}
if: contains(github.event.*.labels.*.name, 'renovate/auto-regenerate')
runs-on: ubuntu-latest
env:
REF: ${{ github.event.pull_request.head.ref }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
ref: ${{ env.REF }}
token: ${{ secrets.K8S_TEAM_BOT_GH_PAT }}

- name: setup golang
Expand All @@ -39,4 +41,4 @@ jobs:
git status
git diff-index --quiet HEAD || \
git commit -m "chore: regenerate" && \
git push origin ${{ github.event.pull_request.head.ref }}
git push origin ${{ env.REF }}
18 changes: 11 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,20 @@ jobs:
version_extractor_regex: 'v(.*)$'
- name: Add standard tags
run: |
echo 'TAGS_STANDARD<<EOF' >> $GITHUB_ENV
echo 'type=raw,value=${{ steps.semver_parser.outputs.fullversion }}' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
(
echo 'TAGS_STANDARD<<EOF'
echo 'type=raw,value=${{ steps.semver_parser.outputs.fullversion }}'
echo 'EOF'
) >> $GITHUB_ENV
- name: Add major.minor tag
if: ${{ steps.semver_parser.outputs.prerelease == '' }}
run: |
echo 'TAGS_SUPPLEMENTAL<<EOF' >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo 'type=raw,value=${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
(
echo 'TAGS_SUPPLEMENTAL<<EOF'
echo ""
echo 'type=raw,value=${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}'
echo 'EOF'
) >> $GITHUB_ENV
# Setup Golang to use go pkg cache which is utilized in Dockerfile's cache mount.
- name: Setup golang
uses: actions/setup-go@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Detect changes
id: detect-changes
run: |
if [[ `cd docs.konghq.com && git status --porcelain` ]]; then
if [[ $(cd docs.konghq.com && git status --porcelain) ]]; then
echo "Changes detected in docs repo"
echo "HAS_CHANGES=true" >> $GITHUB_OUTPUT
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ jobs:

- name: Extract container image from issue body
id: extract_image
env:
BODY: ${{ github.event.issue.body }}
# Fail the job if we cannot get "### Container image" keyword from issue body.
run: |
kong_container_image=$(echo ${{ github.event.issue.body }} | grep -A 2 '### Container image' | tail -n 1) && \
kong_container_image=$(echo ${{ env.BODY }} | grep -A 2 '### Container image' | tail -n 1) && \
echo "TEST_KONG_CONTAINER_IMAGE=${kong_container_image}" >> $GITHUB_ENV

# Split the container into repo and tag by ":" and then extract the first 3 segments of tags as its version.
Expand Down
4 changes: 4 additions & 0 deletions .tools_versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ gotestsum: "1.12.0"
staticcheck: "2024.1.1"
# renovate: datasource=github-releases depName=go-delve/delve
delve: "1.24.0"
# 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 @@ -145,6 +145,20 @@ go-junit-report: ## Download go-junit-report locally if necessary.
@$(MAKE) mise-plugin-install DEP=go-junit-report
@$(MISE) install go-junit-report@$(GOJUNIT_REPORT_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)

# ------------------------------------------------------------------------------
# Build
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -197,6 +211,13 @@ fmt:
.PHONY: lint
lint: verify.tidy golangci-lint staticcheck

.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: golangci-lint
golangci-lint: golangci-lint.download
$(GOLANGCI_LINT) run --verbose --config $(PROJECT_DIR)/.golangci.yaml $(GOLANGCI_LINT_FLAGS)
Expand Down
Loading