Skip to content

Commit 392277b

Browse files
authored
Merge pull request #73 from joshuanianji/fix-72
Fix `IDRIS_SHA` and `IDRIS_LSP_SHA` env vars
2 parents 8027e2e + e826c3a commit 392277b

12 files changed

+88
-38
lines changed

.github/actions/get-idris-sha/action.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ runs:
1919
- name: Get SHA
2020
id: get-sha
2121
run: |
22-
echo "name=sha::$(curl -s 'https://api.github.com/repos/idris-lang/Idris2/commits' | jq -r '.[0].sha')" >> $GITHUB_OUTPUT
22+
echo "sha=$(curl -s 'https://api.github.com/repos/idris-lang/Idris2/commits' | jq -r '.[0].sha')" >> $GITHUB_OUTPUT
2323
shell: bash
2424
- name: Get LSP SHA
2525
id: get-lsp-sha
2626
run: |
27-
echo "name=lsp-sha::$(curl -s 'https://api.github.com/repos/idris-community/idris2-lsp/commits' | jq -r '.[0].sha')" >> $GITHUB_OUTPUT
27+
echo "lsp-sha=$(curl -s 'https://api.github.com/repos/idris-community/idris2-lsp/commits' | jq -r '.[0].sha')" >> $GITHUB_OUTPUT
2828
shell: bash
29-
- name: Print Output
29+
- name: Outputs
3030
run: |
31-
echo $GITHUB_OUTPUT
31+
echo "LSP SHA: ${{ steps.get-lsp-sha.outputs.lsp-sha }}"
32+
echo "Idris Commit SHA: ${{ steps.get-sha.outputs.sha }}"
3233
shell: bash

.github/workflows/ci.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Test and Deploy
1+
name: CI
22

33
on:
44
push:
@@ -18,7 +18,7 @@ on:
1818

1919
jobs:
2020
base-build-test:
21-
name: Base Build and Test - ${{ matrix.idris-version }}
21+
name: Base Build & Test - ${{ matrix.idris-version }}
2222
strategy:
2323
matrix:
2424
idris-version: ["v0.5.1", "v0.6.0", "v0.7.0", "latest"]
@@ -43,15 +43,13 @@ jobs:
4343
secrets: inherit
4444

4545
devcontainer-build-test:
46-
name: Devcontainer Build and Test - ${{ matrix.idris-lsp-version }}
46+
name: Devcontainer Build & Test - ${{ matrix.idris-lsp-version }}
4747
needs: [base-build-test] # needs cached base builds
4848
strategy:
4949
matrix:
5050
# based off of the branches in the idris-lsp repo
51-
idris-lsp-version: ["idris2-0.5.1", "idris2-0.6.0", "idris2-0.7.0", "latest"]
51+
idris-lsp-version: ["idris2-0.6.0", "idris2-0.7.0", "latest"]
5252
include:
53-
- idris-lsp-version: "idris2-0.5.1"
54-
idris-version: "v0.5.1"
5553
- idris-lsp-version: "idris2-0.6.0"
5654
idris-version: "v0.6.0"
5755
- idris-lsp-version: "idris2-0.7.0"
@@ -71,10 +69,8 @@ jobs:
7169
needs: [base-deploy, devcontainer-build-test] # needs base deployed to registry
7270
strategy:
7371
matrix:
74-
idris-lsp-version: ["idris2-0.5.1", "idris2-0.6.0", "idris2-0.7.0", "latest"]
72+
idris-lsp-version: ["idris2-0.6.0", "idris2-0.7.0", "latest"]
7573
include:
76-
- idris-lsp-version: "idris2-0.5.1"
77-
idris-version: "v0.5.1"
7874
- idris-lsp-version: "idris2-0.6.0"
7975
idris-version: "v0.6.0"
8076
- idris-lsp-version: "idris2-0.7.0"

.github/workflows/version-base-build-test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ jobs:
7777
env:
7878
LIB_PATH: ${{ github.workspace }}/.bats
7979
DOCKER_IMAGE: ${{ env.TAG }}
80+
IDRIS_VERSION: ${{ inputs.idris-version }}
8081
run: bats tests/base.bats
8182

