diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9f4e34..b9d720e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,10 +28,13 @@ jobs: fetch-depth: 0 submodules: "true" - uses: mozilla-actions/sccache-action@v0.0.9 - - uses: jdx/mise-action@v2 - - run: mise install + - uses: jdx/mise-action@v3 + with: + # version 2025.5.11, a symlink is created for rust setup + # without cache, missing components are installed + # with cache, nothing is installed, but as rust tool is symlinked, it is not cached => missing components failure + cache: false + cache_save: false + experimental: true + - run: mise run ci shell: bash - - run: make generate - - run: make check_no_uncommitted_changes_on_sdk - - run: make check - - run: make test diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index f7fa31c..360b75e 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -19,11 +19,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} cancel-in-progress: true -env: - # configure sccache to cache the build artifacts (on github caches) - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - jobs: lint_commits: name: Lint Commit Messages @@ -35,31 +30,3 @@ jobs: fetch-depth: 0 - name: Check Commit Lint uses: wagoid/commitlint-github-action@v6 - - lint_check: - name: Rust - lint_${{ matrix.lint_projects }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - lint_projects: - - cargo_fmt_check - - cargo_toml_fmt_files - - cargo_clippy - - cargo_deny - steps: - - name: Run the checkout command - uses: actions/checkout@v5 - with: - fetch-depth: 0 - submodules: "true" - - uses: mozilla-actions/sccache-action@v0.0.9 - - uses: jdx/mise-action@v2 - - run: mise install - shell: bash - - name: Check cargo version - run: cargo --version - - name: Run ${{ matrix.lint_projects }} - run: make -f Makefile lint_${{ matrix.lint_projects }} - - run: ${SCCACHE_PATH} --show-stats - shell: bash diff --git a/.mise.toml b/.mise.toml index 8af1479..e89364c 100644 --- a/.mise.toml +++ b/.mise.toml @@ -1,16 +1,78 @@ [env] # RUSTC_WRAPPER = "sccache" -RUST_WITHOUT = "rust-docs" -# ASDF_RUST_PROFILE = "minimal" MISE_CARGO_BINSTALL = "true" [tools] "aqua:cargo-bins/cargo-binstall" = "1" -rust = { version = "1.85", profile = "default" } -make = "latest" -# # experimental +rust = { version = "1.89.0", profile = "minimal", components = "rustfmt,clippy" } # the rust tool stack (with cargo, fmt, clippy) to build source "cargo:cargo-nextest" = "0.9" "cargo:cargo-hack" = "0.6" "cargo:cargo-deny" = "0.16" # "cargo:git-cliff" = "latest" -"cargo:dprint" = "0.45" +"dprint" = "latest" + +[tasks."format"] +alias = "fmt" +description = "Format the code and sort dependencies" +run = [ + "cargo --locked fmt", + "cargo --locked sort --grouped", + "dprint fmt --config=tools/dprint/dprint.json", +] + +[tasks.check] +run = "cargo hack check --each-feature" + +# no uncommitted changes on sdk (generated code) +[tasks."check:no_uncommitted_changes_on_sdk"] +run = "git diff --exit-code cdevents-sdk" + +[tasks."lint:cargo_fmt"] +run = "cargo fmt --all -- --check" + +[tasks."lint:cargo_deny"] +run = """ +cargo deny --workspace --all-features \ + --exclude-dev \ + --exclude generator \ + check licenses advisories \ + --config=tools/cargo-deny/deny.toml +""" + +[tasks."lint:cargo_clippy"] +run = "cargo clippy --workspace --all-features --no-deps --all-targets -- --deny warnings" + +[tasks."lint:toml"] +run = "dprint check --config=tools/dprint/dprint.json" + +[tasks."lint"] +depends = ["lint:*"] + +[tasks.clean] +run = "cargo clean" + +[tasks.generate] +run = """cargo run -p generator -- --templates-dir "generator/templates" --jsonschemas "cdevents-specs/*/schemas/*.json" --dest "cdevents-sdk/src/generated"""" + +[tasks.test] +wait_for = ["generate", "lint:*"] +run = [ + "cargo nextest run --all-features", + "cargo test --doc", +] + +# [tasks."git:setup_cdevents-specs"] +# run = [ +# "git submodule deinit -f --all", +# "git submodule init", +# "git submodule add -f https://github.com/cdevents/spec.git cdevents-specs/main", +# "git submodule add -f -b spec-v0.3 https://github.com/cdevents/spec.git cdevents-specs/spec-v0.3", +# "git submodule add -f -b spec-v0.4 https://github.com/cdevents/spec.git cdevents-specs/spec-v0.4", +# "git submodule update -f --rebase -- cdevents-specs/main", +# ] + +[tasks."git:update_cdevents-specs"] +run = "git submodule update --recursive --remote" + +[tasks.ci] +depends = ["generate", "test", "lint", "check"] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 15b73d5..ace601c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,3 @@ - # Contributing 🚀 Thank you for contributing to cdevents! 🚀 @@ -24,7 +23,7 @@ GitHub is used for project Source Code Management (SCM) using the SSH protocol f 1. Create [a GitHub account](https://github.com/join) if you do not already have one. 1. Setup -[GitHub access via SSH](https://help.github.com/articles/connecting-to-github-with-ssh/) + [GitHub access via SSH](https://help.github.com/articles/connecting-to-github-with-ssh/) ### Install tools @@ -32,8 +31,10 @@ You must install these tools: 1. [`git`](https://help.github.com/articles/set-up-git/): For source control -2. If you use [mise](https://mise.jdx.dev/): `mise install` (after git clone) - Else look into the mise configuration file [`.mise.toml`](https://github.com/cdevents/sdk-rust/blob/main/.mise.toml) to have the list of tools to install +2. [mise](https://mise.jdx.dev/): + +- `mise install`: to install complementary tools, sdk,... +- `mise tasks`: to list all tasks used to build ### Setup a fork @@ -43,41 +44,40 @@ The sdk-rust project requires that you develop (commit) code changes to branches 1. Create a clone of your fork on your local machine: - ```shell - git clone git@github.com:${YOUR_GITHUB_USERNAME}/sdk-rust.git - ``` + ```shell + git clone git@github.com:${YOUR_GITHUB_USERNAME}/sdk-rust.git + ``` 1. Configure `git` remote repositories - Adding `cdevents/sdk-rust` as the `upstream` and your fork as the `origin` remote repositories to your `.git/config` sets you up nicely for regularly [syncing your fork](https://help.github.com/articles/syncing-a-fork/) and submitting pull requests. - - 1. Change into the project directory + Adding `cdevents/sdk-rust` as the `upstream` and your fork as the `origin` remote repositories to your `.git/config` sets you up nicely for regularly [syncing your fork](https://help.github.com/articles/syncing-a-fork/) and submitting pull requests. + 1. Change into the project directory - ```shell - cd sdk-rust - ``` + ```shell + cd sdk-rust + ``` - 2. Retrieve submodules + 2. Retrieve submodules - ```shell - git submodule init - git submodule update --init --recursive - ``` + ```shell + git submodule init + git submodule update --init --recursive + ``` - 3. Configure sdk-rust as the `upstream` repository + 3. Configure sdk-rust as the `upstream` repository - ```shell - git remote add upstream git@github.com:cdevents/sdk-rust.git + ```shell + git remote add upstream git@github.com:cdevents/sdk-rust.git - # Optional: Prevent accidental pushing of commits by changing the upstream URL to `no_push` - git remote set-url --push upstream no_push - ``` + # Optional: Prevent accidental pushing of commits by changing the upstream URL to `no_push` + git remote set-url --push upstream no_push + ``` - 4. Configure your fork as the `origin` repository + 4. Configure your fork as the `origin` repository - ```shell - git remote add origin git@github.com:${YOUR_GITHUB_USERNAME}/sdk-rust.git - ``` + ```shell + git remote add origin git@github.com:${YOUR_GITHUB_USERNAME}/sdk-rust.git + ``` ## Development @@ -92,19 +92,19 @@ git switch -c feat_foo To format the rust code and imports: ```shell -make fmt +mise run fmt ``` -To run the go linter: +To run the all the tasks like the ci: ```shell -make lint +mise run ci ``` To run unit tests: ```shell -make test +mise run test ``` ### Commit & push @@ -130,4 +130,4 @@ Create a PR (pull request) and ask for review. The last reviewer, will "Squash & merge" when ready. The message of the squashed commit follows the [conventional commit], and aggregate/summaries commits of the branch. - [conventional commit]: https://www.conventionalcommits.org/en/v1.0.0/#summary \ No newline at end of file +[conventional commit]: https://www.conventionalcommits.org/en/v1.0.0/#summary diff --git a/Makefile b/Makefile deleted file mode 100644 index ed494b3..0000000 --- a/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -check: - cargo hack check --each-feature - -# no uncommitted changes on sdk (generated code) -check_no_uncommitted_changes_on_sdk: - git diff --exit-code cdevents-sdk - -lint_cargo_fmt_check: - cargo fmt --all -- --check - -lint_cargo_deny: - cargo deny --workspace --all-features \ - --exclude-dev \ - --exclude generator \ - check licenses advisories \ - --config=tools/cargo-deny/deny.toml - -lint_cargo_clippy: - cargo clippy --workspace --all-features --no-deps --all-targets -- --deny warnings - -lint_cargo_toml_fmt_files: - dprint fmt --config=tools/dprint/dprint.json - -lint_cargo_toml_check_files: - dprint check --config=tools/dprint/dprint.json - -clean: - cargo clean - -generate: - cargo run -p generator -- --templates-dir "generator/templates" --jsonschemas "cdevents-specs/*/schemas/*.json" --dest "cdevents-sdk/src/generated" - -test: - cargo nextest run --all-features - cargo test --doc - -# buid_cdevents-specs: -# git submodule deinit -f --all -# git submodule init -# git submodule add -f https://github.com/cdevents/spec.git cdevents-specs/main -# git submodule add -f -b spec-v0.3 https://github.com/cdevents/spec.git cdevents-specs/spec-v0.3 -# git submodule add -f -b spec-v0.4 https://github.com/cdevents/spec.git cdevents-specs/spec-v0.4 -# git submodule update -f --rebase -- cdevents-specs/main - -update_cdevents-specs: - git submodule update --recursive --remote - -.PHONY: - generate \ - check check_no_uncommitted_changes_on_sdk \ - test \ - lint_cargo_fmt_check lint_cargo_deny lint_cargo_clippy lint_cargo_toml_files \ - clean