-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
81 lines (65 loc) · 2.21 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: "Find Minimum Required Rust Version"
description: "Runs cargo-msrv on multiple paths and finds the highest minimum Rust version required."
author: "derrix060"
branding:
icon: "eye"
color: "red"
inputs:
paths:
description: "Comma-separated list of paths to run cargo-msrv. Defaults to the current directory"
default: "."
outputs:
highest-msrv:
description: "The highest minimum Rust version required."
value: ${{ steps.cargo-msrv.outputs.highest-msrv }}
runs:
using: "composite"
steps:
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: cargo
- name: Install cargo-msrv
shell: bash
run: cargo install cargo-msrv
- name: Setup jq
uses: dcarbone/[email protected]
- name: Run cargo-msrv for each path
id: cargo-msrv
shell: bash
run: |
set -euxo pipefail
# Split the input paths by commas
IFS=',' read -r -a paths <<< "${{ inputs.paths }}"
# Initialize the highest version variable
highest_msrv="0.0.0"
# Function to compare versions
compare_versions() {
if [[ "$1" == "$2" ]]; then
echo 0
elif [[ "$1" == "$(echo -e "$1\n$2" | sort -Vr | head -n1)" ]]; then
echo 1
else
echo 2
fi
}
# Loop through all paths and run cargo-msrv
for path in "${paths[@]}"; do
echo "Running cargo-msrv for $path"
cargo msrv find --path $path --output-format json --no-log 2>&1 | tee logs.txt
version=$(tail -1 logs.txt | jq -r '.result.version')
if [[ "$version" == "null" ]]; then
echo "Could not find MSRV for $path"
exit 1
fi
echo "Found MSRV $version for $path"
# Compare and store the highest version
result=$(compare_versions $highest_msrv $version)
if [[ "$result" -eq "2" ]]; then
echo "Found higher MSRV $version than $highest_msrv"
highest_msrv=$version
fi
done
echo "The highest MSRV is $highest_msrv"
# Set output
echo "highest-msrv=$highest_msrv" >> $GITHUB_OUTPUT