Skip to content

Commit

Permalink
feat: add action file
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed May 26, 2024
1 parent e40c445 commit 7469dfb
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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/[email protected]

- name: Determine MSRV
id: msrv
uses: ./

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/[email protected]
with:
toolchain: ${{ matrix.toolchain.version }}

- name: Test
run: cargo build
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.

7 changes: 7 additions & 0 deletions test-workspace/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "ci"
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!");
}

0 comments on commit 7469dfb

Please sign in to comment.