diff --git a/.github/workflows/build_matrix.yml b/.github/workflows/build_matrix.yml deleted file mode 100644 index ef52356..0000000 --- a/.github/workflows/build_matrix.yml +++ /dev/null @@ -1,99 +0,0 @@ -name: Build matrix - -on: - workflow_call: - outputs: - matrix: - value: ${{ jobs.setup-matrix.outputs.matrix }} - -jobs: - # IMPORTANT: in case of changing the structure of this file make sure to test - # the changes against `npm/gen-root.ts` file - setup-matrix: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.setup-matrix.outputs.matrix }} - steps: - - id: setup-matrix - uses: druzsan/setup-matrix@v2 - with: - matrix: | - build: - [ - linux-x64-gnu, - linux-x64-musl, - linux-arm64-gnu, - linux-arm64-musl, - linux-ia32-gnu, - darwin-arm64, - darwin-x64, - win32-x64-msvc, - win32-arm64-msvc, - win32-ia32-msvc, - ] - include: - - build: linux-x64-gnu - os: ubuntu-latest - rust: stable - target: x86_64-unknown-linux-gnu - libc: glibc - - - build: linux-x64-musl - os: ubuntu-latest - rust: stable - target: x86_64-unknown-linux-musl - libc: musl - cross: true - - - build: linux-arm64-gnu - os: ubuntu-latest - rust: stable - target: aarch64-unknown-linux-gnu - libc: glibc - cross: true - - - build: linux-arm64-musl - os: ubuntu-latest - rust: stable - target: aarch64-unknown-linux-musl - libc: musl - cross: true - - - build: linux-ia32-gnu - os: ubuntu-latest - rust: stable - target: i686-unknown-linux-gnu - libc: glibc - cross: true - - - build: darwin-arm64 - os: macos-latest - rust: stable - target: aarch64-apple-darwin - - - build: darwin-x64 - os: macos-latest - rust: stable - target: x86_64-apple-darwin - - - build: win32-x64-msvc - os: windows-latest - rust: stable - target: x86_64-pc-windows-msvc - libc: msvc - ext: ".exe" - - - build: win32-arm64-msvc - os: windows-latest - rust: stable - target: aarch64-pc-windows-msvc - libc: msvc - ext: ".exe" - test: false - - - build: win32-ia32-msvc - os: windows-latest - rust: stable - target: i686-pc-windows-msvc - libc: msvc - ext: ".exe" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4e3978..67910a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,87 +1,65 @@ -name: Build +# ------------------------------------------------------------------- +# ------------------------------- WARNING --------------------------- +# ------------------------------------------------------------------- +# +# This file was automatically generated by gh-workflows using the +# gh-workflow-gen bin. You should add and commit this file to your +# git repository. **DO NOT EDIT THIS FILE BY HAND!** Any manual changes +# will be lost if the file is regenerated. +# +# To make modifications, update your `build.rs` configuration to adjust +# the workflow description as needed, then regenerate this file to apply +# those changes. +# +# ------------------------------------------------------------------- +# ----------------------------- END WARNING ------------------------- +# ------------------------------------------------------------------- +name: Build and Test +env: + RUSTFLAGS: -Dwarnings on: + pull_request_target: + types: + - opened + - synchronize + - reopened + branches: + - main push: branches: - - main - pull_request: - branches: [main] - types: [opened, reopened, synchronize] -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - # TODO: cancel in progress is not ok for a release since it can be cancelled in a middle of updates - # and we can end up with partial release. - # but for pull-requests cancelling previously running jobs could be beneficial - # cancel-in-progress: true - + - main jobs: - setup_build_matrix: - name: Outputs matrix used for cross compilation - uses: ./.github/workflows/build_matrix.yml - - test_wasm: - name: Run Tests (WASM) + build: + name: Build and Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - target: wasm32-unknown-unknown - - - name: Install Wasm Pack - run: cargo install wasm-bindgen-cli --vers "0.2.92" - - - name: Test WASM - run: | - # TODO: add test for wasm, so we could actually test that. - cargo install -q worker-build && worker-build - - test: - name: Run Tests on ${{ matrix.build }} - runs-on: ${{ matrix.os || 'ubuntu-latest' }} - needs: setup_build_matrix - strategy: - fail-fast: false - matrix: ${{ fromJson(needs.setup_build_matrix.outputs.matrix) }} - - steps: - - uses: actions/checkout@v4 - - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: "20.11.0" - - - name: Install Rust Toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - - - name: Install Cross compilation toolchain - uses: taiki-e/setup-cross-toolchain-action@v1 - with: - target: ${{ matrix.target }} - - uses: taiki-e/install-action@cargo-llvm-cov - - - name: Run Cargo Test - if: matrix.test != 'false' - # TODO: run llvm-cov only for single build since other builds are not sent to codecov anyway - run: cargo llvm-cov --workspace ${{ matrix.features }} --lcov --target ${{ matrix.target }} --output-path lcov.info - publish: - name: Publish on crates.io + - name: Checkout Code + uses: actions/checkout@v4 + - name: Setup Rust Toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable, nightly + components: clippy, rustfmt + - name: Cargo Test + run: cargo test --all-features --workspace + - name: Cargo Fmt + run: cargo +nightly fmt --check + - name: Cargo Clippy + run: cargo +nightly clippy --all-features --workspace -- -D warnings + release: + needs: build + name: Release runs-on: ubuntu-latest - needs: test - if: github.ref == 'refs/heads/main' && github.event_name == 'push' + permissions: + contents: write + pull-requests: write + packages: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} steps: - - uses: actions/checkout@v4 - - - name: Install Rust Toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - - - name: Log in to Crates.io - run: echo ${{ secrets.CARGO_REGISTRY_TOKEN }} | cargo login - - - name: Publish to Crates.io - run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} + - name: Checkout Code + uses: actions/checkout@v4 + - name: Release Plz + uses: MarcoIeni/release-plz-action@v0.5 diff --git a/Cargo.lock b/Cargo.lock index c81e9e5..74eb02b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,23 @@ dependencies = [ "memchr", ] +[[package]] +name = "async-trait" +version = "0.1.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + [[package]] name = "bumpalo" version = "3.16.0" @@ -19,9 +36,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytes" -version = "1.7.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "cfg-if" @@ -50,7 +67,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 2.0.87", ] [[package]] @@ -61,7 +78,27 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.87", +] + +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] @@ -73,7 +110,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.87", ] [[package]] @@ -82,12 +119,47 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "gh-workflow" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1ad3bcceabc26816ce586fece0653c5253300dcfa66c0a62efed1ccb5f745d" +dependencies = [ + "async-trait", + "derive_more", + "derive_setters", + "indexmap", + "merge", + "serde", + "serde_json", + "serde_yaml", + "strum_macros", +] + +[[package]] +name = "hashbrown" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "http" version = "1.1.0" @@ -105,6 +177,17 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "indexmap" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +dependencies = [ + "equivalent", + "hashbrown", + "serde", +] + [[package]] name = "itoa" version = "1.0.11" @@ -123,6 +206,37 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "merge" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10bbef93abb1da61525bbc45eeaff6473a41907d19f8f9aa5168d214e10693e9" +dependencies = [ + "merge_derive", + "num-traits", +] + +[[package]] +name = "merge_derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "209d075476da2e63b4b29e72a2ef627b840589588e71400a25e3565c4f849d07" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "once_cell" version = "1.20.2" @@ -139,11 +253,35 @@ dependencies = [ "yansi", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -171,9 +309,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -186,6 +324,12 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "rustversion" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" + [[package]] name = "ryu" version = "1.0.18" @@ -209,7 +353,7 @@ checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", ] [[package]] @@ -234,6 +378,19 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "stripmargin" version = "0.1.1" @@ -246,6 +403,30 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.87", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.87" @@ -262,6 +443,7 @@ name = "tailcall-valid" version = "0.1.1" dependencies = [ "derive_setters", + "gh-workflow", "http", "pretty_assertions", "regex", @@ -290,7 +472,7 @@ checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", ] [[package]] @@ -299,6 +481,18 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + [[package]] name = "wasm-bindgen" version = "0.2.95" @@ -321,7 +515,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.87", "wasm-bindgen-shared", ] @@ -343,7 +537,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index 404a02a..2585e31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,4 +20,9 @@ wasm-bindgen = "0.2.92" [dev-dependencies] pretty_assertions = "1.4.1" -stripmargin = "0.1.1" \ No newline at end of file +stripmargin = "0.1.1" +gh-workflow = { version = "0" } + +[features] +default = [] +test-feature = [] diff --git a/tests/ci.rs b/tests/ci.rs new file mode 100644 index 0000000..bbe42a9 --- /dev/null +++ b/tests/ci.rs @@ -0,0 +1,70 @@ + +use gh_workflow::*; +use release_plz::Release; +use toolchain::Toolchain; + +#[test] +fn ci() { + let flags = RustFlags::deny("warnings"); + + let build = Job::new("Build and Test") + .add_step(Step::checkout()) + .add_step( + Toolchain::default() + .add_stable() + .add_nightly() + .add_clippy() + .add_fmt(), + ) + .add_step( + Cargo::new("test") + .args("--all-features --workspace") + .name("Cargo Test"), + ) + .add_step( + Cargo::new("fmt") + .nightly() + .args("--check") + .name("Cargo Fmt"), + ) + .add_step( + Cargo::new("clippy") + .nightly() + .args("--all-features --workspace -- -D warnings") + .name("Cargo Clippy"), + ); + + let event = Event::default() + .push(Push::default().add_branch("main")) + .pull_request_target( + PullRequestTarget::default() + .add_type(PullRequestType::Opened) + .add_type(PullRequestType::Synchronize) + .add_type(PullRequestType::Reopened) + .add_branch("main"), + ); + + let permissions = Permissions::default() + .pull_requests(Level::Write) + .packages(Level::Write) + .contents(Level::Write); + + let release = Job::new("Release") + .needs("build") + .add_env(Env::github()) + .add_env(Env::new( + "CARGO_REGISTRY_TOKEN", + "${{ secrets.CARGO_REGISTRY_TOKEN }}", + )) + .permissions(permissions) + .add_step(Step::checkout()) + .add_step(Release::default()); + + Workflow::new("Build and Test") + .add_env(flags) + .on(event) + .add_job("build", build) + .add_job("release", release) + .generate() + .unwrap(); +}