Refactor wait-and-upload GitHub Action (#144)

This commit is contained in:
Yvan Sraka 2024-04-13 10:06:14 +02:00 committed by GitHub
parent ce013269ab
commit b37cc6f3d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 55 deletions

View File

@ -87,6 +87,5 @@ jobs:
platform: ${{ matrix.platform }}
target-platform: ${{ matrix.target-platform }}
compiler-nix-name: ${{ matrix.compiler-nix-name }}
minimal: ${{ matrix.variant == '-minimal' }}
iog: ${{ matrix.iog == '-iog' }}
iog-full: ${{ matrix.iog == '-iog-full' }}
variant: ${{ matrix.variant }}
iog: ${{ matrix.iog }}

View File

@ -15,23 +15,19 @@ on:
required: true
description: 'compiler name in nix format. e.g. ghc96'
type: string
minimal:
description: 'without hls, hlint, ...'
type: boolean
default: true
variant:
description: 'if set to `minimal` without hls, hlint, ...'
type: string
default: ''
iog:
description: 'with iog libs: libsodium, libsecp256k1, libblst, ...'
type: boolean # FIXME: this should rather be a 'string' that could be set to 'full' ...
default: false
iog-full:
description: 'with full iog libs: libsodium, libsecp256k1, libblst, postgresql, R, ...'
type: boolean
default: false
description: 'if set to `-iog` with libs `libsodium`, `libsecp256k1`, `libblst`, ... and if set to `-iog-full` adds `postgresql` and `R`'
type: string
default: ''
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
DEV_SHELL: ${{ inputs.platform }}.${{ inputs.compiler-nix-name }}${{ inputs.target-platform }}${{ inputs.minimal && '-minimal' || '' }}${{ (inputs.iog-full && '-iog-full') || (inputs.iog && '-iog') || ''}}-env
DEV_SHELL: ${{ inputs.platform }}.${{ inputs.compiler-nix-name }}${{ inputs.target-platform }}${{ inputs.variant }}${{ inputs.iog }}-env
DEFAULT_TAG: latest
GH_TOKEN: ${{ github.token }}
@ -120,7 +116,7 @@ jobs:
# Likely, we consider using `-iog` as the default and do not generate other images.
# Then the user choices left would be between native, `-windows` or `-js` target platforms,
# and the GHC version (currently `ghc810` and `ghc96`).
if: ${{ contains(fromJSON('["x86_64-linux", "aarch64-linux"]'), inputs.platform) && contains(fromJson('["","-windows","-js"]'), inputs.target-platform) && contains(fromJson('["ghc810","ghc96"]'), inputs.compiler-nix-name) && !inputs.minimal && inputs.iog && !inputs.iog-full }}
if: ${{ contains(fromJSON('["x86_64-linux", "aarch64-linux"]'), inputs.platform) && contains(fromJson('["","-windows","-js"]'), inputs.target-platform) && contains(fromJson('["ghc810","ghc96"]'), inputs.compiler-nix-name) && inputs.variant == '' && inputs.iog == '-iog' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
@ -137,42 +133,14 @@ jobs:
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.platform }}.${{ inputs.compiler-nix-name }}${{ inputs.target-platform }}${{ (inputs.iog-full && '-iog-full') || (inputs.iog && '-iog') }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.platform }}.${{ inputs.compiler-nix-name }}${{ inputs.target-platform }}${{ inputs.variant }}${{ inputs.iog }}
build-args: |
PLATFORM=${{ inputs.platform }}
TARGET_PLATFORM=${{ inputs.target-platform }}
COMPILER_NIX_NAME=${{ inputs.compiler-nix-name }}
MINIMAL=${{ inputs.minimal }}
VARIANT=${{ inputs.variant }}
IOG=${{ inputs.iog }}
IOG_FULL=${{ inputs.iog-full }}
codespace-download:
env:
IMAGE_NAME: input-output-hk/devx-devcontainer
needs: codespace-upload
permissions:
packages: write
runs-on: ubuntu-latest
# We want a GitHub Codespace image for each combination of devx developer shell option.
# But, since the purpose of GitHub Codespace is to serve a complete development environment,
# the user is likely to always expect HLS (I don't see the point otherwise).
# Therefore, it doesn't seem useful to build an image on the `-minimal` flavor (without HLS),
# or the `-static` one (especially since the latter currently requires `-minimal` to work).
# Likely, we consider using `-iog` as the default and do not generate other images.
# Then the user choices left would be between native, `-windows` or `-js` target platforms,
# and the GHC version (currently `ghc810` and `ghc96`).
if: ${{ contains(fromJSON('["x86_64-linux", "aarch64-linux"]'), inputs.platform) && contains(fromJson('["","-windows","-js"]'), inputs.target-platform) && contains(fromJson('["ghc810","ghc96"]'), inputs.compiler-nix-name) && !inputs.minimal && inputs.iog }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run test command inside the Dev Container
run: docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.platform }}.${{ inputs.compiler-nix-name }}${{ inputs.target-platform }} \
run: docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.platform }}.${{ inputs.compiler-nix-name }}${{ inputs.target-platform }}${{ inputs.variant }}${{ inputs.iog }} \
/bin/bash -c "cabal update && cabal unpack hello && cd hello-* && cabal build"

View File

@ -9,20 +9,15 @@ WORKDIR /workspaces
ARG PLATFORM="x86_64-linux"
ARG TARGET_PLATFORM=""
ARG COMPILER_NIX_NAME="ghc96"
ARG MINIMAL="false"
ARG IOG="true"
ARG IOG_FULL="false"
ARG VARIANT=""
ARG IOG="-iog"
RUN DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get -y install curl gh git grep jq nix rsync zstd \
&& curl -L https://raw.githubusercontent.com/input-output-hk/actions/latest/devx/support/fetch-docker.sh -o fetch-docker.sh \
&& chmod +x fetch-docker.sh \
&& SUFFIX='' \
&& if [ "$MINIMAL" = "true" ]; then SUFFIX="${SUFFIX}-minimal"; fi \
&& if [ "$IOG" = "true" ]; then SUFFIX="${SUFFIX}-iog"; fi \
&& if [ "$IOG_FULL" = "true" ]; then SUFFIX="${SUFFIX}-full"; fi \
&& ./fetch-docker.sh input-output-hk/devx $PLATFORM.$COMPILER_NIX_NAME$TARGET_PLATFORM${SUFFIX}-env | zstd -d | nix-store --import | tee store-paths.txt
&& ./fetch-docker.sh input-output-hk/devx $PLATFORM.$COMPILER_NIX_NAME$TARGET_PLATFORM$VARIANT$IOG-env | zstd -d | nix-store --import | tee store-paths.txt
RUN cat <<EOF >> $HOME/.bashrc
source $(grep -m 1 -e '-env.sh$' store-paths.txt)