Skip to content

Commit 5a909ef

Browse files
committed
Adds GHC compilation CI stage
1 parent 5755cea commit 5a909ef

5 files changed

Lines changed: 78 additions & 13 deletions

File tree

.github/workflows/ghc.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: "GHC images"
2+
3+
on:
4+
# FIXME: Remove this before merging!
5+
pull_request: { branches: [ "master" ] }
6+
push: { branches: [ "release" ] }
7+
8+
env:
9+
alpine_ver: "3.14"
10+
11+
jobs:
12+
build:
13+
runs-on: "ubuntu-20.04"
14+
15+
strategy:
16+
matrix:
17+
ghc_ver: [ "8.10.7" ]
18+
numeric: [ "gmp" ]
19+
20+
steps:
21+
- name: "Check this repository out."
22+
uses: "actions/checkout@v2"
23+
24+
- name: "Pull `ghcup` image."
25+
run: |
26+
# TODO: Avoid having to specify a ghcup version here...
27+
buildah pull docker://ghcr.io/jkachmar/ghcup:0.1.17.2
28+
29+
- name: "Compile GHC and publish an image from the resulting container."
30+
id: "build-image"
31+
run: |
32+
image_id=$(
33+
./ghc/builder.sh \
34+
-a "${{ env.alpine_ver }}" \
35+
-g "${{ matrix.ghc_ver }}" \
36+
-n "${{ matrix.numeric }}" \
37+
| tail -n 1
38+
)
39+
40+
image_name=$(
41+
buildah images --format "{{.Name}}" ${image_id}
42+
)
43+
# NOTE: This parameter expansion drops the leading `localhost/` that
44+
# `buildah` (and other OCI tools) prepend to local image names.
45+
echo "::set-output name=image_name::${image_name#*/}"
46+
47+
image_tags=$(
48+
buildah images --format "{{.Tag}}" ${image_id}
49+
)
50+
echo "::set-output name=image_tags::${image_tags}"
51+
52+
- name: "Push compiled GHC image to the GitHub Container Registry."
53+
id: "push-to-ghcr"
54+
uses: "redhat-actions/push-to-registry@v2"
55+
with:
56+
image: "${{ steps.build-image.outputs.image_name }}"
57+
tags: "${{ steps.build-image.outputs.image_tags }}"
58+
registry: "ghcr.io/${{ github.repository_owner }}"
59+
username: "${{ github.actor }}"
60+
password: "${{ github.token }}"
61+
62+
- name: "Print image URL."
63+
run: |
64+
echo "Image pushed to ${{ steps.push-to-ghcr.outputs.registry-paths }}"

.github/workflows/ghcup.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name: "`ghcup` image"
22

3+
# FIXME: Re-enable this workflow before merging!
34
on:
45
# FIXME: Remove this before merging!
5-
pull_request: { branches: [ "master" ] }
6-
push: { branches: [ "release" ] }
6+
# pull_request: { branches: [ "master" ] }
7+
# push: { branches: [ "release" ] }
78

89
env:
910
alpine_ver: "3.14"
@@ -16,8 +17,8 @@ jobs:
1617
- name: "Check this repository out."
1718
uses: "actions/checkout@v2"
1819

19-
- name: "Build `ghcup` image."
20-
id: "build-ghcup-image"
20+
- name: "Download `ghcup` and publish an image containing it."
21+
id: "build-image"
2122
run: |
2223
image_id=$(
2324
./ghcup/builder.sh \
@@ -29,7 +30,6 @@ jobs:
2930
image_name=$(
3031
buildah images --format "{{.Name}}" ${image_id}
3132
)
32-
3333
# NOTE: This parameter expansion drops the leading `localhost/` that
3434
# `buildah` (and other OCI tools) prepend to local image names.
3535
echo "::set-output name=image_name::${image_name#*/}"
@@ -40,15 +40,15 @@ jobs:
4040
echo "::set-output name=image_tags::${image_tags}"
4141
4242
- name: "Push `ghcup` image to the GitHub Container Registry"
43-
id: "push-ghcup-to-ghcr"
43+
id: "push-to-ghcr"
4444
uses: "redhat-actions/push-to-registry@v2"
4545
with:
46-
image: "${{ steps.build-ghcup-image.outputs.image_name }}"
47-
tags: "${{ steps.build-ghcup-image.outputs.image_tags }}"
46+
image: "${{ steps.build-image.outputs.image_name }}"
47+
tags: "${{ steps.build-image.outputs.image_tags }}"
4848
registry: "ghcr.io/${{ github.repository_owner }}"
4949
username: "${{ github.actor }}"
5050
password: "${{ github.token }}"
5151

5252
- name: "Print image URL."
5353
run: |
54-
echo "Image pushed to ${{ steps.push-ghcup-to-ghcr.outputs.registry-paths }}"
54+
echo "Image pushed to ${{ steps.push-to-ghcr.outputs.registry-paths }}"

ghc/builder.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fi
8080

8181
# Add the GHC version and numeric library to container and image names.
8282
container="${container}-${numeric}-${ghc_ver}"
83-
image="${image}-${numeric}:${ghc_ver}"
83+
image="${image}-${numeric}"
8484

8585
################################################################################
8686
# Container.
@@ -201,4 +201,4 @@ buildah config \
201201
# TMPDIR=./tmp \
202202
buildah \
203203
--signature-policy=./policy.json \
204-
commit --rm "${container}" "${image}"
204+
commit "${container}" "${image}:${ghc_ver}"

ghcup/builder.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ buildah config \
130130
# NOTE: Tagging the image with the `ghcup_version` for convenience.
131131
buildah \
132132
--signature-policy=./policy.json \
133-
commit --rm "${container}" "${image}:${ghcup_version}"
133+
commit "${container}" "${image}:${ghcup_version}"

policy.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"default": [{"type": "reject"}],
33
"transports": {
44
"docker": {
5-
"docker.io/library/alpine": [{"type": "insecureAcceptAnything"}]
5+
"docker.io/library/alpine": [{"type": "insecureAcceptAnything"}],
6+
"ghcr.io/jkachmar/ghcup": [{"type": "insecureAcceptAnything"}]
67
},
78
"dir": {
89
"": [{"type": "insecureAcceptAnything"}]

0 commit comments

Comments
 (0)