Skip to content

Commit 03919cf

Browse files
author
William DeMeo
committed
build pdf from legacy-latex and generate web site
1. **PDF Jobs (`...-pdf`)**: * removed `uses: ./.github/workflows/build_artifact.yml`; * added build steps (Nix install, `fls-shake`, upload) directly into job; * Most importantly, there are now *two* checkout steps; the first checks out current branch (`master-markdown`); the second uses `sparse-checkout` to grab *only `src` directory* from `legacy-latex` branch and places it into workspace, overwriting `src` from `master-markdown`; * When `fls-shake` runs, it uses build environment from `master-markdown` (our `flake.nix`, etc.) but operates on legacy LaTeX source. 2. **MkDocs Job (`mkdocs-site`)**: * new job runs only on pushes/PRs to `master-markdown`; * uses `_build` artifact from initial Agda compilation; * calls `nix develop .#markdown --command "cd _build/mkdocs/src && mkdocs build --site-dir ../../../site"`; * resulting `site` directory is uploaded as new artifact named `mkdocs-site`. 3. **Artifacts Job (`upload-artifacts`)**: * job now depends on new `mkdocs-site` job; * downloads the `mkdocs-site` directory along with all other artifacts and commits them to `*-artifacts` branch, integrating new website into existing artifact deployment process.
1 parent dd77353 commit 03919cf

File tree

1 file changed

+135
-40
lines changed

1 file changed

+135
-40
lines changed

.github/workflows/build.yml

Lines changed: 135 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ name: Build and upload artifacts
22
on:
33
push:
44
branches:
5-
- master
5+
# !!! now running on new markdown branch and legacy latex branch !!!
6+
- master-markdown
7+
- legacy-latex
68
pull_request:
79
branches:
8-
- master
9-
# For running the workflow manually - useful for branches without PRs, for
10-
# which CI isn't run automatically
10+
# !!! now targeting PRs against new markdown branch !!!
11+
- master-markdown
12+
# For running workflow manually (for branches w/o PRs, where CI isn't run automatically)
1113
workflow_dispatch:
1214

1315
permissions:
@@ -45,17 +47,113 @@ jobs:
4547
with:
4648
target: hs
4749

50+
# !!! Build mkdocs site from markdown files !!!
51+
mkdocs-site:
52+
needs: [formal-ledger-agda]
53+
# only run on master-markdown branch
54+
if: ${{ github.ref == 'refs/heads/master-markdown' }}
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Checkout main repository
58+
uses: actions/checkout@v4
59+
- name: Download agda _build artifact
60+
uses: actions/download-artifact@v4
61+
with:
62+
name: _build
63+
path: _build
64+
- name: Install Nix
65+
uses: cachix/install-nix-action@v31
66+
with:
67+
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/6c5963357f3c1c840201eda129a99d455074db04.tar.gz
68+
extra_nix_config: |
69+
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
70+
substituters = https://cache.iog.io https://cache.nixos.org/
71+
- name: Build MkDocs site
72+
run: |
73+
# !!! change to mkdocs src directory first !!!
74+
nix develop .#markdown --command "cd _build/mkdocs/src && mkdocs build --site-dir ../../../site"
75+
# --site-dir places output in root for upload step
76+
- name: Upload MkDocs site artifact
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: mkdocs-site
80+
path: site
81+
82+
# !!! MODIFIED PDF JOBS !!!
83+
# We now inline build steps and check out 'legacy-latex' branch to ensure PDF is
84+
# built from correct LaTeX source files.
85+
4886
cardano-ledger-pdf:
4987
needs: [formal-ledger-agda]
50-
uses: ./.github/workflows/build_artifact.yml
51-
with:
52-
target: cardano-ledger.pdf
88+
runs-on: ubuntu-latest
89+
steps:
90+
- name: Checkout repo with build scripts (e.g., master-markdown)
91+
uses: actions/checkout@v4
92+
- name: Replace src with legacy LaTeX sources
93+
uses: actions/checkout@v4
94+
with:
95+
# check out legacy-latex branch
96+
ref: 'legacy-latex'
97+
# only get 'src' directory
98+
sparse-checkout: |
99+
src
100+
sparse-checkout-cone-mode: false
101+
- name: Download agda _build artifact
102+
uses: actions/download-artifact@v4
103+
with:
104+
name: _build
105+
path: _build
106+
- name: Install Nix
107+
uses: cachix/install-nix-action@v31
108+
with:
109+
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/6c5963357f3c1c840201eda129a99d455074db04.tar.gz
110+
extra_nix_config: |
111+
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
112+
substituters = https://cache.iog.io https://cache.nixos.org/
113+
- name: Build the target cardano-ledger.pdf
114+
run: |
115+
nix develop .#default --command fls-shake --trace -j8 cardano-ledger.pdf
116+
- name: Upload cardano-ledger.pdf artifact
117+
uses: actions/upload-artifact@v4
118+
with:
119+
name: cardano-ledger.pdf
120+
path: dist
53121