8283
base-test-2:
@@ -106,7 +107,7 @@ jobs:
106107
# "consumer" images just "consume" the base image and do nothing else
107108
# basic tests for these
108109
consumer-build-test:
109-
name: Build Consumer - ${{ matrix.dockerfile }}
110+
name: Build Consumer
110111
runs-on: ubuntu-latest
111112
needs: [base-test-1, base-test-2]
112113
strategy:
@@ -171,4 +172,5 @@ jobs:
171172
env:
172173
LIB_PATH: ${{ github.workspace }}/.bats
173174
DOCKER_IMAGE: ${{ env.TAG }}
175+
IDRIS_VERSION: ${{ inputs.idris-version }}
174176
run: bats tests/consumer-idris.bats

.github/workflows/version-base-deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ permissions:
1313

1414
jobs:
1515
deploy-base:
16-
name: Deploy Base - ${{ inputs.idris-version }}
16+
name: Deploy Base
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Checkout Repo
@@ -55,7 +55,7 @@ jobs:
5555
platforms: linux/amd64,linux/arm64
5656

5757
deploy-consumers:
58-
name: Deploy Consumer - ${{ matrix.dockerfile }} ${{ inputs.idris-version }}
58+
name: Deploy Consumer
5959
runs-on: ubuntu-latest
6060
strategy:
6161
matrix:

.github/workflows/version-devcontainer-build-test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ permissions:
1616

1717
jobs:
1818
devcontainer-build-test:
19-
name: Build Devcontainer - ${{ inputs.idris-lsp-version }}
19+
name: Build & Test
2020
runs-on: ubuntu-latest
2121
services:
2222
registry:
@@ -72,4 +72,5 @@ jobs:
7272
env:
7373
LIB_PATH: ${{ github.workspace }}/.bats
7474
DOCKER_IMAGE: ${{ env.TAG }}
75+
IDRIS_VERSION: ${{ inputs.idris-version }}
7576
run: bats tests/devcontainer-idris.bats

.github/workflows/version-devcontainer-deploy.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ permissions:
1616

1717
jobs:
1818
deploy-devcontainer:
19-
name: Deploy Devcontainer - ${{ inputs.idris-lsp-version }}
19+
name: Deploy
2020
runs-on: ubuntu-latest
2121
steps:
2222
- name: Checkout Repo
@@ -42,10 +42,6 @@ jobs:
4242
username: ${{ github.actor }}
4343
password: ${{ secrets.GITHUB_TOKEN }}
4444

45-
- name: Get Latest Idris Commit SHA
46-
id: get-sha
47-
uses: ./.github/actions/get-idris-sha
48-
4945
- name: Docker meta
5046
id: create-meta
5147
uses: docker/metadata-action@v5

