name: "Editor: Dev & CI" on: push: branches: - master pull_request: {} env: CARGO_TERM_COLOR: always INDEX_HTML_HEAD_REPLACEMENT: jobs: build: runs-on: self-hosted permissions: contents: write deployments: write pull-requests: write actions: write env: RUSTC_WRAPPER: /usr/bin/sccache CARGO_INCREMENTAL: 0 SCCACHE_DIR: /var/lib/github-actions/.cache steps: - name: ๐Ÿ“ฅ Clone and checkout repository uses: actions/checkout@v3 - name: ๐Ÿ—‘ Clear wasm-bindgen cache run: rm -r ~/.cache/.wasm-pack || true - name: ๐ŸŸข Install the latest Node.js uses: actions/setup-node@v4 with: node-version: "latest" - name: ๐Ÿšง Install Node dependencies run: | cd frontend npm ci - name: ๐Ÿฆ€ Install the latest Rust run: | echo "Initial system version:" rustc --version rustup update stable echo "Latest updated version:" 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) sed -i "s||$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html - name: ๐ŸŒ Build Graphite web code env: NODE_ENV: production run: | cd frontend mold -run npm run build - name: ๐Ÿ“ค Publish to Cloudflare Pages id: cloudflare uses: cloudflare/pages-action@1 continue-on-error: true with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} gitHubToken: ${{ secrets.GITHUB_TOKEN }} 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 run: | cd frontend npm run lint - name: ๐Ÿ”ฌ Check Rust formatting run: | mold -run cargo fmt --all -- --check - name: ๐Ÿฆ€ Build Rust code env: RUSTFLAGS: -Dwarnings run: | mold -run cargo build --all-features - name: ๐Ÿงช Run Rust tests 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 # steps: # - uses: actions/checkout@v3 # - name: ๐Ÿงช Run Rust miri # run: | # mold -run cargo +nightly miri nextest run -j32 --all-features cargo-deny: runs-on: ubuntu-latest steps: - name: ๐Ÿ“ฅ Clone and checkout repository uses: actions/checkout@v3 - name: ๐Ÿ“œ Check crate license compatibility for root workspace uses: EmbarkStudios/cargo-deny-action@v2 with: command: check bans licenses sources - name: ๐Ÿ“œ Check crate license compatibility for /libraries/rawkit uses: EmbarkStudios/cargo-deny-action@v2 with: command: check bans licenses sources manifest-path: libraries/rawkit/Cargo.toml