From 8a6bb6f5f34b3656feee3fca0752523d93c9132d Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Tue, 15 Aug 2023 13:47:23 -0300 Subject: [PATCH 1/4] ci: restore emqx app standalone tests Those were accidentally removed during a refactoring. They are needed because we provide the `emqx` application as a standalone dependency for plugins. --- .github/workflows/_pr_entrypoint.yaml | 9 +++ .github/workflows/_push-entrypoint.yaml | 9 +++ .github/workflows/run_emqx_app_tests.yaml | 67 +++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 .github/workflows/run_emqx_app_tests.yaml diff --git a/.github/workflows/_pr_entrypoint.yaml b/.github/workflows/_pr_entrypoint.yaml index ec2bbf2e1..81a4b7f71 100644 --- a/.github/workflows/_pr_entrypoint.yaml +++ b/.github/workflows/_pr_entrypoint.yaml @@ -146,6 +146,15 @@ jobs: path: ${{ matrix.profile }}.zip retention-days: 1 + run_emqx_app_tests: + needs: + - sanity-checks + - compile + uses: ./.github/workflows/run_emqx_app_tests.yaml + with: + runner: ${{ needs.sanity-checks.outputs.runner }} + builder: ${{ needs.sanity-checks.outputs.builder }} + run_test_cases: needs: - sanity-checks diff --git a/.github/workflows/_push-entrypoint.yaml b/.github/workflows/_push-entrypoint.yaml index 9ef517ab9..7ba8cbce7 100644 --- a/.github/workflows/_push-entrypoint.yaml +++ b/.github/workflows/_push-entrypoint.yaml @@ -158,6 +158,15 @@ jobs: path: ${{ matrix.profile }}.zip retention-days: 1 + run_emqx_app_tests: + needs: + - sanity-checks + - compile + uses: ./.github/workflows/run_emqx_app_tests.yaml + with: + runner: ${{ needs.sanity-checks.outputs.runner }} + builder: ${{ needs.sanity-checks.outputs.builder }} + run_test_cases: if: needs.prepare.outputs.release != 'true' needs: diff --git a/.github/workflows/run_emqx_app_tests.yaml b/.github/workflows/run_emqx_app_tests.yaml new file mode 100644 index 000000000..13a8b42d6 --- /dev/null +++ b/.github/workflows/run_emqx_app_tests.yaml @@ -0,0 +1,67 @@ +name: Check emqx app standalone + +# These tests are needed because we provide the `emqx` application as a standalone +# dependency for plugins. + +concurrency: + group: test-standalone-${{ github.event_name }}-${{ github.ref }} + cancel-in-progress: true + +on: + workflow_call: + inputs: + runner: + required: true + type: string + builder: + required: true + type: string + +env: + IS_CI: "yes" + +jobs: + run_emqx_app_tests: + runs-on: ${{ inputs.runner }} + container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir}}-${{ matrix.otp }}-ubuntu22.04" + + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: run + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + echo "git diff base: $GITHUB_BASE_REF" + if [[ "$GITHUB_BASE_REF" =~ [0-9a-f]{8,40} ]]; then + # base is a commit sha1 + compare_base="$GITHUB_BASE_REF" + else + repo="${GITHUB_REPOSITORY}" + git remote -v + remote="$(git remote -v | grep -E "github\.com(:|/)$repo((\.git)|(\s))" | grep fetch | awk '{print $1}')" + git fetch "$remote" "$GITHUB_BASE_REF" + compare_base="$remote/$GITHUB_BASE_REF" + fi + changed_files="$(git diff --name-only ${compare_base} HEAD apps/emqx)" + if [ "$changed_files" = '' ]; then + echo "nothing changed in apps/emqx, ignored." + exit 0 + fi + make ensure-rebar3 + cp rebar3 apps/emqx/ + cd apps/emqx + ./rebar3 xref + ./rebar3 dialyzer + ./rebar3 eunit -v + ./rebar3 ct --name 'test@127.0.0.1' -v --readable=true + ./rebar3 proper -d test/props + - uses: actions/upload-artifact@v3 + if: failure() + with: + name: logs-${{ matrix.runs-on }} + path: apps/emqx/_build/test/logs From 124c5d94e566ca32ad10ec224d209d4c5fb96075 Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Tue, 15 Aug 2023 14:25:38 -0300 Subject: [PATCH 2/4] ci: fix variable usage Co-authored-by: Ivan Dyachkov --- .github/workflows/_push-entrypoint.yaml | 2 +- .github/workflows/run_emqx_app_tests.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/_push-entrypoint.yaml b/.github/workflows/_push-entrypoint.yaml index 7ba8cbce7..a59511259 100644 --- a/.github/workflows/_push-entrypoint.yaml +++ b/.github/workflows/_push-entrypoint.yaml @@ -160,7 +160,7 @@ jobs: run_emqx_app_tests: needs: - - sanity-checks + - prepare - compile uses: ./.github/workflows/run_emqx_app_tests.yaml with: diff --git a/.github/workflows/run_emqx_app_tests.yaml b/.github/workflows/run_emqx_app_tests.yaml index 13a8b42d6..b5b821741 100644 --- a/.github/workflows/run_emqx_app_tests.yaml +++ b/.github/workflows/run_emqx_app_tests.yaml @@ -23,7 +23,7 @@ env: jobs: run_emqx_app_tests: runs-on: ${{ inputs.runner }} - container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir}}-${{ matrix.otp }}-ubuntu22.04" + container: ${{ inputs.builder }} defaults: run: @@ -63,5 +63,5 @@ jobs: - uses: actions/upload-artifact@v3 if: failure() with: - name: logs-${{ matrix.runs-on }} + name: logs-${{ inputs.runner }} path: apps/emqx/_build/test/logs From 4151fe5045d55fc8519d1d338d08a5e80abe9afd Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Tue, 15 Aug 2023 14:33:39 -0300 Subject: [PATCH 3/4] ci(refactor): compute before/after references in parent workflow --- .github/workflows/_pr_entrypoint.yaml | 2 ++ .github/workflows/_push-entrypoint.yaml | 2 ++ .github/workflows/run_emqx_app_tests.yaml | 22 ++++++++++------------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/_pr_entrypoint.yaml b/.github/workflows/_pr_entrypoint.yaml index 81a4b7f71..dce8a91eb 100644 --- a/.github/workflows/_pr_entrypoint.yaml +++ b/.github/workflows/_pr_entrypoint.yaml @@ -154,6 +154,8 @@ jobs: with: runner: ${{ needs.sanity-checks.outputs.runner }} builder: ${{ needs.sanity-checks.outputs.builder }} + before_ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} + after_ref: ${{ github.sha }} run_test_cases: needs: diff --git a/.github/workflows/_push-entrypoint.yaml b/.github/workflows/_push-entrypoint.yaml index a59511259..bccb21c78 100644 --- a/.github/workflows/_push-entrypoint.yaml +++ b/.github/workflows/_push-entrypoint.yaml @@ -166,6 +166,8 @@ jobs: with: runner: ${{ needs.sanity-checks.outputs.runner }} builder: ${{ needs.sanity-checks.outputs.builder }} + before_ref: ${{ github.event.before }} + after_ref: ${{ github.sha }} run_test_cases: if: needs.prepare.outputs.release != 'true' diff --git a/.github/workflows/run_emqx_app_tests.yaml b/.github/workflows/run_emqx_app_tests.yaml index b5b821741..5479a86ab 100644 --- a/.github/workflows/run_emqx_app_tests.yaml +++ b/.github/workflows/run_emqx_app_tests.yaml @@ -16,6 +16,12 @@ on: builder: required: true type: string + before_ref: + required: true + type: string + after_ref: + required: true + type: string env: IS_CI: "yes" @@ -34,20 +40,12 @@ jobs: with: fetch-depth: 0 - name: run + env: + BEFORE_REF: ${{ inputs.before_ref }} + AFTER_REF: ${{ inputs.after_ref }} run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" - echo "git diff base: $GITHUB_BASE_REF" - if [[ "$GITHUB_BASE_REF" =~ [0-9a-f]{8,40} ]]; then - # base is a commit sha1 - compare_base="$GITHUB_BASE_REF" - else - repo="${GITHUB_REPOSITORY}" - git remote -v - remote="$(git remote -v | grep -E "github\.com(:|/)$repo((\.git)|(\s))" | grep fetch | awk '{print $1}')" - git fetch "$remote" "$GITHUB_BASE_REF" - compare_base="$remote/$GITHUB_BASE_REF" - fi - changed_files="$(git diff --name-only ${compare_base} HEAD apps/emqx)" + changed_files="$(git diff --name-only ${BEFORE_REF} ${AFTER_REF} apps/emqx)" if [ "$changed_files" = '' ]; then echo "nothing changed in apps/emqx, ignored." exit 0 From b4161009436c9ec010e33a0785cc405d00a913d9 Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Tue, 15 Aug 2023 14:40:19 -0300 Subject: [PATCH 4/4] ci: fix output source --- .github/workflows/_push-entrypoint.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_push-entrypoint.yaml b/.github/workflows/_push-entrypoint.yaml index bccb21c78..bc3bc486e 100644 --- a/.github/workflows/_push-entrypoint.yaml +++ b/.github/workflows/_push-entrypoint.yaml @@ -164,8 +164,8 @@ jobs: - compile uses: ./.github/workflows/run_emqx_app_tests.yaml with: - runner: ${{ needs.sanity-checks.outputs.runner }} - builder: ${{ needs.sanity-checks.outputs.builder }} + runner: ${{ needs.prepare.outputs.runner }} + builder: ${{ needs.prepare.outputs.builder }} before_ref: ${{ github.event.before }} after_ref: ${{ github.sha }}