Skip to content

Commit

Permalink
Parallelise workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucsanszky committed Aug 30, 2024
1 parent 0d0c26e commit 9ff3999
Showing 1 changed file with 49 additions and 16 deletions.
65 changes: 49 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand All @@ -61,54 +60,88 @@ 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: |
echo "** Generated PDF files:"; find -L docs/ -name '*.pdf'
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/[email protected]
Expand Down

0 comments on commit 9ff3999

Please sign in to comment.