Skip to content

Commit 150f9d1

Browse files
authored
Merge pull request #1 from actions-rust-lang/action
2 parents e40c445 + 5de5909 commit 150f9d1

File tree

6 files changed

+212
-0
lines changed

6 files changed

+212
-0
lines changed

.github/workflows/ci.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
merge_group:
7+
types: [checks_requested]
8+
pull_request:
9+
branches: [main]
10+
11+
permissions:
12+
contents: read
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
msrv:
20+
name: MSRV
21+
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Install Rust
28+
uses: actions-rust-lang/setup-rust-toolchain@v1
29+
30+
- name: Determine MSRV
31+
id: msrv
32+
uses: ./
33+
with:
34+
manifest-path: ./test-workspace/Cargo.toml
35+
36+
outputs:
37+
msrv: "${{ steps.msrv.outputs.msrv }}"
38+
39+
build:
40+
needs: msrv
41+
42+
runs-on: ubuntu-latest
43+
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
toolchain:
48+
- { name: msrv, version: "${{ needs.msrv.outputs.msrv }}" }
49+
- { name: stable, version: stable }
50+
51+
name: Test / ${{ matrix.toolchain.name }}
52+
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- name: Install Rust
57+
uses: actions-rust-lang/setup-rust-toolchain@v1
58+
with:
59+
toolchain: ${{ matrix.toolchain.version }}
60+
cache-workspaces: ./test-workspace
61+
62+
- name: Test
63+
run: cargo run --manifest-path=./test-workspace/Cargo.toml
64+
65+
combined:
66+
runs-on: ubuntu-latest
67+
68+
name: Test Combined
69+
70+
steps:
71+
- uses: actions/checkout@v4
72+
73+
- name: Install Rust (stable)
74+
uses: actions-rust-lang/setup-rust-toolchain@v1
75+
with:
76+
cache: false
77+
78+
- name: Determine MSRV
79+
id: msrv
80+
uses: ./
81+
with:
82+
manifest-path: ./test-workspace/Cargo.toml
83+
84+
- name: Install Rust (MSRV)
85+
uses: actions-rust-lang/setup-rust-toolchain@v1
86+
with:
87+
toolchain: ${{ steps.msrv.outputs.msrv }}
88+
cache-workspaces: ./test-workspace
89+
90+
- name: Test
91+
run: cargo run --manifest-path=./test-workspace/Cargo.toml

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## 0.1.0
4+
5+
- Initial release.

action.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Determine minimum supported Rust version (MSRV) for workspace
2+
3+
description: |
4+
Determine minimum supported Rust version (MSRV) for workspace for use in a job matrix.
5+
6+
inputs:
7+
manifest-path:
8+
description: Path to Cargo.toml manifest for workspace
9+
required: false
10+
11+
runs:
12+
using: composite
13+
14+
steps:
15+
- name: Read MSRV from workspace manifest
16+
id: read_msrv
17+
shell: bash
18+
run: |
19+
cargo metadata --format-version=1 --manifest-path=${{ inputs.manifest-path || 'Cargo.toml' }} \
20+
| jq -r 'first(.packages[] | select(.source == null and .rust_version)) | .rust_version' \
21+
| sed -E 's/^1\.([0-9]{2})$/1\.\1\.0/' \
22+
| xargs -0 printf "msrv=%s" \
23+
| tee /dev/stderr \
24+
>> "$GITHUB_OUTPUT"
25+
26+
outputs:
27+
msrv:
28+
description: |-
29+
Minimum supported Rust version. E.g.: 1.72.1"
30+
value: ${{ steps.read_msrv.outputs.msrv }}

test-workspace/Cargo.lock

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-workspace/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "crate"
3+
version = "1.0.0"
4+
publish = false
5+
edition = "2018"
6+
rust-version = "1.72"
7+
8+
[dependencies]
9+
detrim = "0.1"

test-workspace/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello, world!");
3+
}

0 commit comments

Comments
 (0)