Skip to content

Commit 61a3714

Browse files
authored
Merge pull request #64 from joshuanianji/idris-api
Install Idris API
2 parents 0cd066e + d1551d3 commit 61a3714

File tree

4 files changed

+58
-6
lines changed

4 files changed

+58
-6
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

base.Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ RUN if [ $IDRIS_VERSION = "latest" ] ; \
4343
WORKDIR /root/Idris2
4444
RUN make bootstrap SCHEME=scheme && make install
4545

46-
# these things aren't strictly necessary for a functioning base image,
47-
# but they make it possible for us to test the image
48-
4946
# add idris2 to path
5047
ENV PATH="/root/.idris2/bin:${PATH}"
5148
# add idris lib to LD_LIBRARY_PATH
5249
ENV LD_LIBRARY_PATH="/root/.idris2/lib:${LD_LIBRARY_PATH}"
50+
51+
# self-hosting (needed for Idris2 API)
52+
# in my experience, the Idris2 API seems to still work without the self-hosting step
53+
# At least, it builds the idris2-python correctly (although i haven't checked anything else)
54+
# to be safe, I'll do this step anyway
55+
# NOTE: not sure if the install-api transfers to the child images
56+
RUN make clean && make all && make install
57+
RUN make install-api

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)