scripts/build-image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def build_image_sha(image: str, sha_info: dict, idris_base_version: str, tag: st
8383

8484
if args.version and args.version != 'latest':
8585
# Build versioned image.
86-
dockerfile = f'{parser.image}.Dockerfile'
87-
tag = f'{parser.image}-{parser.version}' if not args.tag else args.tag
86+
dockerfile = f'{args.image}.Dockerfile'
87+
tag = f'{args.image}-{args.version}' if not args.tag else args.tag
8888
print(f'Building {dockerfile} with tag {tag}')
8989

9090
# build image

scripts/install-chezscheme-arch.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22

3+
set -o errexit # abort on nonzero exitstatus
4+
set -o nounset # abort on unbound variable
5+
set -o pipefail # don't hide errors within pipes
6+
37
# installs chez scheme from source for aarch based systems
48
# https://github.com/racket/ChezScheme/blob/master/BUILDING
59

scripts/install-idris-lsp.sh

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,50 @@
1+
#!/bin/bash
2+
3+
set -o errexit # abort on nonzero exitstatus
4+
set -o nounset # abort on unbound variable
5+
set -o pipefail # don't hide errors within pipes
6+
17
# Given a cloned idris LSP repo, install the lsp server
28
# distinguishes between the "old" repo (pre 0.5.1) and the new one
39

410
# Also assumes that PATH and LD_LIBRARY_PATH are set correctly
511

12+
613
if [ -z ${IDRIS_LSP_VERSION+x} ]; then
714
echo "IDRIS LSP VAR IS UNSET!";
815
exit 1;
916
else
1017
echo "LSP Version is set to '$IDRIS_LSP_VERSION'";
1118
fi
1219

20+
# Reinstall Idris2
21+
# https://github.com/idris-community/idris2-lsp/tree/idris2-0.6.0
22+
# I think this is similar across all versions, but I need to test with 0.4.0 and 0.5.1
23+
cd /build/idris2-lsp/Idris2
24+
make bootstrap SCHEME=scheme PREFIX=/usr/local/lib/idris2
25+
make install PREFIX=/usr/local/lib/idris2
26+
27+
make clean PREFIX=/usr/local/lib/idris2
28+
make all PREFIX=/usr/local/lib/idris2
29+
make install PREFIX=/usr/local/lib/idris2
30+
make install-with-src-libs PREFIX=/usr/local/lib/idris2
31+
make install-with-src-api PREFIX=/usr/local/lib/idris2
32+
1333
# check if the version is "idris2-0.4.0" or "idris2-0.5.1"
1434
# these are the "older" supported versions, before the idris2-lsp repo was split a reusable LSP-lib
15-
if [[ $IDRIS_LSP_VERSION == "idris2-0.4.0" ]] || [[ $IDRIS_LSP_VERSION == "idris2-0.5.1" ]]; then
35+
if [[ $IDRIS_LSP_VERSION == "idris2-0.4.0" ]] ||
36+
[[ $IDRIS_LSP_VERSION == "idris2-0.5.1" ]] ||
37+
[[ $IDRIS_LSP_VERSION == "idris2-0.6.0" ]]; then
1638
echo "Installing older version of idris2-lsp"
17-
18-
# Manual install of idris2-lsp (no need to rebuild idris)
39+
40+
# Manual install of idris2-lsp
1941
cd /build/idris2-lsp
2042
make install PREFIX=/usr/local/lib/idris2
2143
else
2244
# if the idris version is not one of the "old" ones, it is either a newer version (0.6.0 and up) or "latest"d
2345
echo "Installing newer version of idris2-lsp"
2446

25-
# rebuild idris2
26-
cd /build/idris2-lsp/Idris2
27-
make clean PREFIX=/usr/local/lib/idris2
28-
make all PREFIX=/usr/local/lib/idris2
29-
make install PREFIX=/usr/local/lib/idris2
30-
make install-with-src-libs PREFIX=/usr/local/lib/idris2
31-
make install-with-src-api PREFIX=/usr/local/lib/idris2
32-
33-
3447
# Manually install LSP library and idris2-lsp
35-
cd /build/idris2-lsp
36-
git submodule update --init LSP-lib
3748
cd /build/idris2-lsp/LSP-lib
3849
idris2 --install-with-src
3950
cd /build/idris2-lsp

tests/base.bats

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,17 @@ function setup() {
3737
# the ENTRYPOINT is already the `idris2` command, so we just `docker run` without any other stuff
3838
run docker run $DOCKER_IMAGE idris2
3939
refute_output --partial "Uncaught error:"
40+
}
41+
42+
@test "Check environment variables" {
43+
# make sure IDRIS_SHA is set
44+
# https://bats-core.readthedocs.io/en/stable/writing-tests.html#run-test-other-commands
45+
# expects the cmd to return 0
46+
if [[ $IDRIS_VERSION != "latest" ]]; then
47+
# For versions that are not latest, IDRIS_VERSION should be set
48+
docker run $DOCKER_IMAGE bash -c "if [[ -z \$IDRIS_VERSION ]]; then exit 1; else exit 0; fi"
49+
else
50+
# For latest, IDRIS_SHA should be set
51+
docker run $DOCKER_IMAGE bash -c "if [[ -z \$IDRIS_SHA ]]; then exit 1; else exit 0; fi"
52+
fi
4053
}

0 commit comments

Comments
 (0)