diff --git a/.github/workflows/readme-checks.yml b/.github/workflows/readme-checks.yml new file mode 100644 index 0000000..9900daa --- /dev/null +++ b/.github/workflows/readme-checks.yml @@ -0,0 +1,44 @@ +name: rust + +on: + push: + branches: [ "main" ] + workflow_dispatch: {} + +env: + CARGO_TERM_COLOR: always + +jobs: + check msrv: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v4 + - name: find version mentioned in readme + id: readme-version + run: | + set -euo pipefail + pwd + mkdir -p target/debug + cargo build + readme_version="$(cat README.md | ./target/debug/mdq '# Development | P: "Requires rustc >=" ' | awk '{print $NF}')" + echo "result=$readme_version" >> "$GITHUB_OUTPUT" + - name: pull cargo-msrv from docker hub + run: docker pull foresterre/cargo-msrv + - name: find minimum supported rust version + id: run-msrv + run: | + set -euo pipefail + min_version="$(docker run --rm -t -v "$PWD/":/app/ foresterre/cargo-msrv find --no-log --output-format minimal | tr -d $'\r\n')" + echo "result=$min_version" >> "$GITHUB_OUTPUT" + - name: compare versions + run: | + echo "::notice title=cargo-msrv::$MSRV_VERSION" + echo "::notice title=README.md-msrv::$README_VERSION" + if [[ "$MSRV_VERSION" != "$README_VERSION" ]]; then + echo "::error title=msrv-mismatch::cargo-msrv was $MSRV_VERSION but README.md says rustc >= $README_VERSION" + exit 1 + fi + env: + MSRV_VERSION: ${{ steps.run-msrv.outputs.result }} + README_VERSION: ${{ steps.readme-version.outputs.result }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3c7e169..2341327 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -27,6 +27,7 @@ jobs: echo "::error file=$file_path,title=git-status::<$status_code> $file_path" done <<<"$(git status --porcelain)" exit "$exit_code" + check: runs-on: ubuntu-latest needs: build diff --git a/README.md b/README.md index 455a40a..41237e8 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ Any of these will work: 1. ```shell cargo install --git https://github.com/yshavit/mdq + ``` 2. ```shell brew install mdq ``` @@ -179,3 +180,15 @@ cat oncall.md | mdq ':-: * :-: 2024-01-15' |:----------:|:-----:|:---:|:---:|----:| | 2024-01-15 | | | x | | ``` + +# Development + +Requires rustc >= 1.20.0 + +```bash +cargo build +``` + +```bash +cargo test +```