Skip to content

Commit

Permalink
add rustc as requirement for cargo install
Browse files Browse the repository at this point in the history
- move the `cargo install` to the last option
- add the requirement
- modify the requirement (in both cases) to 1.76.0, to trigger a failure
  so that I can make sure it works
- change the checker to use just plain grep, and include the file name
  and line number, so I can use them in the workflow commands
  • Loading branch information
yshavit committed Mar 1, 2025
1 parent e03e11f commit a0c37ec
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/readme-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: docker pull yshavit/mdq
- name: find version mentioned in readme
id: readme-version
run: |
set -euo pipefail
readme_version="$(cat README.md | docker run -i --rm yshavit/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 "::notice title=cargo-msrv::$min_version"
echo "result=$min_version" >> "$GITHUB_OUTPUT"
- name: compare versions
- name: check versions in readme
id: readme-version
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
set -euo pipefail
exit_code=0
while IFS=: read -r file line_no found_rustc_version; do
if [[ "$found_rustc_version" == "$MSRV_VERSION" ]]; then
echo "::notice file=$file,line=$line_no,title=version::✅ $found_rustc_version"
else
echo "::error file=$file,line=$line_no,title=version::$found_rustc_version should have been $MSRV_VERSION"
exit_code=1
fi
done <<<"$(grep -HnoE 'rustc >= \S+' README.md)"
exit "$exit_code"
env:
MSRV_VERSION: ${{ steps.run-msrv.outputs.result }}
README_VERSION: ${{ steps.readme-version.outputs.result }}
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ have one you prefer.
Any of these will work:

1. ```shell
cargo install --git https://github.com/yshavit/mdq
```
2. ```shell
brew install mdq
```
3. ```bash
(Mac and Linux)
1. ```bash
docker pull yshavit/mdq
echo 'My [example](https://github.com/yshavit/mdq) markdown' | docker run --rm -i yshavit/mdq '[]()'
```
4. Download binaries from [the latest release] (or any other release, of course).
1. Download binaries from [the latest release] (or any other release, of course).

You can also grab the binaries from the latest [build-release] workflow run. You must be logged into GitHub to do
that (this is GitHub's limitation, not mine). You'll have to `chmod +x` them before you can run them.
1. ```shell
cargo install --git https://github.com/yshavit/mdq
```
Requires rustc >= 1.2.3

Check failure on line 58 in README.md

View workflow job for this annotation

GitHub Actions / check-msrv

version

rustc >= 1.2.3 should have been 1.78.0

<details>
<summary>Security concerns</summary>
Expand Down Expand Up @@ -188,7 +190,7 @@ cat oncall.md | mdq ':-: * :-: 2024-01-15'
# Development
Requires rustc >= 1.78.0
Requires rustc >= 1.2.3

Check failure on line 193 in README.md

View workflow job for this annotation

GitHub Actions / check-msrv

version

rustc >= 1.2.3 should have been 1.78.0
```bash
cargo build
Expand Down

0 comments on commit a0c37ec

Please sign in to comment.