use_npm: true
tasks:
install-hooks:
commands:
- command: git config --local core.hooksPath .githooks
description: Install git hooks
run:
commands:
- command: cargo r
description: Run the project
fmt:
commands:
- command: cargo fmt --all
description: Format the project
lint:
commands:
- command: cargo clippy --all-features --all-targets --tests --benches -- -Dclippy::all
description: Lint check the project
check:
commands:
- command: cargo c
description: Check the project
build:
commands:
- command: cargo b
description: Build the project
depends_on:
- name: check
build-in-container:
commands:
- container_command:
- cargo
- c
image: docker.io/library/rust:latest
description: Build the project in a container
depends_on:
- name: check
pack:
preconditions:
- command: git diff-index --quiet --exit-code HEAD --
- command: cargo c
commands:
- command: |
latest_version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
name=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].name')
podman build \
--sbom=true \
--label org.opencontainers.image.created=$(date +%Y-%m-%dT%H:%M:%S%z) \
--label org.opencontainers.image.authors=gh:@ffimnsr \
--label org.opencontainers.image.description="$name $latest_version" \
--label org.opencontainers.image.revision=$(git rev-parse HEAD) \
--label org.opencontainers.image.source=$(git remote get-url origin) \
--label org.opencontainers.image.title=$name \
--label org.opencontainers.image.url=https://github.com/ffimnsr/mk-rs \
--label org.opencontainers.image.version=$latest_version \
-f Containerfile \
-t ghcr.io/ffimnsr/$name-rs:$latest_version \
-t ghcr.io/ffimnsr/$name-rs:latest .
test: command -v podman
description: Build the container image
pack_2:
preconditions:
- command: cargo c
commands:
- container_build:
image_name: ghcr.io/ffimnsr/mk-rs
context: .
tags:
- latest
- ${{ env.VERSION }}
labels:
- org.opencontainers.image.created=MK_NOW
- org.opencontainers.image.authors=gh:@ffimnsr
- org.opencontainers.image.description=${{ env.DESCRIPTION }}
- org.opencontainers.image.revision=MK_GIT_REVISION
- org.opencontainers.image.source=MK_GIT_REMOTE_ORIGIN
- org.opencontainers.image.title=mk-rs
- org.opencontainers.image.url=https://github.com/ffimnsr/mk-rs
- org.opencontainers.image.version=${{ env.VERSION }}
description: Build the container image
environment:
VERSION: $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
DESCRIPTION: $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].description')
docs:
commands:
- command: docsify serve docs
description: Serve the documentation
docs_2: docsify serve docs
install_codecov_tools:
commands:
- cargo install --locked grcov
- rustup component add llvm-tools-preview
description: Install code coverage tools
gen_test_cov:
commands:
- cargo t
environment:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: -C instrument-coverage -C codegen-units=1 -C opt-level=0 -C link-dead-code -C overflow-checks=off
LLVM_PROFILE_FILE: ./target/debug/coverage/cargo-test-%p-%m.profraw
description: Run tests with coverage
cov_to_html:
commands:
- rm -rf target/coverage/html
- |
grcov ./target/debug/coverage/ \
--binary-path ./target/debug/ \
-s . \
-t html \
--branch \
--ignore-not-existing \
--keep-only 'src/*' \
-o coverage/html
- open coverage/html/index.html
description: Generate HTML coverage report
cov_to_lcov:
commands:
- rm -rf target/coverage/tests.lcov
- |
grcov ./target/debug/coverage/ \
--binary-path ./target/debug/ \
-s . \
-t lcov \
--branch \
--ignore-not-existing \
--keep-only 'src/*' \
-o coverage/tests.lcov
description: Generate lcov coverage report
python:
commands:
- command: ls -lah
- command: python3
interactive: true
description: Serve the project
parallel:
commands:
- command: |
sleep 5
echo "Hello"
- command: |
sleep 5
echo "World"
description: Run the project in parallel
parallel: true
parallel2:
commands:
- task: check
- command: |
sleep 5
echo "World"
description: Run the project in parallel
parallel: true