54122
conway-ledger-pdf:
55123
needs: [formal-ledger-agda]
56-
uses: ./.github/workflows/build_artifact.yml
57-
with:
58-
target: conway-ledger.pdf
124+
runs-on: ubuntu-latest
125+
steps:
126+
- name: Checkout repo with build scripts (e.g., master-markdown)
127+
uses: actions/checkout@v4
128+
- name: Replace src with legacy LaTeX sources
129+
uses: actions/checkout@v4
130+
with:
131+
# check out legacy-latex branch
132+
ref: 'legacy-latex'
133+
# only get 'src' directory
134+
sparse-checkout: |
135+
src
136+
sparse-checkout-cone-mode: false
137+
- name: Download agda _build artifact
138+
uses: actions/download-artifact@v4
139+
with:
140+
name: _build
141+
path: _build
142+
- name: Install Nix
143+
uses: cachix/install-nix-action@v31
144+
with:
145+
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/6c5963357f3c1c840201eda129a99d455074db04.tar.gz
146+
extra_nix_config: |
147+
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
148+
substituters = https://cache.iog.io https://cache.nixos.org/
149+
- name: Build the target conway-ledger.pdf
150+
run: |
151+
nix develop .#default --command fls-shake --trace -j8 conway-ledger.pdf
152+
- name: Upload conway-ledger.pdf artifact
153+
uses: actions/upload-artifact@v4
154+
with:
155+
name: conway-ledger.pdf
156+
path: dist
59157

60158
html:
61159
needs: [formal-ledger-agda]
@@ -64,9 +162,9 @@ jobs:
64162
target: html
65163

