tests
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: 'Priority: NeedsTriage, Type: Bug'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
|
||||
1. Create example `file.bats` with following contents
|
||||
2. run `bats --foo file.bats`
|
||||
3. ...
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Environment (please complete the following information):**
|
||||
- Bats version [e.g. 1.4.0 or commit hash if applicable]
|
||||
- operating system (including version): [e.g. Linux (please name your distribution!), FreeBSD, MacOS]
|
||||
- `bash --version`: [e.g. 5.1]
|
||||
- Install method: [e.g. git submodule, distribution package manager, npm, homebrew, ...]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: 'Priority: NeedsTriage, Type: Enhancement'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the feature request here.
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: docker
|
||||
directory: /.devcontainer
|
||||
schedule:
|
||||
interval: daily
|
||||
labels:
|
||||
- docker
|
||||
- devcontainer
|
||||
- dependencies
|
||||
- no changelog
|
||||
|
||||
- package-ecosystem: github-actions
|
||||
directory: /
|
||||
schedule:
|
||||
interval: daily
|
||||
labels:
|
||||
- github-actions
|
||||
- dependencies
|
||||
- no changelog
|
||||
|
||||
- package-ecosystem: docker
|
||||
directory: /
|
||||
schedule:
|
||||
interval: daily
|
||||
labels:
|
||||
- docker
|
||||
- dependencies
|
||||
- no changelog
|
||||
|
||||
- package-ecosystem: pip
|
||||
directory: /docs/source
|
||||
schedule:
|
||||
interval: daily
|
||||
labels:
|
||||
- pip
|
||||
- dependencies
|
||||
- no changelog
|
||||
|
||||
- package-ecosystem: npm
|
||||
directory: /
|
||||
schedule:
|
||||
interval: daily
|
||||
labels:
|
||||
- npm
|
||||
- dependencies
|
||||
- no changelog
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
get_pr_json() {
|
||||
curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/bats-core/bats-core/pulls/$1"
|
||||
}
|
||||
|
||||
PR_NUMBER="$1"
|
||||
LABEL="$2"
|
||||
|
||||
get_pr_json "$PR_NUMBER" | jq .labels[].name | grep "$LABEL"
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
name: Codespell
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
codespell:
|
||||
name: Check for spelling errors
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- name: Codespell
|
||||
uses: codespell-project/actions-codespell@94259cd8be02ad2903ba34a22d9c13de21a74461 # v2.0
|
||||
@@ -0,0 +1,22 @@
|
||||
# Dependency Review Action
|
||||
#
|
||||
# This Action will scan dependency manifest files that change as part of a Pull Request,
|
||||
# surfacing known-vulnerable versions of the packages declared or updated in the PR.
|
||||
# Once installed, if the workflow run is marked as required,
|
||||
# PRs introducing known-vulnerable packages will be blocked from merging.
|
||||
#
|
||||
# Source repository: https://github.com/actions/dependency-review-action
|
||||
name: 'Dependency Review'
|
||||
on: [pull_request]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
dependency-review:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Checkout Repository'
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- name: 'Dependency Review'
|
||||
uses: actions/dependency-review-action@0fa40c3c10055986a88de3baa0d6ec17c5a894b3 # v4.2.3
|
||||
@@ -0,0 +1,35 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
release: { types: [published] }
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
npmjs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
with:
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
- run: npm publish --ignore-scripts
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
github-npm:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
with:
|
||||
registry-url: "https://npm.pkg.github.com"
|
||||
- name: scope package name as required by GitHub Packages
|
||||
run: npm init -y --scope ${{ github.repository_owner }}
|
||||
- run: npm publish --ignore-scripts
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,59 @@
|
||||
name: Release to docker hub
|
||||
|
||||
on:
|
||||
release: { types: [published] }
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version to simulate for deploy'
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
dockerhub:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
|
||||
- id: version
|
||||
run: |
|
||||
EXPECTED_VERSION=${{ github.event.inputs.version }}
|
||||
TAG_VERSION=${GITHUB_REF#refs/tags/v} # refs/tags/v1.2.3 -> 1.2.3
|
||||
echo ::set-output name=version::${EXPECTED_VERSION:-$TAG_VERSION}
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
|
||||
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Log in to the GitHub Container registry
|
||||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3.2.0
|
||||
|
||||
- uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
|
||||
tags: ${{ secrets.DOCKER_USERNAME }}/bats:${{ steps.version.outputs.version }},${{ secrets.DOCKER_USERNAME }}/bats:latest
|
||||
push: true
|
||||
|
||||
- uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
|
||||
tags: ${{ secrets.DOCKER_USERNAME }}/bats:${{ steps.version.outputs.version }}-no-faccessat2,${{ secrets.DOCKER_USERNAME }}/bats:latest-no-faccessat2
|
||||
push: true
|
||||
build-args: bashver=5.1.4
|
||||
@@ -0,0 +1,72 @@
|
||||
# This workflow uses actions that are not certified by GitHub. They are provided
|
||||
# by a third-party and are governed by separate terms of service, privacy
|
||||
# policy, and support documentation.
|
||||
|
||||
name: Scorecard supply-chain security
|
||||
on:
|
||||
# For Branch-Protection check. Only the default branch is supported. See
|
||||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
|
||||
branch_protection_rule:
|
||||
# To guarantee Maintained check is occasionally updated. See
|
||||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
|
||||
schedule:
|
||||
- cron: '44 10 * * 6'
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
name: Scorecard analysis
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# Needed to upload the results to code-scanning dashboard.
|
||||
security-events: write
|
||||
# Needed to publish results and get a badge (see publish_results below).
|
||||
id-token: write
|
||||
# Uncomment the permissions below if installing in a private repository.
|
||||
# contents: read
|
||||
# actions: read
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
|
||||
# - you want to enable the Branch-Protection check on a *public* repository, or
|
||||
# - you are installing Scorecard on a *private* repository
|
||||
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
|
||||
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
|
||||
|
||||
# Public repositories:
|
||||
# - Publish results to OpenSSF REST API for easy access by consumers
|
||||
# - Allows the repository to include the Scorecard badge.
|
||||
# - See https://github.com/ossf/scorecard-action#publishing-results.
|
||||
# For private repositories:
|
||||
# - `publish_results` will always be set to `false`, regardless
|
||||
# of the value entered here.
|
||||
publish_results: true
|
||||
|
||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
@@ -0,0 +1 @@
|
||||
set -u
|
||||
+333
@@ -0,0 +1,333 @@
|
||||
name: Tests
|
||||
|
||||
# Controls when the action will run.
|
||||
on: [push, pull_request, workflow_dispatch]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
changelog:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- name: Check that PR is mentioned in Changelog
|
||||
run: |
|
||||
if ! ./.github/workflows/check_pr_label.sh "${{github.event.pull_request.number}}" "no changelog"; then
|
||||
grep "#${{github.event.pull_request.number}}" docs/CHANGELOG.md
|
||||
fi
|
||||
if: ${{github.event.pull_request}}
|
||||
|
||||
shfmt:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- run: |
|
||||
curl https://github.com/mvdan/sh/releases/download/v3.5.1/shfmt_v3.5.1_linux_amd64 -o shfmt
|
||||
chmod a+x shfmt
|
||||
- run: ./shfmt --diff .
|
||||
|
||||
# Ensure we detect when a change disables Bats from reporting failure.
|
||||
# This would not be detectable by Bats' selftests.
|
||||
failsafe:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Check failing tests fail suite,
|
||||
run: "! bin/bats test/fixtures/bats/failing.bats"
|
||||
|
||||
shellcheck:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- name: Run shellcheck
|
||||
run: |
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install shellcheck
|
||||
./shellcheck.sh
|
||||
|
||||
linux:
|
||||
strategy:
|
||||
matrix:
|
||||
os: ['ubuntu-20.04', 'ubuntu-22.04']
|
||||
env_vars:
|
||||
- ''
|
||||
# allow for some parallelity without GNU parallel, since it is not installed by default
|
||||
- 'BATS_NO_PARALLELIZE_ACROSS_FILES=1 BATS_NUMBER_OF_PARALLEL_JOBS=2'
|
||||
- 'BATS_PARALLEL_BINARY_NAME=rush'
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- name: Install rush
|
||||
run: |
|
||||
curl -sSfL https://github.com/shenwei356/rush/releases/download/v0.5.0/rush_linux_amd64.tar.gz | sudo tar xzf - -C /usr/local/bin
|
||||
if: contains(matrix.env_vars, 'rush')
|
||||
- name: Run test on OS ${{ matrix.os }}
|
||||
shell: 'script -q -e -c "bash {0}"' # work around tty issues
|
||||
env:
|
||||
TERM: linux # fix tput for tty issue work around
|
||||
run: |
|
||||
bash --version
|
||||
bash -c "time ${{ matrix.env_vars }} bin/bats --print-output-on-failure --formatter tap test"
|
||||
|
||||
unset_variables:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- name: Check unset variables
|
||||
shell: 'script -q -e -c "bash {0}"' # work around tty issues
|
||||
env:
|
||||
TERM: linux # fix tput for tty issue work around
|
||||
BASH_ENV: ${GITHUB_WORKSPACE}/.github/workflows/set_nounset.bash
|
||||
run: bin/bats test --print-output-on-failure
|
||||
|
||||
npm_on_linux:
|
||||
strategy:
|
||||
matrix:
|
||||
os: ['ubuntu-20.04', 'ubuntu-22.04']
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- name: Run test on OS ${{ matrix.os }}
|
||||
shell: 'script -q -e -c "bash {0}"' # work around tty issues
|
||||
env:
|
||||
TERM: linux # fix tput for tty issue work around
|
||||
run: |
|
||||
npm pack ./
|
||||
sudo npm install -g ./bats-*.tgz
|
||||
bats test --print-output-on-failure
|
||||
|
||||
windows:
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- name: Check failing tests fail suite,
|
||||
run: bash -c "! bin/bats test/fixtures/bats/failing.bats"
|
||||
- run: |
|
||||
bash --version
|
||||
bash -c "time bin/bats --print-output-on-failure --formatter tap test"
|
||||
|
||||
npm_on_windows:
|
||||
strategy:
|
||||
matrix:
|
||||
os: ['windows-2019']
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- run: npm pack ./
|
||||
- run: npm install -g (get-item .\bats-*.tgz).FullName
|
||||
- run: bats -T --print-output-on-failure test
|
||||
|
||||
macos:
|
||||
strategy:
|
||||
matrix:
|
||||
os: ['macos-11', 'macos-12']
|
||||
env_vars:
|
||||
- ''
|
||||
# allow for some parallelity without GNU parallel, since it is not installed by default
|
||||
- 'BATS_NO_PARALLELIZE_ACROSS_FILES=1 BATS_NUMBER_OF_PARALLEL_JOBS=2'
|
||||
- 'BATS_PARALLEL_BINARY_NAME=rush'
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- name: Install unbuffer via expect
|
||||
run: brew install expect
|
||||
- name: Install rush
|
||||
run: |
|
||||
curl -sSfL https://github.com/shenwei356/rush/releases/download/v0.5.0/rush_darwin_amd64.tar.gz | sudo tar xzf - -C /usr/local/bin
|
||||
if: contains(matrix.env_vars, 'rush')
|
||||
|
||||
- name: Check failing tests fail suite,
|
||||
shell: 'unbuffer bash {0}' # work around tty issues
|
||||
env:
|
||||
TERM: linux # fix tput for tty issue work around
|
||||
run: bash -c '! bin/bats test/fixtures/bats/failing.bats'
|
||||
|
||||
- name: Run test on OS ${{ matrix.os }}
|
||||
shell: 'unbuffer bash {0}' # work around tty issues
|
||||
env:
|
||||
TERM: linux # fix tput for tty issue work around
|
||||
run: |
|
||||
bash --version
|
||||
bash -c "time ${{ matrix.env_vars }} bin/bats --print-output-on-failure --formatter tap test"
|
||||
|
||||
npm_on_macos:
|
||||
strategy:
|
||||
matrix:
|
||||
os: ['macos-11', 'macos-12']
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- name: Install unbuffer via expect
|
||||
run: brew install expect
|
||||
- name: Run test on OS ${{ matrix.os }}
|
||||
shell: 'unbuffer bash {0}' # work around tty issues
|
||||
env:
|
||||
TERM: linux # fix tput for tty issue work around
|
||||
run: |
|
||||
npm pack ./
|
||||
# somehow there is already an installed bats version around
|
||||
npm install --force -g ./bats-*.tgz
|
||||
bats --print-output-on-failure test
|
||||
|
||||
bash-version:
|
||||
strategy:
|
||||
matrix:
|
||||
version: ['3.2', '4.0', '4.1', '4.2', '4.3', '4.4', '4', '5.0', '5.1', '5', 'rc']
|
||||
env_vars:
|
||||
- ''
|
||||
# also test running (recursively!) in parallel
|
||||
- '-e BATS_NUMBER_OF_PARALLEL_JOBS=2'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- name: Run test on bash version ${{ matrix.version }}
|
||||
shell: 'script -q -e -c "bash {0}"' # work around tty issues
|
||||
run: |
|
||||
set -e
|
||||
docker build --build-arg bashver="${{ matrix.version }}" --tag "bats/bats:bash-${{ matrix.version }}" .
|
||||
docker run -it "bash:${{ matrix.version }}" --version
|
||||
time docker run -it ${{ matrix.env_vars }} "bats/bats:bash-${{ matrix.version }}" --print-output-on-failure --tap /opt/bats/test
|
||||
|
||||
alpine:
|
||||
runs-on: ubuntu-latest
|
||||
container: alpine:latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- name: Install dependencies
|
||||
run: apk add bash ncurses util-linux
|
||||
- name: Run test on bash version ${{ matrix.version }}
|
||||
shell: 'script -q -e -c "bash {0}"' # work around tty issues
|
||||
env:
|
||||
TERM: linux # fix tput for tty issue work around
|
||||
run:
|
||||
time ./bin/bats --print-output-on-failure test/
|
||||
|
||||
freebsd:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
packages:
|
||||
- flock
|
||||
- ""
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: vmactions/freebsd-vm@35a5b20a98476a681c7576a344775be7e7f77f06 # v1.0.6
|
||||
with:
|
||||
prepare: pkg install -y bash parallel ${{ matrix.packages }}
|
||||
run: |
|
||||
time ./bin/bats --print-output-on-failure test/
|
||||
|
||||
find_broken_symlinks:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
# list symlinks that are broken and force non-zero exit if there are any
|
||||
- run: "! find . -xtype l | grep ."
|
||||
|
||||
rpm:
|
||||
runs-on: ubuntu-latest
|
||||
container: almalinux:8
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- run: dnf install -y rpm-build rpmdevtools
|
||||
- name: Build and install RPM and dependencies
|
||||
run: |
|
||||
rpmdev-setuptree
|
||||
version=$(rpmspec -q --qf '%{version}' contrib/rpm/bats.spec)
|
||||
tar --transform "s,^,bats-core-${version}/," -cf /github/home/rpmbuild/SOURCES/v${version}.tar.gz ./
|
||||
rpmbuild -v -bb ./contrib/rpm/bats.spec
|
||||
ls -al /github/home/rpmbuild/RPMS/noarch/
|
||||
dnf install -y /github/home/rpmbuild/RPMS/noarch/bats-*.rpm
|
||||
dnf -y install procps-ng # avoid timeout failure
|
||||
- name: Run tests
|
||||
shell: 'script -q -e -c "bash {0}"' # work around tty issues
|
||||
env:
|
||||
TERM: linux # fix tput for tty issue work around
|
||||
run: bats --print-output-on-failure --filter-tags !dep:install_sh test/
|
||||
|
||||
dockerfile:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3.2.0
|
||||
|
||||
- uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
|
||||
with:
|
||||
platforms: linux/amd64
|
||||
tags: bats:test
|
||||
load: true
|
||||
|
||||
- run: docker run -itv "$PWD":/code bats:test --tap --print-output-on-failure test/
|
||||
shell: 'script -q -e -c "bash {0}"' # work around tty issues
|
||||
env:
|
||||
TERM: linux # fix tput for tty issue work around
|
||||
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
with:
|
||||
repository: bats-core/bats-assert
|
||||
path: bats-assert
|
||||
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
with:
|
||||
repository: bats-core/bats-support
|
||||
path: bats-support
|
||||
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
with:
|
||||
repository: bats-core/bats-file
|
||||
path: bats-file
|
||||
|
||||
- run: |
|
||||
<<EOF cat >test.sh
|
||||
apk add sudo python3 # install bats-file's dependencies
|
||||
ln -sf python3 /usr/bin/python # bats-file uses python without version
|
||||
bats --tap --print-output-on-failure bats-*/test/
|
||||
EOF
|
||||
docker run -itv "$PWD":/code --entrypoint bash bats:test test.sh
|
||||
shell: 'script -q -e -c "bash {0}"' # work around tty issues
|
||||
env:
|
||||
TERM: linux # fix tput for tty issue work around
|
||||
|
||||
coverage:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- run: |
|
||||
wget https://github.com/SimonKagstrom/kcov/releases/download/v40/kcov-amd64.tar.gz
|
||||
tar -xf kcov-amd64.tar.gz
|
||||
- run: |
|
||||
./usr/local/bin/kcov --exclude-path=/tmp $PWD/coverage ./bin/bats --filter-tags '!no-kcov' test/
|
||||
shell: 'script -q -e -c "bash {0}"' # work around tty issues
|
||||
env:
|
||||
TERM: linux # fix tput for tty issue work around
|
||||
|
||||
- name: Archive code coverage results
|
||||
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
|
||||
with:
|
||||
name: code-coverage-report
|
||||
path: coverage/*
|
||||
|
||||
- name: Print the Total Coverage
|
||||
id: coverage-percent
|
||||
shell: bash
|
||||
env:
|
||||
minimum_coverage: 86.40
|
||||
run: |
|
||||
value=$(jq '.percent_covered' <coverage/bats/coverage.json)
|
||||
fixed_point() { # <float val>
|
||||
int=${1%.*}
|
||||
decimals=${1#*.}
|
||||
echo $int${decimals::2}
|
||||
}
|
||||
echo "Coverage: $value%" | tee "$GITHUB_STEP_SUMMARY"
|
||||
if (( $(fixed_point $value) < $(fixed_point $expected) )); then
|
||||
echo " is below required minimum coverage ($minimum_coverage%)." | tee -a "$GITHUB_STEP_SUMMARY"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user