Skip to content

Update main.yml

Update main.yml #333

Workflow file for this run

name: Prebuild DevX closures
on:
push:
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
DEFAULT_TAG: latest
GH_TOKEN: ${{ github.token }}
jobs:
# wait-for-hydra-eval:
# env:
# GH_TOKEN: ${{ github.token }}
# name: "Wait for hydra status"
# runs-on: ubuntu-latest
# steps:
# - uses: input-output-hk/actions/wait-for-hydra@latest
# with:
# check: required
discover:
# needs: wait-for-hydra-eval
name: Discover
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: fetch all ci/hydra-build jobs
id: set-matrix
run: |
# Group the output by platform.
curl -L https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux64 -o jq
chmod +x jq
./jq --version
CHECK_RUNS=$(gh api "repos/$GITHUB_REPOSITORY/commits/main/check-runs" --paginate)
echo "checks..."
FILTERED=$(./jq -c -r '.check_runs[] | select(.name | endswith("-env")) | { "config": .name, "build_path": .output.text }' <<< "$CHECK_RUNS")
echo "filtered..."
./jq -e . <<< "$FILTERED"
GROUPS=$(./jq --slurp -c -r '. as $jobs | map(.config | split(".") | first) | unique | map(. as $group | {"platform": $group, "jobs": $jobs | map(select(.config |startswith($group)))})' <<< "$FILTERED")
echo "groups..."
if ./jq -e . <<< "$GROUPS" > /dev/null 2>&1; then # JSON validation
echo "Valid JSON"
else
echo "Invalid JSON: $GROUPS"
exit 1 # or handle the error appropriately
fi
echo "creating result matrix."
echo "matrix=$GROUPS" >> $GITHUB_OUTPUT
# We need this process step in here, because we have in excess of 256 jobs.
process:
needs: discover
runs-on: ubuntu-latest # You still need runs-on to define a job, but it can be minimal
strategy:
fail-fast: false
matrix:
group: ${{ fromJson(needs.discover.outputs.matrix) }}
name: Process Jobs for ${{ matrix.group.platform }}
outputs:
jobs: ${{ toJson(matrix.group.jobs) }} # Direct output definition
steps:
- name: No-op step (required to have at least one step)
run: echo "No-op" # Minimal step to satisfy step requirement
ghcr-upload:
needs: process
name: Container Upload
strategy:
fail-fast: false
matrix:
job: ${{ fromJson(needs.process.outputs.matrix) }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
- name: Install Nix with good defaults
uses: cachix/install-nix-action@v20
with:
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk=
substituters = https://cache.iog.io/ https://cache.zw3rk.com/ https://cache.nixos.org/
nix_path: nixpkgs=channel:nixos-unstable
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute and upload closure and developer environment to ghcr.io
env:
DEV_SHELL: ${{ matrix.job.config }}
SHELL_NIX_PATH: ${{ matrix.job.build_path }}
NIX_STORE_SECRET_KEY: ${{ secrets.SECRET_KEY }}
run: ./extra/ghcr-upload.sh
# codespace-upload:
# env:
# IMAGE_NAME: input-output-hk/devx-devcontainer
# needs: ghcr-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: false
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Log in to the Container registry
# uses: docker/[email protected]
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Build and push Docker image
# uses: docker/build-push-action@v4
# with:
# context: .
# push: true
# 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 }}
# VARIANT=${{ inputs.variant }}
# IOG=${{ inputs.iog }}
# - 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 }}${{ inputs.variant }}${{ inputs.iog }} \
# bash -ic "cabal update && cabal unpack hello && cd hello-* && cabal build"