66164
upload-artifacts:
67-
# This job runs only if the workflow has not been manually dispached
165+
# run only if workflow has not been manually dispached
68166
if: ${{ github.event_name != 'workflow_dispatch' }}
69-
needs: [formal-ledger-agda, hs, conway-ledger-pdf, cardano-ledger-pdf, html]
167+
needs: [formal-ledger-agda, hs, conway-ledger-pdf, cardano-ledger-pdf, html, mkdocs-site]
70168
runs-on: ubuntu-latest
71169
steps:
72170
- uses: actions/checkout@v4
@@ -77,17 +175,15 @@ jobs:
77175
run: |
78176
printf "Set the artifacts branch name.\n"
79177
if [[ -n "${{ github.event.pull_request.head.ref }}" ]]; then
80-
printf "This workflow was triggered by a PR to master\n"
178+
printf "This workflow was triggered by a PR to master-markdown\n"
81179
echo "artifacts_branch=${{ github.event.pull_request.head.ref }}-artifacts" >> $GITHUB_OUTPUT
82180
printf "artifacts_branch: %s\n" "${{ github.event.pull_request.head.ref }}-artifacts"
83181
else
84-
printf "This workflow was triggered by a push event to master\n"
85-
echo "artifacts_branch=master-artifacts" >> $GITHUB_OUTPUT
86-
printf "artifacts_branch: %s\n" "master-artifacts"
182+
# Changed default artifact branch to master-markdown-artifacts.
183+
printf "This workflow was triggered by a push event\n"
184+
echo "artifacts_branch=master-markdown-artifacts" >> $GITHUB_OUTPUT
185+
printf "artifacts_branch: %s\n" "master-markdown-artifacts"
87186
fi
88-
# Checkout env.artifacts_branch if it already exists
89-
# otherwise create a new orphan branch.
90-
# Lastly, remove all files from the repo
91187
- name: Checkout artifacts branch
92188
run: |
93189
if [[ -n "$(git ls-remote --heads origin "${ARTIFACTS_BRANCH}")" ]]; then
@@ -113,30 +209,30 @@ jobs:
113209
<meta name="Author" content="IOHK">
114210
<title>Formal Ledger Specifications</title>
115211
<style type="text/css">
116-
BODY { font-family : monospace, sans-serif; color: black;}
117-
P { font-family : monospace, sans-serif; color: black; margin:0px; padding: 0px;}
118-
A:visited { text-decoration : none; margin : 0px; padding : 0px;}
119-
A:link { text-decoration : none; margin : 0px; padding : 0px;}
120-
A:hover { text-decoration: underline; background-color : yellow; margin : 0px; padding : 0px;}
121-
A:active { margin : 0px; padding : 0px;}
122-
.VERSION { font-size: small; font-family : arial, sans-serif; }
212+
BODY { font-family : monospace, sans-serif; color: black;}
213+
P { font-family : monospace, sans-serif; color: black; margin:0px; padding: 0px;}
214+
A:visited { text-decoration : none; margin : 0px; padding : 0px;}
215+
A:link { text-decoration : none; margin : 0px; padding : 0px;}
216+
A:hover { text-decoration: underline; background-color : yellow; margin : 0px; padding : 0px;}
217+
A:active { margin : 0px; padding : 0px;}
218+
.VERSION { font-size: small; font-family : arial, sans-serif; }
123219
</style>
124220
</head>
125221
<body>
126222
<h1>Directory Tree</h1><p>
127223
EOF
128224
129-
tree -H '.' \
130-
-L 1 \
131-
--dirsfirst \
132-
--hintro=/dev/null \
133-
--houtro=/dev/null \
134-
--metafirst \
135-
--charset utf-8 \
136-
--timefmt '%d-%b-%Y %H:%M' \
137-
-I "index.html" \
138-
-I "hs" \
139-
-h -D --du \
225+
tree -H '.' \
226+
-L 2 \
227+
--dirsfirst \
228+
--hintro=/dev/null \
229+
--houtro=/dev/null \
230+
--metafirst \
231+
--charset utf-8 \
232+
--timefmt '%d-%b-%Y %H:%M' \
233+
-I "index.html" \
234+
-I "hs" \
235+
-h -D --du \
140236
>> index.html
141237
142238
cat << EOF >> index.html
@@ -147,14 +243,13 @@ jobs:
147243
</body>
148244
</html>
149245
EOF
150-
151246
- name: Commit artifacts
152247
run: |
153248
git config user.name 'github-actions[bot]'
154249
git config user.email 'github-actions[bot]@users.noreply.github.com'
155250
git add -A
156-
git commit -m "Artifacts generated from ${{ github.sha }}"
157-
- name: Push ${{ env.artifacts_branch }}
251+
git commit --allow-empty -m "Artifacts generated from ${{ github.sha }}"
252+
- name: Push ${{ steps.set-artifacts-branch.outputs.artifacts_branch }}
158253
uses: ad-m/github-push-action@v0.6.0
159254
with:
160255
github_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)