mirror of
https://github.com/input-output-hk/devx.git
synced 2024-10-26 04:08:39 +03:00
Refactor wait-and-upload
GitHub Action (#144)
This commit is contained in:
parent
ce013269ab
commit
b37cc6f3d4
5
.github/workflows/main.yml
vendored
5
.github/workflows/main.yml
vendored
@ -87,6 +87,5 @@ jobs:
|
|||||||
platform: ${{ matrix.platform }}
|
platform: ${{ matrix.platform }}
|
||||||
target-platform: ${{ matrix.target-platform }}
|
target-platform: ${{ matrix.target-platform }}
|
||||||
compiler-nix-name: ${{ matrix.compiler-nix-name }}
|
compiler-nix-name: ${{ matrix.compiler-nix-name }}
|
||||||
minimal: ${{ matrix.variant == '-minimal' }}
|
variant: ${{ matrix.variant }}
|
||||||
iog: ${{ matrix.iog == '-iog' }}
|
iog: ${{ matrix.iog }}
|
||||||
iog-full: ${{ matrix.iog == '-iog-full' }}
|
|
||||||
|
56
.github/workflows/wait-and-upload.yml
vendored
56
.github/workflows/wait-and-upload.yml
vendored
@ -15,23 +15,19 @@ on:
|
|||||||
required: true
|
required: true
|
||||||
description: 'compiler name in nix format. e.g. ghc96'
|
description: 'compiler name in nix format. e.g. ghc96'
|
||||||
type: string
|
type: string
|
||||||
minimal:
|
variant:
|
||||||
description: 'without hls, hlint, ...'
|
description: 'if set to `minimal` without hls, hlint, ...'
|
||||||
type: boolean
|
type: string
|
||||||
default: true
|
default: ''
|
||||||
iog:
|
iog:
|
||||||
description: 'with iog libs: libsodium, libsecp256k1, libblst, ...'
|
description: 'if set to `-iog` with libs `libsodium`, `libsecp256k1`, `libblst`, ... and if set to `-iog-full` adds `postgresql` and `R`'
|
||||||
type: boolean # FIXME: this should rather be a 'string' that could be set to 'full' ...
|
type: string
|
||||||
default: false
|
default: ''
|
||||||
iog-full:
|
|
||||||
description: 'with full iog libs: libsodium, libsecp256k1, libblst, postgresql, R, ...'
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
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
|
DEFAULT_TAG: latest
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
|
||||||
@ -120,7 +116,7 @@ jobs:
|
|||||||
# Likely, we consider using `-iog` as the default and do not generate other images.
|
# 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,
|
# Then the user choices left would be between native, `-windows` or `-js` target platforms,
|
||||||
# and the GHC version (currently `ghc810` and `ghc96`).
|
# 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:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@ -137,42 +133,14 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
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: |
|
build-args: |
|
||||||
PLATFORM=${{ inputs.platform }}
|
PLATFORM=${{ inputs.platform }}
|
||||||
TARGET_PLATFORM=${{ inputs.target-platform }}
|
TARGET_PLATFORM=${{ inputs.target-platform }}
|
||||||
COMPILER_NIX_NAME=${{ inputs.compiler-nix-name }}
|
COMPILER_NIX_NAME=${{ inputs.compiler-nix-name }}
|
||||||
MINIMAL=${{ inputs.minimal }}
|
VARIANT=${{ inputs.variant }}
|
||||||
IOG=${{ inputs.iog }}
|
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
|
- 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"
|
/bin/bash -c "cabal update && cabal unpack hello && cd hello-* && cabal build"
|
||||||
|
11
Dockerfile
11
Dockerfile
@ -9,20 +9,15 @@ WORKDIR /workspaces
|
|||||||
ARG PLATFORM="x86_64-linux"
|
ARG PLATFORM="x86_64-linux"
|
||||||
ARG TARGET_PLATFORM=""
|
ARG TARGET_PLATFORM=""
|
||||||
ARG COMPILER_NIX_NAME="ghc96"
|
ARG COMPILER_NIX_NAME="ghc96"
|
||||||
ARG MINIMAL="false"
|
ARG VARIANT=""
|
||||||
ARG IOG="true"
|
ARG IOG="-iog"
|
||||||
ARG IOG_FULL="false"
|
|
||||||
|
|
||||||
RUN DEBIAN_FRONTEND=noninteractive \
|
RUN DEBIAN_FRONTEND=noninteractive \
|
||||||
&& apt-get update \
|
&& apt-get update \
|
||||||
&& apt-get -y install curl gh git grep jq nix rsync zstd \
|
&& 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 \
|
&& 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 \
|
&& chmod +x fetch-docker.sh \
|
||||||
&& SUFFIX='' \
|
&& ./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
|
||||||
&& 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
|
|
||||||
|
|
||||||
RUN cat <<EOF >> $HOME/.bashrc
|
RUN cat <<EOF >> $HOME/.bashrc
|
||||||
source $(grep -m 1 -e '-env.sh$' store-paths.txt)
|
source $(grep -m 1 -e '-env.sh$' store-paths.txt)
|
||||||
|
Loading…
Reference in New Issue
Block a user