-
Notifications
You must be signed in to change notification settings - Fork 409
Install
📑: links to another wiki page
- Install Bats Using a Package 📑
- Install Bats Using GNU Stow 📑
- Install Bats from GitHub Release
- Install Bats from GitHub branch archive
- Adding Bats dependency to Travis CI
- Adding Bats from GitHub release to your own Dockerfile
- More Examples 📑
Download and install a tagged release.
tag=1.1.0
batstmp="$(mktemp -d bats-core-"${tag}".XXXXX)"
pushd "${batstmp}" &> /dev/null || return 11
curl -sSLO https://github.com/bats-core/bats-core/archive/refs/tags/v"${tag}".tar.gz
tar -zxvf v"${tag}".tar.gz
sudo bash "${batstmp}"/bats-core-"${tag}"/install.sh /usr/local
popd &> /dev/null || return 12
command -v bats && rm -rf "${batstmp}"
Download and install from the master
branch zip
archive
branch=master
batstmp="$(mktemp -d bats-core-"${branch}".XXXXX)"
pushd "${batstmp}" &> /dev/null || return 11
curl -sSLO https://github.com/bats-core/bats-core/archive/refs/heads/"${branch}".zip
unzip -qo "${branch}".zip
sudo bash "${batstmp}"/bats-core-"${branch}"/install.sh /usr/local
popd &> /dev/null || return 12
command -v bats && rm -rf "${batstmp}"
If you use Bats for testing builds in 🔁Travis CI, start with this configuration.
ℹ️ Note
language: bash
is a Travis CI alias forlanguage: minimal
This installs the GitHub master
branch from source and adds /usr/local/bin
to the PATH
.
Sample .travis.yml file
language: bash
dist: xenial
#addons:
# apt:
# update: true
# packages:
# - xz-utils
# - pv
env:
global:
- export PATH="/usr/local/bin:$PATH"
before_install:
- |
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
branch=master
batstmp="$(mktemp -d bats-core-"${branch}".XXXXX)"
pushd "${batstmp}" &> /dev/null || return 11
curl -sSLO https://github.com/bats-core/bats-core/archive/refs/heads/"${branch}".zip
unzip -qo "${branch}".zip
sudo bash "${batstmp}"/bats-core-"${branch}"/install.sh /usr/local
popd &> /dev/null || return 12
fi
script:
- bats test/test.bats
Uncomment the addons: apt
section if you need to install other packages, not included in the default xenial
environment.
If you have your own Docker based development environment in which you want Bats to be available, then the following works.
ℹ️ Note
Some "slim/thin/minimal" Docker images may needcurl
installing first. The below extract was tested withdebian:bullseye-slim
which did needcurl
installing viaapt-get install
Sample Dockerfile extract
...
# Set tagged release version of Bats to use. This could be also set in docker-compose.
ARG BATS_VERSION="1.7.0"
# Install bats
RUN batstmp="$(mktemp -d bats-core-${BATS_VERSION}.XXXX)" \
&& echo ${batstmp} \
&& cd ${batstmp} \
&& curl -SLO https://github.com/bats-core/bats-core/archive/refs/tags/v${BATS_VERSION}.tar.gz \
&& tar -zxvf v${BATS_VERSION}.tar.gz \
&& bash bats-core-${BATS_VERSION}/install.sh /usr/local \
&& rm -rf "${batstmp}"
This community-maintained documentation for Bats is about core/master
,
see sidebar interwiki or the about page for more info.