From 4767b952dd2d0773562048047ab36a6a7032ed96 Mon Sep 17 00:00:00 2001 From: Ivan Dyachkov Date: Sun, 6 Aug 2023 13:57:47 +0200 Subject: [PATCH] ci: move sanity checks to the main workflow --- .github/actions/pr-sanity-checks/action.yaml | 65 -------------------- .github/workflows/_pr_entrypoint.yaml | 50 ++++++++++++++- scripts/pr-sanity-checks.sh | 2 +- scripts/shelltest/run_tests.sh | 2 + 4 files changed, 51 insertions(+), 68 deletions(-) delete mode 100644 .github/actions/pr-sanity-checks/action.yaml diff --git a/.github/actions/pr-sanity-checks/action.yaml b/.github/actions/pr-sanity-checks/action.yaml deleted file mode 100644 index f19fe2c6d..000000000 --- a/.github/actions/pr-sanity-checks/action.yaml +++ /dev/null @@ -1,65 +0,0 @@ -name: 'Pull request sanity checks' - -defaults: - run: - shell: 'bash -Eeuo pipefail {0}' - -runs: - using: composite - steps: - - name: Run gitlint - shell: bash - env: - BEFORE_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} - AFTER_REF: ${{ github.sha }} - run: | - pip install gitlint - gitlint --commits $BEFORE_REF..$AFTER_REF --config .github/workflows/.gitlint - - name: Run shellcheck - shell: bash - run: | - DEBIAN_FRONTEND=noninteractive apt-get update -qy && apt-get install -qy shellcheck - ./scripts/shellcheck.sh - - name: Run shell tests - shell: bash - run: | - DEBIAN_FRONTEND=noninteractive apt-get update -qy && apt-get install -qy shelltestrunner - scripts/shelltest/run_tests.sh - - name: Check workflow files - shell: bash - env: - ACTIONLINT_VSN: 1.6.25 - run: | - wget https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VSN}/actionlint_${ACTIONLINT_VSN}_linux_amd64.tar.gz - tar zxf actionlint_${ACTIONLINT_VSN}_linux_amd64.tar.gz actionlint - # TODO: enable shellcheck when all the current issues are fixed - ./actionlint -color \ - -shellcheck= \ - -ignore 'label ".+" is unknown' \ - -ignore 'value "emqx-enterprise" in "exclude"' - - name: Check line-break at EOF - shell: bash - run: | - ./scripts/check-nl-at-eof.sh - - name: Check apps version - shell: bash - run: | - ./scripts/apps-version-check.sh - - name: Setup mix - env: - MIX_ENV: emqx-enterprise - PROFILE: emqx-enterprise - shell: bash - run: | - mix local.hex --force --if-missing && mix local.rebar --force --if-missing - - name: Check formatting - env: - MIX_ENV: emqx-enterprise - PROFILE: emqx-enterprise - shell: bash - run: | - ./scripts/check-format.sh - - name: Run elvis check - shell: bash - run: | - ./scripts/elvis-check.sh $GITHUB_BASE_REF diff --git a/.github/workflows/_pr_entrypoint.yaml b/.github/workflows/_pr_entrypoint.yaml index 4fc8ee774..ec2bbf2e1 100644 --- a/.github/workflows/_pr_entrypoint.yaml +++ b/.github/workflows/_pr_entrypoint.yaml @@ -38,8 +38,54 @@ jobs: - name: Work around https://github.com/actions/checkout/issues/766 run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" - - uses: ./.github/actions/pr-sanity-checks - - name: Build matrix + - name: Run gitlint + env: + BEFORE_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} + AFTER_REF: ${{ github.sha }} + run: | + pip install gitlint + gitlint --commits $BEFORE_REF..$AFTER_REF --config .github/workflows/.gitlint + - name: Run shellcheck + run: | + DEBIAN_FRONTEND=noninteractive apt-get update -qy && apt-get install -qy shellcheck + ./scripts/shellcheck.sh + - name: Run shell tests + run: | + DEBIAN_FRONTEND=noninteractive apt-get update -qy && apt-get install -qy shelltestrunner + scripts/shelltest/run_tests.sh + - name: Check workflow files + env: + ACTIONLINT_VSN: 1.6.25 + run: | + wget https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VSN}/actionlint_${ACTIONLINT_VSN}_linux_amd64.tar.gz + tar zxf actionlint_${ACTIONLINT_VSN}_linux_amd64.tar.gz actionlint + # TODO: enable shellcheck when all the current issues are fixed + ./actionlint -color \ + -shellcheck= \ + -ignore 'label ".+" is unknown' \ + -ignore 'value "emqx-enterprise" in "exclude"' + - name: Check line-break at EOF + run: | + ./scripts/check-nl-at-eof.sh + - name: Check apps version + run: | + ./scripts/apps-version-check.sh + - name: Setup mix + env: + MIX_ENV: emqx-enterprise + PROFILE: emqx-enterprise + run: | + mix local.hex --force --if-missing && mix local.rebar --force --if-missing + - name: Check formatting + env: + MIX_ENV: emqx-enterprise + PROFILE: emqx-enterprise + run: | + ./scripts/check-format.sh + - name: Run elvis check + run: | + ./scripts/elvis-check.sh $GITHUB_BASE_REF + - name: Generate CT Matrix id: matrix run: | APPS="$(./scripts/find-apps.sh --ci)" diff --git a/scripts/pr-sanity-checks.sh b/scripts/pr-sanity-checks.sh index 113ffd324..6b193b74e 100755 --- a/scripts/pr-sanity-checks.sh +++ b/scripts/pr-sanity-checks.sh @@ -18,7 +18,7 @@ EMQX_BUILDER_ELIXIR=${EMQX_BUILDER_ELIXIR:-1.14.5} EMQX_BUILDER_PLATFORM=${EMQX_BUILDER_PLATFORM:-ubuntu22.04} EMQX_BUILDER=${EMQX_BUILDER:-ghcr.io/emqx/emqx-builder/${EMQX_BUILDER_VERSION}:${EMQX_BUILDER_ELIXIR}-${EMQX_BUILDER_OTP}-${EMQX_BUILDER_PLATFORM}} -commands=$(yq ".runs.steps[].run" .github/actions/pr-sanity-checks/action.yaml | grep -v null) +commands=$(yq ".jobs.sanity-checks.steps[].run" .github/workflows/_pr_entrypoint.yaml | grep -v null) BEFORE_REF=${BEFORE_REF:-$(git rev-parse master)} AFTER_REF=${AFTER_REF:-$(git rev-parse HEAD)} diff --git a/scripts/shelltest/run_tests.sh b/scripts/shelltest/run_tests.sh index 28f48eaee..11caa6cac 100755 --- a/scripts/shelltest/run_tests.sh +++ b/scripts/shelltest/run_tests.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash +# shellcheck disable=SC2164 cd -P -- "$(dirname -- "$0")/.." exit_code=0 @@ -8,6 +9,7 @@ for test in shelltest/*.test; do echo "Running $test" /bin/sh "${test%.test}.setup" shelltest -c --diff --all --precise -- "$test" + # shellcheck disable=SC2181 if [ $? -ne 0 ]; then exit_code=1 fi