From 85c9c2c62e344422c36eb830c73fae24bb025251 Mon Sep 17 00:00:00 2001 From: Sameer Puri Date: Mon, 12 Oct 2026 11:15:31 -0700 Subject: [PATCH] Overhaul GHA workflows --- .github/workflows/cli.yml | 32 -------------- .github/workflows/lib.yml | 63 --------------------------- .github/workflows/release.yml | 6 +-- .github/workflows/web-deploy.yml | 43 +++++++++++++----- .github/workflows/web.yml | 12 +---- .github/workflows/workspace.yml | 47 ++++++++++++++++++++ g_code/src/tests.rs | 2 +- star/src/turtle/elements/image_ops.rs | 2 - web/src/forms/mod.rs | 10 ++--- 9 files changed, 89 insertions(+), 128 deletions(-) delete mode 100644 .github/workflows/cli.yml delete mode 100644 .github/workflows/lib.yml create mode 100644 .github/workflows/workspace.yml diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml deleted file mode 100644 index dba91b5..0000000 --- a/.github/workflows/cli.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Build svg2gcode-cli - -on: - push: - branches: [main] - pull_request: - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - - name: Get stable release date - id: stable-date - run: echo "date=$(curl -s https://static.rust-lang.org/dist/channel-rust-stable.toml | grep '^date' -m1 | cut -d'"' -f2)" >> $GITHUB_OUTPUT - - uses: Swatinem/rust-cache@v2 - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: nightly-${{ steps.stable-date.outputs.date }} - components: rustfmt - - uses: dtolnay/rust-toolchain@stable - with: - components: clippy - - name: Fmt - run: cargo +nightly-${{ steps.stable-date.outputs.date }} fmt --check -p svg2gcode-cli - - name: Clippy - run: cargo clippy -p svg2gcode-cli -- -D warnings - - name: Build - run: cargo build -p svg2gcode-cli diff --git a/.github/workflows/lib.yml b/.github/workflows/lib.yml deleted file mode 100644 index 8123aa7..0000000 --- a/.github/workflows/lib.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Build, test, and publish coverage for svg2gcode - -on: - push: - branches: [main] - pull_request: - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - - name: Get stable release date - id: stable-date - run: echo "date=$(curl -s https://static.rust-lang.org/dist/channel-rust-stable.toml | grep '^date' -m1 | cut -d'"' -f2)" >> $GITHUB_OUTPUT - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: nightly-${{ steps.stable-date.outputs.date }} - components: rustfmt - - uses: dtolnay/rust-toolchain@stable - with: - components: clippy - - uses: Swatinem/rust-cache@v2 - - name: Fmt - run: cargo +nightly-${{ steps.stable-date.outputs.date }} fmt --check -p svg2gcode - - name: Clippy - run: cargo clippy -p svg2gcode -- -D warnings - - name: Build - run: cargo build -p svg2gcode - - name: Test - run: cargo test -p svg2gcode - coverage: - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' - steps: - - uses: actions/checkout@v5 - with: - fetch-depth: 0 - - uses: Swatinem/rust-cache@v2 - with: - cache-all-crates: true - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: nightly - components: llvm-tools-preview - - run: cargo install grcov - - run: cargo build -p svg2gcode - env: - RUSTFLAGS: '-Cinstrument-coverage' - RUSTDOCFLAGS: '-Cinstrument-coverage' - LLVM_PROFILE_FILE: 'codecov-instrumentation-%p-%m.profraw' - - run: RUSTFLAGS='-Cinstrument-coverage' cargo test --all-features --no-fail-fast -p svg2gcode - env: - RUSTFLAGS: '-Cinstrument-coverage' - RUSTDOCFLAGS: '-Cinstrument-coverage' - LLVM_PROFILE_FILE: 'codecov-instrumentation-%p-%m.profraw' - - run: grcov . -s . --binary-path ./target/debug/ -t lcov --branch -o lcov.info - - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c3c888a..2647320 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,7 @@ name: Release CLI on: release: - types: [created] + types: [published] jobs: build: @@ -21,7 +21,7 @@ jobs: target: aarch64-unknown-linux-musl artifact: svg2gcode-linux-aarch64 - name: macOS x64 - runner: macos-15-intel + runner: macos-26-intel target: x86_64-apple-darwin artifact: svg2gcode-macos-x86_64 - name: macOS arm64 @@ -57,7 +57,7 @@ jobs: release: name: Upload release assets needs: build - runs-on: ubuntu-latest + runs-on: ubuntu-slim permissions: contents: write steps: diff --git a/.github/workflows/web-deploy.yml b/.github/workflows/web-deploy.yml index 7900f79..8df11d8 100644 --- a/.github/workflows/web-deploy.yml +++ b/.github/workflows/web-deploy.yml @@ -1,20 +1,34 @@ name: Deploy svg2gcode-web on: - workflow_run: - branches: [main] - workflows: [Check svg2gcode-web] - types: [completed] + release: + types: [published] + workflow_dispatch: + inputs: + ref: + description: 'Commit hash, tag, or branch to deploy' + required: true + default: 'main' + type: string env: CARGO_TERM_COLOR: always +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: false + jobs: build: runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - uses: actions/checkout@v5 with: + ref: ${{ inputs.ref || github.ref }} submodules: 'true' - uses: dtolnay/rust-toolchain@stable with: @@ -27,10 +41,17 @@ jobs: run: | cd web trunk build --release --public-url https://sameer.github.io/svg2gcode/ - - - name: Publish to GitHub Pages - uses: peaceiris/actions-gh-pages@v4 - if: github.ref == 'refs/heads/main' + - name: Upload to Github Pages + uses: actions/upload-pages-artifact@v3 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ${{ github.workspace }}/web/dist + path: ${{ github.workspace }}/web/dist + deploy: + environment: + name: github-pages + url: ${{ steps.deploypages.outputs.page_url }} + runs-on: ubuntu-slim + needs: build + steps: + - name: Deploy to GitHub Pages + id: deploypages + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml index 078554d..80869ac 100644 --- a/.github/workflows/web.yml +++ b/.github/workflows/web.yml @@ -11,21 +11,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - - name: Get stable release date - id: stable-date - run: echo "date=$(curl -s https://static.rust-lang.org/dist/channel-rust-stable.toml | grep '^date' -m1 | cut -d'"' -f2)" >> $GITHUB_OUTPUT - uses: Swatinem/rust-cache@v2 - - uses: dtolnay/rust-toolchain@stable with: - toolchain: nightly-${{ steps.stable-date.outputs.date }} - components: rustfmt + cache-all-crates: true - uses: dtolnay/rust-toolchain@stable with: targets: wasm32-unknown-unknown - components: clippy - - name: Fmt - run: cargo +nightly-${{ steps.stable-date.outputs.date }} fmt --check -p svg2gcode-web - - name: Clippy - run: cargo clippy -p svg2gcode-web --target wasm32-unknown-unknown -- -D warnings - name: Check run: cargo check -p svg2gcode-web --target wasm32-unknown-unknown diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml new file mode 100644 index 0000000..91e9b18 --- /dev/null +++ b/.github/workflows/workspace.yml @@ -0,0 +1,47 @@ +name: Workspace crate checks + +on: + push: + branches: [main] + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + - uses: Swatinem/rust-cache@v2 + with: + cache-all-crates: true + - name: Get stable release date + id: stable-date + run: echo "date=$(curl -s https://static.rust-lang.org/dist/channel-rust-stable.toml | grep '^date' -m1 | cut -d'"' -f2)" >> $GITHUB_OUTPUT + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly-${{ steps.stable-date.outputs.date }} + components: clippy, rustfmt + - uses: taiki-e/install-action@cargo-hack + - name: Fmt + run: cargo +nightly-${{ steps.stable-date.outputs.date }} fmt --check + - name: Clippy + run: cargo +nightly-${{ steps.stable-date.outputs.date }} hack clippy --workspace --feature-powerset --tests -- -D warnings + build_and_test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + - uses: Swatinem/rust-cache@v2 + with: + cache-all-crates: true + - uses: dtolnay/rust-toolchain@stable + - uses: taiki-e/install-action@cargo-hack + - name: Build + run: cargo hack build --workspace --feature-powerset + - name: Test + run: cargo hack test --workspace --feature-powerset diff --git a/g_code/src/tests.rs b/g_code/src/tests.rs index 04f7558..effe08c 100644 --- a/g_code/src/tests.rs +++ b/g_code/src/tests.rs @@ -43,7 +43,7 @@ fn assert_close(left: Vec>, right: Vec>) { let mut code = String::new(); ::g_code::emit::format_gcode_fmt(left.iter(), FormatOptions::default(), &mut code).unwrap(); assert_eq!(left.len(), right.len(), "{code}"); - for (i, pair) in left.into_iter().zip(right.into_iter()).enumerate() { + for (i, pair) in left.into_iter().zip(right).enumerate() { match pair { (Token::Field(l), Token::Field(r)) => { assert_eq!(l.letters, r.letters); diff --git a/star/src/turtle/elements/image_ops.rs b/star/src/turtle/elements/image_ops.rs index 6f498e6..2621f71 100644 --- a/star/src/turtle/elements/image_ops.rs +++ b/star/src/turtle/elements/image_ops.rs @@ -72,8 +72,6 @@ pub fn transform_image( // During non-aligned rotation, the corners need to be transparent image = add_alpha_channel(image); - - let scale_x = image_to_final.transform_vector(vector(1.0, 0.0)).length(); let scale_y = image_to_final.transform_vector(vector(0.0, 1.0)).length(); diff --git a/web/src/forms/mod.rs b/web/src/forms/mod.rs index 34e48a7..90bc5e1 100644 --- a/web/src/forms/mod.rs +++ b/web/src/forms/mod.rs @@ -276,10 +276,10 @@ pub fn import_export_modal() -> Html { &gloo_file::File::from(file), move |res| { let res = res - .map_err(|err| format!("Error reading {}: {}", &filename, err)) + .map_err(|err| format!("Error reading {}: {}", filename, err)) .and_then(|bytes| { serde_json::from_slice::(&bytes) - .map_err(|err| format!("Error parsing {}: {}", &filename, err)) + .map_err(|err| format!("Error parsing {}: {}", filename, err)) }); match res { @@ -429,7 +429,7 @@ pub fn svg_form() -> Html { ) .err() { - Err(format!("Error parsing {}: {}", &filename, err)) + Err(format!("Error parsing {}: {}", filename, err)) } else { Ok(Svg { content: text, @@ -517,7 +517,7 @@ pub fn svg_form() -> Html { { url_input_parsed.set(Some(Err(format!( "Error parsing {}: {}", - &response_url, err + response_url, err )))); } else { app.reduce_mut(|app| { @@ -532,7 +532,7 @@ pub fn svg_form() -> Html { Err(err) => { url_input_parsed.set(Some(Err(format!( "Error fetching {}: {:?}", - &request_url, + request_url, err.dyn_into::().unwrap().message() )))); }