Skip to content

Commit

Permalink
feat: update dependencies of workspaces' Cargo.toml (#11)
Browse files Browse the repository at this point in the history
* feat: extract workspace members and dependencies

* feat: pass relative path to fetch deps from Cargo.toml file

* feat: actually use relative path and start propagating workspace_members deps

* feat: keep single array of deps

* refactor: make the dependency part a bit more generic and save package name for the root Cargo.toml

* fix: address lint and properly calculate total number of deps

* feat: calculate max length of package_name

* fix: specify relative start to fetch the initial Cargo.toml

* feat: display package_names of crates if workspace is present

* fix: selection bug due to data not being sorted anymore

* feat: rework how the toml is saved and passed around + properly save to cargo files

* chore: write some tests

* chore: start of e2e tests

* feat: create some more realistic tests

* fix: failing tests and run new tests

* chore: install cli tool for newer tests

* feat: make the e2e tests verify more fields
  • Loading branch information
BenJeau authored Jan 18, 2025
1 parent 2571f9b commit 979e8a2
Show file tree
Hide file tree
Showing 19 changed files with 1,049 additions and 99 deletions.
31 changes: 27 additions & 4 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock') }}
- name: Add clippy to the toolchain
run: rustup component add clippy
- name: Run cargo clippy
Expand Down Expand Up @@ -56,9 +56,32 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock') }}
- name: Run cargo test
run: cargo test --all -- --nocapture
run: cargo test --bins -- --nocapture

test-realistic:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust setup
run: rustup toolchain install stable --profile minimal
- name: Setup cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./target/
./tests/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('./tests/Cargo.lock') }}-${{ hashFiles('./Cargo.lock') }}
- name: Install cargo-interactive-update
run: cargo install --path .
- name: Run cargo test
run: cd tests && cargo run

audit:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -99,7 +122,7 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock') }}
- name: Run cargo check
run: cargo check

Expand Down
37 changes: 30 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock') }}
- name: Add clippy to the toolchain
run: rustup component add clippy
- name: Run cargo clippy
Expand Down Expand Up @@ -69,9 +69,32 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock') }}
- name: Run cargo test
run: cargo test --all -- --nocapture
run: cargo test --bins -- --nocapture

test-realistic:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust setup
run: rustup toolchain install stable --profile minimal
- name: Setup cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./target/
./tests/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('./tests/Cargo.lock') }}-${{ hashFiles('./Cargo.lock') }}
- name: Install cargo-interactive-update
run: cargo install --path .
- name: Run cargo test
run: cd tests && cargo run

audit:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -112,7 +135,7 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock') }}
- name: Run cargo check
run: cargo check

Expand All @@ -125,7 +148,7 @@ jobs:
uses: crate-ci/typos@v1.29.4

prepare-release:
needs: [lint, format, test, check, typos]
needs: [lint, format, test, test-realistic, check, typos]
permissions:
contents: write
runs-on: ubuntu-latest
Expand Down Expand Up @@ -161,7 +184,7 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock') }}
- name: Update Cargo.toml version
run: |
sed -i -e 's/^version = .*/version = "${{ steps.bump-version.outputs.version }}"/' Cargo.toml
Expand Down Expand Up @@ -205,6 +228,6 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock') }}
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_TOKEN }} ${{ inputs.dry-run && '--dry-run' || '' }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/target
**/target
Loading

0 comments on commit 979e8a2

Please sign in to comment.