diff --git a/.github/workflows/build-dev-and-ci.yml b/.github/workflows/build-dev-and-ci.yml index ff3f2515..e62ea3bc 100644 --- a/.github/workflows/build-dev-and-ci.yml +++ b/.github/workflows/build-dev-and-ci.yml @@ -4,7 +4,7 @@ on: push: branches: - master - pull_request: + pull_request: {} env: CARGO_TERM_COLOR: always INDEX_HTML_HEAD_REPLACEMENT: @@ -13,9 +13,10 @@ jobs: build: runs-on: self-hosted permissions: - contents: read + contents: write deployments: write pull-requests: write + actions: write env: RUSTC_WRAPPER: /usr/bin/sccache CARGO_INCREMENTAL: 0 @@ -47,9 +48,11 @@ jobs: rustc --version - name: ✂ Replace template in
of index.html + if: github.ref != 'refs/heads/master' + env: + INDEX_HTML_HEAD_REPLACEMENT: "" run: | # Remove the INDEX_HTML_HEAD_REPLACEMENT environment variable for build links (not master deploys) - git rev-parse --abbrev-ref HEAD | grep master > /dev/null || export INDEX_HTML_HEAD_REPLACEMENT="" sed -i "s||$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html - name: 🌐 Build Graphite web code @@ -70,6 +73,19 @@ jobs: projectName: graphite-dev directory: frontend/dist + - name: 💬 Comment build link URL to commit hash page on GitHub + if: github.ref == 'refs/heads/master' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh api \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + /repos/${{ github.repository }}/commits/$(git rev-parse HEAD)/comments \ + -f body="| 📦 **Build Complete for** $(git rev-parse HEAD) | + |-| + | ${{ steps.cloudflare.outputs.url }} |" + - name: 👕 Lint Graphite web formatting env: NODE_ENV: production @@ -91,6 +107,51 @@ jobs: run: | mold -run cargo test --all-features --workspace + - name: 📃 Generate code documentation info for website + if: github.ref == 'refs/heads/master' + run: | + cargo test --package graphite-editor --lib -- messages::message::test::generate_message_tree + mkdir -p artifacts-generated + mv hierarchical_message_system_tree.txt artifacts-generated/hierarchical_message_system_tree.txt + + - name: 💿 Obtain cache of auto-generated code docs artifacts, to check if they've changed + if: github.ref == 'refs/heads/master' + id: cache-website-code-docs + uses: actions/cache/restore@v3 + with: + path: artifacts + key: website-code-docs + + - name: 🔍 Check if auto-generated code docs artifacts changed + if: github.ref == 'refs/heads/master' + id: website-code-docs-changed + run: | + if ! diff --brief --recursive artifacts-generated artifacts; then + echo "Auto-generated code docs artifacts have changed." + rm -rf artifacts + mv artifacts-generated artifacts + echo "changed=true" >> $GITHUB_OUTPUT + else + echo "Auto-generated code docs artifacts have not changed." + rm -rf artifacts + rm -rf artifacts-generated + fi + + - name: 💾 Save cache of auto-generated code docs artifacts + if: steps.website-code-docs-changed.outputs.changed == 'true' + uses: actions/cache/save@v3 + with: + path: artifacts + key: ${{ steps.cache-website-code-docs.outputs.cache-primary-key }} + + - name: ♻️ Trigger website rebuild if the auto-generated code docs artifacts have changed + if: steps.website-code-docs-changed.outputs.changed == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + rm -rf artifacts + gh workflow run website.yml --ref master + # miri: # runs-on: self-hosted diff --git a/.github/workflows/comment-!build-commands.yml b/.github/workflows/comment-!build-commands.yml index a8fa55e2..8d8a0ae0 100644 --- a/.github/workflows/comment-!build-commands.yml +++ b/.github/workflows/comment-!build-commands.yml @@ -73,9 +73,10 @@ jobs: rustc --version - name: ✂ Replace template in of index.html + env: + INDEX_HTML_HEAD_REPLACEMENT: "" run: | # Remove the INDEX_HTML_HEAD_REPLACEMENT environment variable for build links (not master deploys) - export INDEX_HTML_HEAD_REPLACEMENT="" sed -i "s||$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html - name: ⌨ Set build command based on comment diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 0451d422..4b9a6ed4 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -9,6 +9,7 @@ on: pull_request: paths: - website/** + workflow_dispatch: {} env: CARGO_TERM_COLOR: always INDEX_HTML_HEAD_INCLUSION: @@ -30,6 +31,14 @@ jobs: with: tool: zola@0.20.0 + - name: 🔍 Check if `website/other` directory changed + uses: dorny/paths-filter@v3 + id: changes + with: + filters: | + website-other: + - "website/other/**" + - name: ✂ Replace template in of index.html run: | # Remove the INDEX_HTML_HEAD_INCLUSION environment variable for build links (not master deploys) @@ -43,16 +52,8 @@ jobs: npm run install-fonts zola --config config.toml build --minify - - name: 🔍 Check if `website/other` directory changed - uses: dorny/paths-filter@v3 - id: changes - with: - filters: | - other: - - "website/other/**" - - name: 💿 Restore cache of `website/other/dist` directory, if available and `website/other` didn't change - if: steps.changes.outputs.other != 'true' + if: steps.changes.outputs.website-other != 'true' id: cache-website-other-dist uses: actions/cache/restore@v3 with: @@ -80,8 +81,32 @@ jobs: - name: 🚚 Move `website/other/dist` contents to `website/public` run: | + mkdir -p website/public mv website/other/dist/* website/public + - name: 💿 Obtain cache of auto-generated code docs artifacts + id: cache-website-code-docs + uses: actions/cache/restore@v3 + with: + path: artifacts + key: website-code-docs + + - name: 📁 Fallback in case auto-generated code docs artifacts weren't cached + if: steps.cache-website-code-docs.outputs.cache-hit != 'true' + run: | + echo "🦀 Initial system version of Rust:" + rustc --version + rustup update stable + echo "🦀 Latest updated version of Rust:" + rustc --version + cargo test --package graphite-editor --lib -- messages::message::test::generate_message_tree + mkdir artifacts + mv hierarchical_message_system_tree.txt artifacts/hierarchical_message_system_tree.txt + + - name: 🚚 Move `artifacts` contents to `website/public` + run: | + mv artifacts/* website/public + - name: 📤 Publish to Cloudflare Pages id: cloudflare uses: cloudflare/pages-action@1