Skip to content

Commit d1551d3

Browse files
committed
Add tests for base image
1 parent e2c26b8 commit d1551d3

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

.github/workflows/build-test-deploy.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,22 @@ jobs:
7070
dockerfile: base
7171
repo: ${{ github.repository }}
7272

73-
- name: Run Test
73+
- name: Setup Bats and Bats libs
74+
uses: brokenpip3/[email protected]
75+
with:
76+
bats-version: '1.8.2'
77+
support-version: 0.3.0
78+
assert-version: 2.1.0
79+
file-install: false
80+
detik-install: false
81+
82+
# LIB_PATH is a env var I use in the setup() function of my bats tests
83+
# it points to the folder containing bats-assert and bats-support
84+
- name: Run Test
7485
run: |
75-
docker run ${{ env.TAG }} /bin/bash -c "make clean; make all && make install"
86+
export LIB_PATH=/usr/lib/
87+
export DOCKER_IMAGE=${{ env.TAG }}
88+
bats tests/base.bats
7689
7790
base-test-2:
7891
name: Test 2 Base - ${{ matrix.idris-version }}
@@ -97,7 +110,7 @@ jobs:
97110

98111
- name: Run Test
99112
run: |
100-
docker run ${{ env.TAG }} /bin/bash -c "make clean; make all; make test"
113+
docker run ${{ env.TAG }} /bin/bash -c "make test"
101114
102115
# it would be nice to make the if conditional in the top level of the job,
103116
# but since devcontainer-build depends on this, we need this to run on a PR success as well

tests/base.bats

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Consumer idris
2+
# Tests the idris installation inside the "consumer" images - Ubuntu and Debian
3+
4+
function setup() {
5+
# Assumes the BATS_TEST_FILENAME is always one layer deep inside tests/
6+
# not a very good assumption! But i'm not going to be using bats much right now...
7+
DIR="$( dirname $( dirname "$BATS_TEST_FILENAME" ) )"
8+
9+
# by default, look in tests/test_helper
10+
if [[ -z "${LIB_PATH}" ]]; then
11+
LIB_PATH="$DIR/tests/test_helper"
12+
fi
13+
14+
load "$LIB_PATH/bats-support/load"
15+
load "$LIB_PATH/bats-assert/load"
16+
}
17+
18+
@test "Test location of Idris binary" {
19+
# note that the consumer images have an entrypoint of the "idris2" binary
20+
run docker run --entrypoint /bin/bash $DOCKER_IMAGE which idris2
21+
assert_output --partial '/root/.idris2/bin/idris2'
22+
}
23+
24+
@test "Test install-api" {
25+
# make sure `install-api` is installed correctly
26+
# by building idris2-python module
27+
28+
# run contents of tests/build-idris2-python.sh in the image
29+
run docker run -i --entrypoint /bin/bash $DOCKER_IMAGE < tests/build-idris2-python.sh
30+
refute_output --partial "required idris2 any but no matching version is installed"
31+
}

tests/build-idris2-python.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
git clone https://github.com/madman-bob/idris2-python.git
2+
cd idris2-python
3+
make install

0 commit comments

Comments
 (0)