From b2bbffca5c511fc2665f1b5d7b44aefcf24752b7 Mon Sep 17 00:00:00 2001 From: davdhacs <105243888+davdhacs@users.noreply.github.com> Date: Fri, 29 Mar 2024 08:37:12 -0600 Subject: [PATCH 1/2] empty commit to trigger github action test From 9d529d54b845d97bfe7689999a85f1452ef8eea4 Mon Sep 17 00:00:00 2001 From: brokenpip3 Date: Sat, 6 Apr 2024 12:55:09 +0200 Subject: [PATCH 2/2] simplify by using install.sh + add matrix in actions --- .../test-local-action-inside-home.yaml | 15 ++++++++-- .../test-local-action-with-conditionals.yaml | 6 +++- .github/workflows/test-local-action.yaml | 11 +++++++ .github/workflows/test-public-action.yaml | 10 +++++++ action.yaml | 29 +++++-------------- 5 files changed, 47 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test-local-action-inside-home.yaml b/.github/workflows/test-local-action-inside-home.yaml index 95f6c0b..5a406bd 100644 --- a/.github/workflows/test-local-action-inside-home.yaml +++ b/.github/workflows/test-local-action-inside-home.yaml @@ -10,6 +10,10 @@ on: jobs: local_test_home: + strategy: + fail-fast: false + matrix: + version: ["1.7.0", "1.8.2", "1.9.0", "1.10.0", "1.11.0", "latest"] runs-on: ubuntu-latest env: BATS_LIB_PATH: "${{ github.workspace }}/tests" @@ -22,6 +26,7 @@ jobs: id: bats-action uses: ./ with: + bats-version: ${{ matrix.version }} support-clean: "false" support-path: "${{ github.workspace }}/tests/bats-support" assert-clean: "false" @@ -55,10 +60,16 @@ jobs: cd /tmp/bats-file/ bats test - name: Execute example tests - run: + run: | + echo $PATH bats -T -p tests + local_test_home_trigger_cache: needs: [local_test_home] + strategy: + fail-fast: false + matrix: + version: ["1.7.0", "1.8.2", "1.9.0", "1.10.0", "1.11.0", "latest"] runs-on: ubuntu-latest env: BATS_LIB_PATH: "${{ github.workspace }}/tests" @@ -71,6 +82,7 @@ jobs: id: bats-action uses: ./ with: + bats-version: ${{ matrix.version }} support-clean: "false" support-path: "${{ github.workspace }}/tests/bats-support" assert-clean: "false" @@ -87,7 +99,6 @@ jobs: - name: Execute test to check Bats-assert if: steps.bats-action.outputs.assert-installed == 'true' run: | - ls -l $BATS_LIB_PATH/ cd /tmp/bats-assert/ bats test - name: Execute test to check Bats-detik diff --git a/.github/workflows/test-local-action-with-conditionals.yaml b/.github/workflows/test-local-action-with-conditionals.yaml index 4508372..09a4ef9 100644 --- a/.github/workflows/test-local-action-with-conditionals.yaml +++ b/.github/workflows/test-local-action-with-conditionals.yaml @@ -10,6 +10,10 @@ on: jobs: local_test_options: + strategy: + fail-fast: false + matrix: + version: ["1.7.0", "1.8.2", "1.9.0", "1.10.0", "1.11.0", "latest"] runs-on: ubuntu-latest env: BATS_LIB_PATH: "/usr/lib" @@ -21,7 +25,7 @@ jobs: - name: Setup Bats and Bats libs uses: ./ with: - bats-version: 1.9.0 + bats-version: ${{ matrix.version } support-clean: "false" assert-clean: "false" detik-install: "true" diff --git a/.github/workflows/test-local-action.yaml b/.github/workflows/test-local-action.yaml index 0fc4dbf..caab797 100644 --- a/.github/workflows/test-local-action.yaml +++ b/.github/workflows/test-local-action.yaml @@ -10,6 +10,10 @@ on: jobs: local_test: + strategy: + fail-fast: false + matrix: + version: ["1.7.0", "1.8.2", "1.9.0", "1.10.0", "1.11.0", "latest"] runs-on: ubuntu-latest env: BATS_LIB_PATH: "/usr/lib" @@ -21,6 +25,7 @@ jobs: - name: Setup Bats and Bats libs uses: ./ with: + bats-version: ${{ matrix.version }} support-clean: "false" assert-clean: "false" detik-clean: "false" @@ -47,8 +52,13 @@ jobs: - name: Execute example tests run: bats -T -p tests + local_test_trigger_cache: needs: [local_test] + strategy: + fail-fast: false + matrix: + version: ["1.7.0", "1.8.2", "1.9.0", "1.10.0", "1.11.0", "latest"] runs-on: ubuntu-latest env: BATS_LIB_PATH: "/usr/lib" @@ -60,6 +70,7 @@ jobs: - name: Setup Bats and Bats libs uses: ./ with: + bats-version: ${{ matrix.version }} support-clean: "false" assert-clean: "false" detik-clean: "false" diff --git a/.github/workflows/test-public-action.yaml b/.github/workflows/test-public-action.yaml index 385b901..ed6deb2 100644 --- a/.github/workflows/test-public-action.yaml +++ b/.github/workflows/test-public-action.yaml @@ -10,6 +10,10 @@ on: jobs: public_test: + strategy: + fail-fast: false + matrix: + version: ["1.7.0", "1.8.2", "1.9.0", "1.10.0", "1.11.0", "latest"] runs-on: ubuntu-latest env: BATS_LIB_PATH: "/usr/lib" @@ -21,6 +25,7 @@ jobs: - name: Setup Bats and Bats-libs uses: bats-core/bats-action@main with: + bats-version: ${{ matrix.version }} support-clean: "false" assert-clean: "false" detik-clean: "false" @@ -48,6 +53,10 @@ jobs: public_test_trigger_cache: # Run the test again to eventually trigger the cache in the future needs: [public_test] + strategy: + fail-fast: false + matrix: + version: ["1.7.0", "1.8.2", "1.9.0", "1.10.0", "1.11.0", "latest"] runs-on: ubuntu-latest env: BATS_LIB_PATH: "/usr/lib" @@ -58,6 +67,7 @@ jobs: - name: Setup Bats and Bats-libs uses: bats-core/bats-action@main with: + bats-version: ${{ matrix.version }} support-clean: "false" assert-clean: "false" detik-clean: "false" diff --git a/action.yaml b/action.yaml index bc88263..089d2e1 100644 --- a/action.yaml +++ b/action.yaml @@ -109,7 +109,6 @@ runs: with: path: | ~/.local/share/bats - ~/.local/bin/bats key: ${{ runner.os }}-bats-${{ inputs.bats-version }} - name: "Set PATH in case of cache-hit" @@ -117,8 +116,8 @@ runs: id: bats-cache-path shell: bash run: | - DESTDIR="$HOME/.local/bin" - echo "$DESTDIR" >> "$GITHUB_PATH" + DESTDIR="$HOME/.local/share/bats" + echo "${DESTDIR}/bin" >> "$GITHUB_PATH" - name: "Download and install Bats" if: inputs.bats-install == 'true' && steps.bats-cache.outputs.cache-hit != 'true' @@ -127,8 +126,7 @@ runs: run: | # In $HOME to avoid sudo requirements VERSION=${{ inputs.bats-version }} - DESTDIR="$HOME/.local/bin" - LIBDIR="$HOME/.local/share/bats" + DESTDIR="$HOME/.local/share/bats" TEMPDIR="/tmp/bats" URL="https://github.com/bats-core/bats-core/" @@ -143,23 +141,12 @@ runs: curl -sL ${URL}/archive/refs/tags/v${VERSION}.tar.gz | tar xz -C ${TEMPDIR} --strip-components 1 && cd ${TEMPDIR} - # Archlinux style, except that we are not in a fakeroot env - # https://gitlab.archlinux.org/archlinux/packaging/packages/bash-bats/-/blob/main/PKGBUILD - sed -i 's|BATS_ROOT/libexec/bats-core/bats|BATS_ROOT/share/bats/bats|g' bin/bats - sed -i 's|BATS_ROOT/lib/bats-core/|BATS_ROOT/share/bats/|g' libexec/bats-core/* - sed -i 's|BATS_ROOT/lib/bats-core/|BATS_ROOT/share/bats/|g' lib/bats-core/* - - for fn in libexec/bats-core/*; do - install -Dm755 ${fn} \ - ${LIBDIR}/$(basename ${fn}) - done - - install -Dm755 bin/bats "${DESTDIR}/bats" - install -Dm755 lib/bats-core/* -t "${LIBDIR}" - - echo "Bats v$VERSION installed in $DESTDIR" - echo "$DESTDIR" >> "$GITHUB_PATH" + # Install + ./install.sh ${DESTDIR} + echo "Bats v${VERSION} installed in ${DESTDIR}" + echo "${DESTDIR}/bin" >> "$GITHUB_PATH" echo "bats-installed=true" >> $GITHUB_OUTPUT + rm -rf ${TEMPDIR} || exit 0 - name: "Set cache for Bats-support"