From 9ff39990832a085d7eb5bb966ea9a2d33ac10abc Mon Sep 17 00:00:00 2001 From: Lucsanszky Date: Fri, 30 Aug 2024 15:34:22 +0200 Subject: [PATCH] Parallelise workflow --- .github/workflows/build.yml | 65 ++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a12c60e64..f68ff5eff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,44 +14,43 @@ env: MAlonzo_branch: ${{ github.event.pull_request.head.ref }}-MAlonzo jobs: - build: + setup: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 with: ref: MAlonzo-code - - name: Create branch ${{ env.MAlonzo_branch }} for generated code if: github.event_name == 'pull_request' && github.event.action == 'opened' run: | git checkout -b ${{ env.MAlonzo_branch }} origin/MAlonzo-code git push origin ${{ env.MAlonzo_branch }} + MAlonzo: + needs: setup + runs-on: ubuntu-latest + steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v20 with: nix_path: nixpkgs=channel:nixos-unstable extra_nix_config: | trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= substituters = https://cache.iog.io https://cache.nixos.org/ - - - name: Configure git - run: | - git config user.name 'github-actions[bot]' - git config user.email 'github-actions[bot]@users.noreply.github.com' - - name: Commit generated code at ${{ env.MAlonzo_branch }} if: github.ref != 'refs/heads/master' run: | + ls -la nix-build -A ledger.hsSrc -j1 -o outputs/MAlonzo + ls -la + # TODO: factor out + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' git stash push git fetch origin ${{ env.MAlonzo_branch }} --unshallow git checkout ${{ env.MAlonzo_branch }} rsync -r --exclude={'**/nix-support','**/lib'} outputs/MAlonzo/haskell/Ledger/* generated/ git add -f generated && git commit -m "Generate code for ${{ github.sha }}" || echo "Everything is up-to-date." - - name: Push ${{ env.MAlonzo_branch }} if: github.ref != 'refs/heads/master' uses: ad-m/github-push-action@v0.6.0 @@ -61,40 +60,73 @@ jobs: force: false directory: . + Formal-Ledger: + needs: setup + runs-on: ubuntu-latest + steps: - uses: actions/checkout@v4 - + - uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + substituters = https://cache.iog.io https://cache.nixos.org/ - name: Build formalLedger id: formalLedger run: | nix-build -A formalLedger -j1 -o outputs/formalLedger rsync -r --include={'**/*.time'} outputs/formalLedger*/* docs/ + Ledger: + needs: setup + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + substituters = https://cache.iog.io https://cache.nixos.org/ - name: Build ledger id: ledger run: | nix-build -A ledger -j1 -o outputs/ledger rsync -r --exclude={'**/nix-support','**/lib'} outputs/ledger*/* docs/ + Midnight: + needs: setup + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + substituters = https://cache.iog.io https://cache.nixos.org/ - name: Build midnight id: midnight run: | nix-build -A midnight -j1 -o outputs/midnight rsync -r --exclude={'**/nix-support','**/lib'} outputs/midnight*/* docs/ + Uploads: + needs: [Formal-Ledger, Ledger, Midnight] + runs-on: ubuntu-latest + steps: - name: Upload PDF artifacts if: github.event_name == 'pull_request' uses: actions/upload-artifact@v4 with: name: PDF specs path: docs/pdfs/*.pdf - - name: Upload typechecking times if: github.event_name == 'pull_request' uses: actions/upload-artifact@v4 with: name: Typechecking durations path: docs/*.time - - name: Generate main website if: github.ref == 'refs/heads/master' run: | @@ -102,13 +134,14 @@ jobs: echo "** Generated HTML files:"; find -L docs/ -name '*.html' echo "** Generated Haskell files:"; find -L docs/ -name '*.hs' OUT_DIR=../docs/ make staticWebsite - - name: Add files if: github.ref == 'refs/heads/master' run: | + # TODO: factor out + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' git add -f docs/ git commit -m "Updated for ${{ github.sha }}" - - name: Push to gh-pages if: github.ref == 'refs/heads/master' uses: ad-m/github-push-action@v0.6.0