Skip to content

Commit

Permalink
simplify by using install.sh + add matrix in actions
Browse files Browse the repository at this point in the history
  • Loading branch information
brokenpip3 committed Apr 6, 2024
1 parent b2bbffc commit 9d529d5
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 24 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/test-local-action-inside-home.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test-local-action-with-conditionals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/test-local-action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/test-public-action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
29 changes: 8 additions & 21 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,15 @@ runs:
with:
path: |
~/.local/share/bats
~/.local/bin/bats
key: ${{ runner.os }}-bats-${{ inputs.bats-version }}

- name: "Set PATH in case of cache-hit"
if: inputs.bats-install == 'true' && steps.bats-cache.outputs.cache-hit == 'true'
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'
Expand All @@ -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/"
Expand All @@ -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"
Expand Down

0 comments on commit 9d529d5

Please sign in to comment.