Skip to content

[FIX] CARDANO_NODE_VERSION environment variable isn't overwritten #185

[FIX] CARDANO_NODE_VERSION environment variable isn't overwritten

[FIX] CARDANO_NODE_VERSION environment variable isn't overwritten #185

Workflow file for this run

name: Pre-merge
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to test'
required: true
pull_request:
paths:
- scripts/cnode-helper-scripts/guild-deploy.sh
- scripts/cnode-helper-scripts/cabal-build-all.sh
- files/tests/pre-merge/ubuntu-guild-deploy.sh.containerfile
jobs:
guild-deploy-and-build:
runs-on: ubuntu-latest
strategy:
matrix:
distro: [rockylinux, ubuntu]
env:
REGISTRY: ghcr.io
BRANCH: ${{ github.event.inputs.branch || github.head_ref }}
if: github.event.pull_request.draft == false
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 30720
swap-size-mb: 1024
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: ' true'
remove-codeql: 'true'
- name: Provide additional free space
run: |
# Workaround to provide additional free space for builds
# https://github.com/actions/virtual-environments/issues/2840
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/local/share/boost "$AGENT_TOOLSDIRECTORY"
df -h
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
- name: Define BRANCH, COMMIT_SHA and G_ACCOUNT in environment
run: |
echo "IS_FORK=${{ github.event.pull_request.head.repo.fork }}" >> $GITHUB_ENV
echo "FORK_OWNER=${{ github.event.pull_request.head.repo.owner.login }}" >> $GITHUB_ENV
echo "G_ACCOUNT=${{ github.repository_owner }}" >> $GITHUB_ENV
echo "COMMIT_SHA=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
- name: Setup G_ACCOUNT based on fork status
run: |
if [ "$IS_FORK" = "true" ]; then
echo "This means the PR is from a fork"
echo "BUILD_G_ACCOUNT=${{ github.event.pull_request.head.repo.owner.login }}" >> $GITHUB_ENV
else
echo "This means the PR is from the same repository"
echo "BUILD_G_ACCOUNT=${{ github.repository_owner }}" >> $GITHUB_ENV
fi
- name: Testing guild-deploy.sh (with libsodium)
run: |
docker build . \
--file files/tests/pre-merge/${{ matrix.distro }}-guild-deploy.sh.containerfile \
--compress \
--build-arg BRANCH=$BRANCH \
--build-arg COMMIT=$COMMIT_SHA \
--build-arg G_ACCOUNT=${{ env.BUILD_G_ACCOUNT }} \
--tag $REGISTRY/${{ env.G_ACCOUNT }}/pre-merge-${{ matrix.distro }}:guild-deploy-l_$COMMIT_SHA
- name: Get Image ID
run: |
PREMERGE_IMAGE_ID1=$(docker inspect ${{ env.REGISTRY }}/${{ env.G_ACCOUNT }}/pre-merge-${{ matrix.distro }}:guild-deploy-l_${{ env.COMMIT_SHA }} --format='{{.Id}}')
echo "PREMERGE_IMAGE_ID1=${PREMERGE_IMAGE_ID1}" >> $GITHUB_ENV
- name: Push pre-merge-${{ matrix.distro }}:guild-deploy-l_${{ env.COMMIT_SHA }}
run: |
docker push ${{ env.REGISTRY }}/${{ env.G_ACCOUNT }}/pre-merge-${{ matrix.distro }}:guild-deploy-l_${{ env.COMMIT_SHA }}
- name: Testing cabal-build-all.sh (with libsodium)
run: |
echo "Working from PR Branch ${{ env.G_ACCOUNT }}/guild-operators/${{ env.BRANCH }} on COMMIT_SHA ${{ env.COMMIT_SHA }}"
docker build . \
--file files/tests/pre-merge/${{ matrix.distro }}-cabal.containerfile \
--compress \
--build-arg BRANCH=${{ env.BRANCH }} \
--build-arg COMMIT=${{ env.COMMIT_SHA }} \
--build-arg G_ACCOUNT=${{ env.BUILD_G_ACCOUNT }} \
--tag ${{ env.REGISTRY }}/${{ env.G_ACCOUNT }}/pre-merge-${{ matrix.distro }}:cabal-l_${{ env.COMMIT_SHA }}
- name: Get Versions and Image ID
run: |
VERSION_DETAILS=($(docker run --rm ${{ env.REGISTRY }}/${{ env.G_ACCOUNT }}/pre-merge-${{ matrix.distro }}:cabal-l_${{ env.COMMIT_SHA }} cardano-node --version | awk '/^cardano-node/'))
PREMERGE_IMAGE_ID2=$(docker inspect ${{ env.REGISTRY }}/${{ env.G_ACCOUNT }}/pre-merge-${{ matrix.distro }}:cabal-l_${{ env.COMMIT_SHA }} --format='{{.Id}}')
echo "CARDANO_NODE_VERSION=${VERSION_DETAILS[1]}" >> $GITHUB_ENV
echo "GHC_VERSION=${VERSION_DETAILS[5]}" >> $GITHUB_ENV
echo "PREMERGE_IMAGE_ID2=${PREMERGE_IMAGE_ID2}" >> $GITHUB_ENV
- name: Push pre-merge-${{ matrix.distro }}:cabal-l_${{ env.COMMIT_SHA }}
run: |
docker push ${{ env.REGISTRY }}/${{ env.G_ACCOUNT }}/pre-merge-${{ matrix.distro }}:cabal-l_${{ env.COMMIT_SHA }}
- name: Add summary details
if: always()
run: |
echo "## Pre-Merge Summary Details" >> $GITHUB_STEP_SUMMARY
echo "| Name | Value |" >> $GITHUB_STEP_SUMMARY
echo "| ---- | ----- |" >> $GITHUB_STEP_SUMMARY
echo "| Guild Deploy Image | ${{ env.REGISTRY }}/${{ env.G_ACCOUNT }}/pre-merge-${{ matrix.distro }}:guild-deploy-l_${{ env.COMMIT_SHA }} |" >> $GITHUB_STEP_SUMMARY
echo "| Guild Deploy Image ID | ${{ env.PREMERGE_IMAGE_ID1 }} |" >> $GITHUB_STEP_SUMMARY
echo "| Cabal Build Image | ${{ env.REGISTRY }}/${{ env.G_ACCOUNT }}/pre-merge-${{ matrix.distro }}:cabal-l_${{ env.COMMIT_SHA }} |" >> $GITHUB_STEP_SUMMARY
echo "| Cabal Build Image ID | ${{ env.PREMERGE_IMAGE_ID2 }} |" >> $GITHUB_STEP_SUMMARY
echo "| G_ACCOUNT | ${{ env.G_ACCOUNT }} |" >> $GITHUB_STEP_SUMMARY
echo "| BRANCH | ${{ env.BRANCH }} |" >> $GITHUB_STEP_SUMMARY
echo "| COMMIT_SHA | ${{ env.COMMIT_SHA }} |" >> $GITHUB_STEP_SUMMARY
echo "| CARDANO_NODE_VERSION | ${{ env.CARDANO_NODE_VERSION }} |" >> $GITHUB_STEP_SUMMARY
echo "| GHC_VERSION | ${{ env.GHC_VERSION }} |" >> $GITHUB_STEP_SUMMARY