Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add action file #1

Merged
merged 1 commit into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: CI

on:
push:
branches: [main]
merge_group:
types: [checks_requested]
pull_request:
branches: [main]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
msrv:
name: MSRV

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Determine MSRV
id: msrv
uses: ./
with:
manifest-path: ./test-workspace/Cargo.toml

outputs:
msrv: "${{ steps.msrv.outputs.msrv }}"

build:
needs: msrv

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
toolchain:
- { name: msrv, version: "${{ needs.msrv.outputs.msrv }}" }
- { name: stable, version: stable }

name: Test / ${{ matrix.toolchain.name }}

steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain.version }}
cache-workspaces: ./test-workspace

- name: Test
run: cargo run --manifest-path=./test-workspace/Cargo.toml

combined:
runs-on: ubuntu-latest

name: Test Combined

steps:
- uses: actions/checkout@v4

- name: Install Rust (stable)
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache: false

- name: Determine MSRV
id: msrv
uses: ./
with:
manifest-path: ./test-workspace/Cargo.toml

- name: Install Rust (MSRV)
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ steps.msrv.outputs.msrv }}
cache-workspaces: ./test-workspace

- name: Test
run: cargo run --manifest-path=./test-workspace/Cargo.toml
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## 0.1.0

- Initial release.
30 changes: 30 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Determine minimum supported Rust version (MSRV) for workspace

description: |
Determine minimum supported Rust version (MSRV) for workspace for use in a job matrix.

inputs:
manifest-path:
description: Path to Cargo.toml manifest for workspace
required: false

runs:
using: composite

steps:
- name: Read MSRV from workspace manifest
id: read_msrv
shell: bash
run: |
cargo metadata --format-version=1 --manifest-path=${{ inputs.manifest-path || 'Cargo.toml' }} \
| jq -r 'first(.packages[] | select(.source == null and .rust_version)) | .rust_version' \
| sed -E 's/^1\.([0-9]{2})$/1\.\1\.0/' \
| xargs -0 printf "msrv=%s" \
| tee /dev/stderr \
>> "$GITHUB_OUTPUT"

outputs:
msrv:
description: |-
Minimum supported Rust version. E.g.: 1.72.1"
value: ${{ steps.read_msrv.outputs.msrv }}
74 changes: 74 additions & 0 deletions test-workspace/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions test-workspace/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "crate"
version = "1.0.0"
publish = false
edition = "2018"
rust-version = "1.72"

[dependencies]
detrim = "0.1"
3 changes: 3 additions & 0 deletions test-workspace/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}