From 8da5b17bfce227ac091f35f68c61595b456d9e0d Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Thu, 17 Apr 2025 20:00:16 +0800 Subject: [PATCH 01/18] chore(ops): new build --- .github/workflows/docker.yml | 89 ++++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index afc9da7..cf24125 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -29,12 +29,73 @@ jobs: - name: Bundler install uses: metanorma/ci/docker-gem-install@main - - name: Metanorma generate site + - name: Print Metanorma version + run: metanorma --version + + - name: Generate Metanorma XML uses: actions-mn/build-and-publish@v2 with: - destination: gh-pages + destination: artifact + artifact-name: mn agree-to-terms: true - use-bundler: true + + fl-build: + runs-on: ubuntu-latest + needs: build + name: Build Firelight version + + steps: + - name: Download Metanorma artifacts + uses: actions/download-artifact@v4 + with: + name: mn + + - name: "Firelight: create temporary Git repo" + run: | + git config --global user.email "57123902+metanorma-ci@users.noreply.github.com" + git config --global user.name "Metanorma CI" + git config --global init.defaultBranch main + git init . + + - name: "Firelight: commit" + run: | + git add documents/_site/documents.xml + git commit -m "Commit MN XML" + + - name: "Firelight: prepare config" + run: | + cat <<'EOF' >> anafero-config.json + { + "version": "0.1", + "entryPoint": "file:_site/documents.xml", + "storeAdapters": [ + "git+https://github.com/metanorma/firelight#collection-support/packages/relaton-collection-xml-store", + "git+https://github.com/metanorma/firelight#collection-support/packages/metanorma-xml-store" + ], + "contentAdapters": [ + "git+https://github.com/metanorma/firelight#collection-support/packages/metanorma-site-content" + ], + "resourceLayouts": [ + "git+https://github.com/metanorma/firelight#collection-support/packages/plateau-layout" + ] + } + EOF + git add anafero-config.json + git commit -m "Add build config" + + - name: "Firelight: generate HTML" + run: | + npx --node-options='--experimental-vm-modules' \ + -y @riboseinc/anafero-cli@0.0.42 \ + --target-dir _site \ + --path-prefix /cc-admin-documents \ + --current-rev main + + - uses: actions/upload-artifact@v4 + with: + name: fl + path: _site + if-no-files-found: error deploy: if: ${{ github.ref_name == github.event.repository.default_branch }} @@ -42,8 +103,28 @@ jobs: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest - needs: build + needs: fl-build steps: + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Make dist dir + run: mkdir dist + + - name: Download HTML artifacts + uses: actions/download-artifact@v4 + with: + pattern: fl + path: dist + + - name: List files in dist + run: ls -l dist + + - name: Upload pages artifact + uses: actions/upload-pages-artifact@v3 + with: + path: dist + - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 From 248dceb202e234059274dd10f0cbcc88464ce38d Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Tue, 22 Apr 2025 13:14:20 +0800 Subject: [PATCH 02/18] chore(ops): fix workflow --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index cf24125..122d370 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -59,7 +59,7 @@ jobs: - name: "Firelight: commit" run: | - git add documents/_site/documents.xml + git add _site/documents.xml git commit -m "Commit MN XML" - name: "Firelight: prepare config" From f37493c47abcd95ecd1d009f490028c7ed40463c Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Tue, 22 Apr 2025 13:38:48 +0800 Subject: [PATCH 03/18] chore(ops): troubleshoot build --- .github/workflows/docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 122d370..8f27564 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -59,6 +59,7 @@ jobs: - name: "Firelight: commit" run: | + ls -Al git add _site/documents.xml git commit -m "Commit MN XML" From c4a5b673e3b492435eec1c7763c2f7d79e47221e Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Tue, 22 Apr 2025 14:17:53 +0800 Subject: [PATCH 04/18] chore(ops): commit correct artifacts --- .github/workflows/docker.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8f27564..51d67da 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -60,8 +60,10 @@ jobs: - name: "Firelight: commit" run: | ls -Al - git add _site/documents.xml - git commit -m "Commit MN XML" + git add documents.xml + git add **/*.pdf + git add **/*.xml + git commit -m "Commit MN XML & PDF artifacts" - name: "Firelight: prepare config" run: | From aa57cbc89028723ae7dcf10d868561fbf711fbc3 Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Tue, 22 Apr 2025 15:03:09 +0800 Subject: [PATCH 05/18] chore(ops): bump build system version --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 51d67da..f513f69 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -89,7 +89,7 @@ jobs: - name: "Firelight: generate HTML" run: | npx --node-options='--experimental-vm-modules' \ - -y @riboseinc/anafero-cli@0.0.42 \ + -y @riboseinc/anafero-cli@0.0.43 \ --target-dir _site \ --path-prefix /cc-admin-documents \ --current-rev main From 0a51a2c086b50c003c78463ebfc95d17660683bb Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Tue, 22 Apr 2025 15:25:45 +0800 Subject: [PATCH 06/18] chore(ops): correct Anafero config --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f513f69..ab86779 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -70,7 +70,7 @@ jobs: cat <<'EOF' >> anafero-config.json { "version": "0.1", - "entryPoint": "file:_site/documents.xml", + "entryPoint": "file:documents.xml", "storeAdapters": [ "git+https://github.com/metanorma/firelight#collection-support/packages/relaton-collection-xml-store", "git+https://github.com/metanorma/firelight#collection-support/packages/metanorma-xml-store" From 4384eea0d4dc887ee7ce972b93e68488ba429d71 Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Tue, 22 Apr 2025 15:47:51 +0800 Subject: [PATCH 07/18] chore(ops): debug build --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ab86779..c402656 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -59,7 +59,7 @@ jobs: - name: "Firelight: commit" run: | - ls -Al + ls -Al documents git add documents.xml git add **/*.pdf git add **/*.xml From 06aedf1d0c58ed830af0dc197a177849133dbf0c Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Tue, 22 Apr 2025 17:00:14 +0800 Subject: [PATCH 08/18] chore(ops): debug build --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c402656..cb18d42 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -59,7 +59,7 @@ jobs: - name: "Firelight: commit" run: | - ls -Al documents + ls -Al documents/cc-0001-report-ioptest git add documents.xml git add **/*.pdf git add **/*.xml From 605dc47a052be46e8fee62e375d1d2f54e8c4e9a Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Tue, 22 Apr 2025 17:26:35 +0800 Subject: [PATCH 09/18] chore(ops): move files around? --- .github/workflows/docker.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index cb18d42..c199155 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -49,6 +49,7 @@ jobs: uses: actions/download-artifact@v4 with: name: mn + path: _site - name: "Firelight: create temporary Git repo" run: | @@ -59,10 +60,10 @@ jobs: - name: "Firelight: commit" run: | - ls -Al documents/cc-0001-report-ioptest - git add documents.xml - git add **/*.pdf - git add **/*.xml + ls -Al _site/documents/cc-0001-report-ioptest + git add _site/documents.xml + git add _site/**/*.pdf + git add _site/**/*.xml git commit -m "Commit MN XML & PDF artifacts" - name: "Firelight: prepare config" @@ -70,7 +71,7 @@ jobs: cat <<'EOF' >> anafero-config.json { "version": "0.1", - "entryPoint": "file:documents.xml", + "entryPoint": "file:_site/documents.xml", "storeAdapters": [ "git+https://github.com/metanorma/firelight#collection-support/packages/relaton-collection-xml-store", "git+https://github.com/metanorma/firelight#collection-support/packages/metanorma-xml-store" @@ -90,14 +91,14 @@ jobs: run: | npx --node-options='--experimental-vm-modules' \ -y @riboseinc/anafero-cli@0.0.43 \ - --target-dir _site \ + --target-dir dist \ --path-prefix /cc-admin-documents \ --current-rev main - uses: actions/upload-artifact@v4 with: name: fl - path: _site + path: dist if-no-files-found: error deploy: From dfbbcb92d8194afe1d8745a3a042a5c189fffbc8 Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Tue, 22 Apr 2025 17:27:29 +0800 Subject: [PATCH 10/18] chore(ops): update MN action --- .github/workflows/docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c199155..72fe485 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -38,6 +38,7 @@ jobs: destination: artifact artifact-name: mn agree-to-terms: true + cache-site-for-manifest: metanorma.yml fl-build: runs-on: ubuntu-latest From 8161ca5a515e8116f0fb888f2e71e24899f3a414 Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Tue, 22 Apr 2025 17:45:50 +0800 Subject: [PATCH 11/18] chore(ops): add manual caching --- .github/workflows/docker.yml | 45 +++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 72fe485..d0f1ceb 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -31,14 +31,57 @@ jobs: - name: Print Metanorma version run: metanorma --version + # In case of cache miss, the generate MN XML step will run + # and the cache will be filled after job finishes. + # Next time it’ll be a cache hit, unless sources changed. + # See also “Upload cached Metanorma XML” step, which is important. + - name: Restore cached Metanorma XML, if any + id: cache-mn-xml + uses: actions/cache@v4 + env: + cache-name: _site + with: + path: _site + + # NOTE: cache key does not include current MN version, + # which means if sources did not change but it’s desirable + # to rebuild XML using a newer MN version it may be impossible to do + # without making a dummy/meaningless change in the content + # to change the hash. + # + # The proper way to address this could be pinning MN version + # somewhere and including it as part of the hash here; + # alternatively, if we really want to always use whatever MN version + # is latest, we could detect that version and include it + # as part of this key. + key: ${{ runner.os }}-mn-${{ env.cache-name }}-${{ hashFiles('sources/00*-v5/**', 'sources/xmi/**', 'sources/liquid_templates/**', 'sources/guidance/**') }} + + # We can fuzzy-match latest available cache, + # instead of precise hash. + # This can speed up build in some scenarios, + # but can in theory also cause issues where XML is not updated + # after source changes. + # restore-keys: | + # ${{ runner.os }}-mn-${{ env.cache-name }}- + # ${{ runner.os }}-mn- + # ${{ runner.os }}- - name: Generate Metanorma XML uses: actions-mn/build-and-publish@v2 + if: steps.cache-mn-xml.outputs.cache-hit != 'true' with: destination: artifact artifact-name: mn agree-to-terms: true - cache-site-for-manifest: metanorma.yml + + # In case of cache hit, we must explicitly upload the _site dir as artifact + - name: Upload cached Metanorma XML + uses: actions/upload-artifact@v4 + if: steps.cache-mn-xml.outputs.cache-hit == 'true' + with: + name: mn + path: _site + if-no-files-found: error fl-build: runs-on: ubuntu-latest From 12d7d77ab8693e5ed56210b4a48e1d84499ab880 Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Tue, 22 Apr 2025 18:16:28 +0800 Subject: [PATCH 12/18] chore(ops): bump build system version --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d0f1ceb..bfa3f73 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -134,7 +134,7 @@ jobs: - name: "Firelight: generate HTML" run: | npx --node-options='--experimental-vm-modules' \ - -y @riboseinc/anafero-cli@0.0.43 \ + -y @riboseinc/anafero-cli@0.0.44 \ --target-dir dist \ --path-prefix /cc-admin-documents \ --current-rev main From 14c5fc9450f5bfe40241832dd05096ddb29a6833 Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Mon, 28 Apr 2025 16:56:10 +0800 Subject: [PATCH 13/18] chore(ops): try to fix build --- .github/workflows/docker.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index bfa3f73..7a1abbd 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -93,7 +93,6 @@ jobs: uses: actions/download-artifact@v4 with: name: mn - path: _site - name: "Firelight: create temporary Git repo" run: | @@ -104,10 +103,10 @@ jobs: - name: "Firelight: commit" run: | - ls -Al _site/documents/cc-0001-report-ioptest - git add _site/documents.xml - git add _site/**/*.pdf - git add _site/**/*.xml + ls -Al documents/cc-0001-report-ioptest + git add documents.xml + git add **/*.pdf + git add **/*.xml git commit -m "Commit MN XML & PDF artifacts" - name: "Firelight: prepare config" @@ -115,7 +114,7 @@ jobs: cat <<'EOF' >> anafero-config.json { "version": "0.1", - "entryPoint": "file:_site/documents.xml", + "entryPoint": "file:documents.xml", "storeAdapters": [ "git+https://github.com/metanorma/firelight#collection-support/packages/relaton-collection-xml-store", "git+https://github.com/metanorma/firelight#collection-support/packages/metanorma-xml-store" From 19955369eb57c95cf7bcd9d827c1fee061acc9ac Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Mon, 28 Apr 2025 17:03:43 +0800 Subject: [PATCH 14/18] chore: enable debug logging --- .github/workflows/docker.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 7a1abbd..0afb0ea 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -136,7 +136,8 @@ jobs: -y @riboseinc/anafero-cli@0.0.44 \ --target-dir dist \ --path-prefix /cc-admin-documents \ - --current-rev main + --current-rev main \ + --debug - uses: actions/upload-artifact@v4 with: From 3897e31c06fb156a9b9a72d94244d0f73e871d77 Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Mon, 28 Apr 2025 17:06:35 +0800 Subject: [PATCH 15/18] chore(ops): bump build system version --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0afb0ea..825ac78 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -133,7 +133,7 @@ jobs: - name: "Firelight: generate HTML" run: | npx --node-options='--experimental-vm-modules' \ - -y @riboseinc/anafero-cli@0.0.44 \ + -y @riboseinc/anafero-cli@0.0.45 \ --target-dir dist \ --path-prefix /cc-admin-documents \ --current-rev main \ From b6ad6e592b36170caf26a01835fbd0586a52b65d Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Mon, 28 Apr 2025 17:09:54 +0800 Subject: [PATCH 16/18] chore(ops): upload cache dump artifact --- .github/workflows/docker.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 825ac78..aad2cd8 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -145,6 +145,11 @@ jobs: path: dist if-no-files-found: error + - uses: actions/upload-artifact@v4 + with: + name: fl-cache-dump + path: cacheDump.json + deploy: if: ${{ github.ref_name == github.event.repository.default_branch }} environment: From 8d743f14e260650385b36feb697f21b8498d1946 Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Mon, 28 Apr 2025 17:42:57 +0800 Subject: [PATCH 17/18] chore(ops): bump build system version --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index aad2cd8..3cf9775 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -133,7 +133,7 @@ jobs: - name: "Firelight: generate HTML" run: | npx --node-options='--experimental-vm-modules' \ - -y @riboseinc/anafero-cli@0.0.45 \ + -y @riboseinc/anafero-cli@0.0.46 \ --target-dir dist \ --path-prefix /cc-admin-documents \ --current-rev main \ From 2c15fbb892f3c899ef2ab95bdaf77b7dbd4ea98e Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Mon, 28 Apr 2025 17:57:09 +0800 Subject: [PATCH 18/18] chore(ops): bump build system version --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3cf9775..996beba 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -133,7 +133,7 @@ jobs: - name: "Firelight: generate HTML" run: | npx --node-options='--experimental-vm-modules' \ - -y @riboseinc/anafero-cli@0.0.46 \ + -y @riboseinc/anafero-cli@0.0.47 \ --target-dir dist \ --path-prefix /cc-admin-documents \ --current-rev main \