diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..b855adb008 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,166 @@ +name: "CI" + +on: + pull_request: {} + merge_group: {} + +env: + CARGO_TERM_COLOR: always + +jobs: + # Rust format check on GitHub runner + rust-fmt: + runs-on: ubuntu-latest + steps: + - name: ๐ฅ Clone and checkout repository + uses: actions/checkout@v3 + + - name: ๐ฆ Check if CI can be skipped + id: skip-check + uses: cariad-tech/merge-queue-ci-skipper@main + + - name: ๐ฆ Install the latest Rust + if: steps.skip-check.outputs.skip-check != 'true' + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + + - name: ๐ฌ Check Rust formatting + if: steps.skip-check.outputs.skip-check != 'true' + run: cargo fmt --all -- --check + + # License compatibility check on GitHub runner + 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 + + # Web build on GitHub runner (only compiles WASM crate) + web-build: + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + steps: + - name: ๐ฅ Clone and checkout repository + uses: actions/checkout@v3 + + - name: ๐ฆ Check if CI can be skipped + id: skip-check + uses: cariad-tech/merge-queue-ci-skipper@main + + - name: ๐ข Install the latest Node.js + if: steps.skip-check.outputs.skip-check != 'true' + uses: actions/setup-node@v4 + with: + node-version: 'latest' + + - name: ๐ฆ Install the latest Rust + if: steps.skip-check.outputs.skip-check != 'true' + uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32-unknown-unknown, x86_64-unknown-linux-gnu + + - name: โก Setup sccache + if: steps.skip-check.outputs.skip-check != 'true' + uses: mozilla-actions/sccache-action@v0.0.9 + + - name: ๐ฆ Setup cargo-binstall + if: steps.skip-check.outputs.skip-check != 'true' + uses: cargo-bins/cargo-binstall@main + + - name: ๐ฆ Install wasm-pack and cargo-about + if: steps.skip-check.outputs.skip-check != 'true' + run: cargo binstall --no-confirm --force wasm-pack cargo-about + + - name: ๐ฆ Install wasm-opt (binaryen) + if: steps.skip-check.outputs.skip-check != 'true' + run: sudo apt-get update && sudo apt-get install -y binaryen + + - name: ๐ง Install build dependencies + if: steps.skip-check.outputs.skip-check != 'true' + run: | + cd frontend + npm run setup + + - name: ๐ Build Graphite web code + if: steps.skip-check.outputs.skip-check != 'true' + env: + NODE_ENV: production + run: | + cd frontend + npm run build + + - name: ๐ค Publish to Cloudflare Pages + if: steps.skip-check.outputs.skip-check != 'true' + 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: ๐ Lint Graphite web formatting + if: steps.skip-check.outputs.skip-check != 'true' + env: + NODE_ENV: production + run: | + cd frontend + npm run lint + + # Full Rust build and tests on self-hosted runner + rust-build-and-test: + runs-on: self-hosted + 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: ๐ฆ Check if CI can be skipped + id: skip-check + uses: cariad-tech/merge-queue-ci-skipper@main + + - name: ๐ฆ Install the latest Rust + if: steps.skip-check.outputs.skip-check != 'true' + run: | + rustup update stable + + - name: ๐ฆ Fetch Rust dependencies + if: steps.skip-check.outputs.skip-check != 'true' + run: | + cargo fetch --locked + + # - name: ๐ฆ Build Rust code + # if: steps.skip-check.outputs.skip-check != 'true' + # env: + # RUSTFLAGS: -Dwarnings + # run: | + # mold -run cargo build --all-features + + - name: ๐งช Run Rust tests + if: steps.skip-check.outputs.skip-check != 'true' + env: + RUSTFLAGS: -Dwarnings + run: | + mold -run cargo test --all-features diff --git a/.github/workflows/build-dev-and-ci.yml b/.github/workflows/deploy-master.yml similarity index 61% rename from .github/workflows/build-dev-and-ci.yml rename to .github/workflows/deploy-master.yml index c903568c0b..df937bcf93 100644 --- a/.github/workflows/build-dev-and-ci.yml +++ b/.github/workflows/deploy-master.yml @@ -1,62 +1,71 @@ -name: "Editor: Dev & CI" +name: "Deploy Master" on: - push: + workflow_run: + workflows: ["Provide Shaders"] + types: + - completed branches: - master - pull_request: {} - merge_group: {} + env: CARGO_TERM_COLOR: always INDEX_HTML_HEAD_REPLACEMENT: jobs: - build: - runs-on: self-hosted + deploy: + # Only run if the shader build succeeded + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest 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 + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" steps: - name: ๐ฅ Clone and checkout repository uses: actions/checkout@v3 + with: + ref: ${{ github.event.workflow_run.head_sha }} - - name: ๐ Clear wasm-bindgen cache - run: rm -r ~/.cache/.wasm-pack || true + - name: ๐จ Download pre-built shaders + run: | + SHADER_URL="https://raw.githubusercontent.com/${{ vars.ARTIFACTS_REPO_OWNER }}/${{ vars.ARTIFACTS_REPO_NAME }}/${{ vars.ARTIFACTS_REPO_BRANCH }}/rev/${{ github.event.workflow_run.head_sha }}/raster_nodes_shaders_entrypoint.wgsl" + curl -fsSL "$SHADER_URL" -o raster_nodes_shaders_entrypoint.wgsl + echo "RASTER_NODES_SHADER_PATH=$(pwd)/raster_nodes_shaders_entrypoint.wgsl" >> $GITHUB_ENV - name: ๐ข Install the latest Node.js uses: actions/setup-node@v4 with: - node-version: "latest" + node-version: 'latest' + + - name: ๐ฆ Install the latest Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32-unknown-unknown + + - name: โก Setup sccache + uses: mozilla-actions/sccache-action@v0.0.9 + + - name: ๐ฆ Setup cargo-binstall + uses: cargo-bins/cargo-binstall@main + + - name: ๐ฆ Install wasm-pack and cargo-about + run: cargo binstall --no-confirm --force wasm-pack cargo-about + + - name: ๐ฆ Install wasm-opt (binaryen) + run: sudo apt-get update && sudo apt-get install -y binaryen - name: ๐ง Install build dependencies run: | cd frontend npm run setup - - name: ๐ฆ Install the latest Rust - run: | - echo "Initial system version:" - rustc --version - rustup update stable - echo "Latest updated version:" - rustc --version - - - name: ๐ฆ Fetch Rust dependencies - run: | - echo "If it fails here, the committed Cargo.lock may be out of date" - cargo fetch --locked - - name: โ Replace template in
of index.html 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 @@ -64,7 +73,7 @@ jobs: NODE_ENV: production run: | cd frontend - mold -run npm run build + npm run build - name: ๐ค Publish to Cloudflare Pages id: cloudflare @@ -78,7 +87,6 @@ jobs: 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: | @@ -90,29 +98,7 @@ jobs: |-| | ${{ 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 - - name: ๐ Generate code documentation info for website - if: github.ref == 'refs/heads/master' run: | cd tools/editor-message-tree cargo run @@ -121,7 +107,6 @@ jobs: mv website/generated/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: @@ -129,7 +114,6 @@ jobs: 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 @@ -157,31 +141,3 @@ jobs: 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 diff --git a/frontend/src/components/widgets/inputs/NumberInput.svelte b/frontend/src/components/widgets/inputs/NumberInput.svelte index 199d3ce4be..d508d8155f 100644 --- a/frontend/src/components/widgets/inputs/NumberInput.svelte +++ b/frontend/src/components/widgets/inputs/NumberInput.svelte @@ -2,6 +2,7 @@ import { createEventDispatcher, onMount, onDestroy, getContext } from "svelte"; import { evaluateMathExpression } from "@graphite/../wasm/pkg/graphite_wasm"; + import type { Editor } from "@graphite/editor"; import { PRESS_REPEAT_DELAY_MS, PRESS_REPEAT_INTERVAL_MS } from "@graphite/io-managers/input"; import type { NumberInputMode, NumberInputIncrementBehavior, ActionShortcut } from "@graphite/messages"; diff --git a/frontend/src/editor.ts b/frontend/src/editor.ts index d8c018102e..fb609d18f9 100644 --- a/frontend/src/editor.ts +++ b/frontend/src/editor.ts @@ -2,6 +2,7 @@ import { EditorHandle } from "@graphite/../wasm/pkg/graphite_wasm"; import init, { wasmMemory, receiveNativeMessage } from "@graphite/../wasm/pkg/graphite_wasm"; + import { type JsMessageType } from "@graphite/messages"; import { createSubscriptionRouter, type SubscriptionRouter } from "@graphite/subscription-router"; import { operatingSystem } from "@graphite/utility-functions/platform"; diff --git a/frontend/src/messages.ts b/frontend/src/messages.ts index 92b35116f4..de965ec035 100644 --- a/frontend/src/messages.ts +++ b/frontend/src/messages.ts @@ -3,6 +3,7 @@ import { Transform, Type, plainToClass } from "class-transformer"; import { type EditorHandle } from "@graphite/../wasm/pkg/graphite_wasm"; + import { type PopoverButtonStyle, type IconName, type IconSize } from "@graphite/icons"; export class JsMessage { diff --git a/frontend/src/subscription-router.ts b/frontend/src/subscription-router.ts index d807a0085f..80e8a59356 100644 --- a/frontend/src/subscription-router.ts +++ b/frontend/src/subscription-router.ts @@ -1,6 +1,7 @@ import { plainToInstance } from "class-transformer"; import { type EditorHandle } from "@graphite/../wasm/pkg/graphite_wasm"; + import { type JsMessageType, messageMakers, type JsMessage } from "@graphite/messages"; type JsMessageCallback