Skip to content

Commit

Permalink
Refactor cd and makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
cottinisimone committed Nov 29, 2023
1 parent a27d459 commit 035ecdf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 102 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install cargo-release
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: login
run: cargo login "$CARGO_AUTH_KEY"
- uses: taiki-e/install-action@cargo-release
- uses: taiki-e/install-action@cargo-make
- run: cargo login "$CARGO_AUTH_KEY"
env:
CARGO_AUTH_KEY: ${{ secrets.CARGO_AUTH_KEY }}
- name: publish
run: cargo release publish --no-confirm --allow-branch "*" --workspace --all-features --execute
- run: cargo make release
17 changes: 7 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,20 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: cargo fmt check
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --workspace --all-features -- -D warnings
- name: Build docs
run: cargo doc --document-private-items --workspace --all-features --no-deps
env:
RUSTDOCFLAGS: -Dwarnings
- uses: taiki-e/install-action@cargo-make
- run: cargo make fmt-check
- run: cargo make clippy
- run: cargo make docs

test:
# Avoid duplicate jobs on PR from a branch on the same repo
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test --all-features
- uses: taiki-e/install-action@cargo-make
- run: cargo make test

alls-green:
if: always() && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
Expand Down
98 changes: 14 additions & 84 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,97 +15,27 @@ args = [
"@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )",
]

[tasks.test]
command = "cargo"
args = ["test"]
dependencies = ["build"]

[tasks.lint]
description = "Run lint"
command = "cargo"
args = ["clippy", "--all-targets", "--all-features"]

### with cargo-limit installed
[tasks.lbuild]
description = "Runs the rust compiler."
category = "Build"
install_crate = false
command = "cargo"
args = [
"lbuild",
"@@remove-empty(CARGO_MAKE_CARGO_VERBOSE_FLAGS)",
"@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )",
]

[tasks.ltest]
dependencies = ["ltest-blocking", "ltest-async"]

[tasks.ltest-blocking]
command = "cargo"
args = ["ltest", "--no-default-features", "--features", "blocking"]
dependencies = ["lbuild"]

[tasks.ltest-async]
command = "cargo"
args = ["ltest", "--no-default-features", "--features", "async"]
dependencies = ["lbuild"]

[tasks.clean]
command = "cargo"
args = ["clean"]

[tasks.format-ci]
description = "Runs the cargo rustfmt plugin during CI."
[tasks.fmt-check]
description = "Runs the cargo rustfmt plugin to check everything is well formatted"
command = "cargo"
args = ["fmt", "--all", "--", "--check"]

[tasks.clippy-ci]
command = "cargo"
args = ["clippy", "--", "-D", "warnings"]

[tasks.build-ci]
description = "Build inside CI."
[tasks.test]
command = "cargo"
args = ["build", "-j", "2"]

[tasks.cache-cleanup]
description = "Clean CI cache"
dependencies = ["cargo-prune", "sweep", "delete-artifacts"]

[tasks.sweep]
description = "Clean cargo cache with sweep"
command = "cargo sweep -t 10"
ignore_errors = true
args = ["test", "${@}", "--all-features"]

[tasks.cargo-prune]
description = "Run cargo prune"
[tasks.clippy]
description = "Run clippy"
command = "cargo"
args = ["prune"]
args = ["clippy", "--all-targets", "--all-features", "--", "-D", "warnings"]

[tasks.delete-artifacts]
description = "Remove non cachable artifacts"
script = [
'''
#!/bin/bash
set -e
set -x
find ./target/debug -type f -maxdepth 1 -delete || true
rm -rfv ./target/{debug,release}/deps/{*positional*}
rm -rfv ./target/{debug,release}/.fingerprint/*positional*
'''
]

[tasks.sweep-start]
description = "Start cargo sweep"
[tasks.docs]
description = "Build docs as they are rendered on docs.rs"
command = "cargo"
args = ["sweep", "-s"]
args = ["doc", "--document-private-items", "--all-features", "--no-deps"]
env = { "RUSTDOCFLAGS" = "-Dwarnings" }

[tasks.sweep-end]
description = "Run cargo sweep cleanup"
[tasks.release]
description = "Task to release the package to crates.io"
command = "cargo"
args = ["sweep", "-f"]

[tasks.print-stats]
description = "Print cache size"
command = "du"
args = ["-sh", "target", ".cargo"]
args = ["release", "publish", "--no-confirm", "--allow-branch \"*\"", "--all-features", "--execute"]

0 comments on commit 035ecdf

Please sign in to comment.