Skip to content

Workflow file for this run

name: BATS on macOS on latest CI build
on:
workflow_dispatch:
inputs:
owner:
description: Override owner (e.g. rancher-sandbox)
type: string
repo:
description: Override repository (e.g. rancher-desktop)
type: string
branch:
description: Override branch (e.g. main, or PR#)
type: string
tests:
description: 'Tests (e.g. tests/containers/*)'
default: 'tests/*'
type: string
results:
description: Number of runs to search for Package workflow
default: 30
type: number
env:
SCRIPT: install-latest-ci.sh
RD_LOCATION: user
GH_OWNER: ${{ github.repository_owner }}
GH_REPOSITORY: ${{ github.repository }}
GH_REF_NAME: ${{ github.ref_name }}
jobs:
bats:
runs-on: macos-12
strategy:
fail-fast: false
matrix:
engine:
- containerd
- moby
steps:
- name: Fetch install script
run: |
URL="https://raw.githubusercontent.com/$GH_REPOSITORY/$GH_REF_NAME/scripts/$SCRIPT"
curl --output-dir "$TMPDIR" -O "$URL"
chmod +x "$TMPDIR/$SCRIPT"
- name: Install latest CI build
run: |
: ${OWNER:=$GH_OWNER}
: ${REPO:=${GH_REPOSITORY#$GH_OWNER/}}
: ${BRANCH:=$GH_REF_NAME}
# If BRANCH is a number, assume it is supposed to be a PR
[[ $BRANCH =~ ^[0-9]+$ ]] && PR=$BRANCH
"$TMPDIR/$SCRIPT"
env:
GH_TOKEN: ${{ github.token }}
OWNER: ${{ inputs.owner }}
REPO: ${{ inputs.repo }}
BRANCH: ${{ inputs.branch }}
RESULTS: ${{ inputs.results }}
- name: Run BATS
run: |
DEFAULT_DIR=$PWD
cd "$TMPDIR/bats"
./bats-core/bin/bats \
--gather-test-outputs-in "$DEFAULT_DIR/logs" \
--report-formatter tap \
${{ inputs.tests }}
env:
RD_CONTAINER_ENGINE: ${{ matrix.engine }}
RD_CAPTURE_LOGS: "true"
RD_TAKE_SCREENSHOTS: "true"
RD_USE_IMAGE_ALLOW_LIST: "true"
- name: Consolidate logs
if: ${{ !cancelled() }}
run: |
# bats/logs may not exist if the workflow is being tested with e.g. tests/helpers/utils.bats
if [ -d "$TMPDIR/bats/logs" ]; then
cp -R "$TMPDIR/bats/logs/" logs
fi
cp "$TMPDIR/bats/report.tap" logs
"$TMPDIR/bats/scripts/rename-logs.sh" logs
- name: Upload logs
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.engine }}.logs
path: logs/
if-no-files-found: error