manifest-schema: Improve quality as a library

This commit is contained in:
Taiki Endo
2025-01-28 16:36:10 +09:00
parent 22b428f64c
commit 5ad07d35ce
3 changed files with 81 additions and 7 deletions

View File

@@ -22,6 +22,8 @@ env:
RUST_BACKTRACE: 1
RUSTFLAGS: -D warnings
RUSTUP_MAX_RETRIES: 10
# NB: sync with miri job's --exclude option
EXCLUDE: --exclude install-action-internal-codegen
defaults:
run:
@@ -32,6 +34,16 @@ concurrency:
cancel-in-progress: true
jobs:
miri:
uses: taiki-e/github-actions/.github/workflows/miri.yml@main
with:
event_name: ${{ github.event_name }}
# NB: sync with env.EXCLUDE
args: --exclude install-action-internal-codegen
msrv:
uses: taiki-e/github-actions/.github/workflows/msrv.yml@main
with:
event_name: ${{ github.event_name }}
tidy:
uses: taiki-e/github-actions/.github/workflows/tidy.yml@main
permissions:
@@ -265,3 +277,25 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.create-pull-request.outputs.pull-request-number }}
if: github.repository_owner == 'taiki-e' && (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main') && steps.diff.outputs.success == 'false' && (steps.create-pull-request.outputs.pull-request-operation == 'created' || steps.create-pull-request.outputs.pull-request-operation == 'updated')
manifest-schema:
strategy:
fail-fast: false
matrix:
rust:
- stable
- beta
- nightly
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: taiki-e/checkout-action@v1
- uses: taiki-e/github-actions/install-rust@main
with:
toolchain: ${{ matrix.rust }}
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@cargo-minimal-versions
- run: cargo test --workspace --all-features ${EXCLUDE}
- run: cargo hack build --workspace --no-private --feature-powerset --no-dev-deps
- run: cargo minimal-versions build --workspace --no-private --detach-path-deps=skip-exact --all-features
- run: cargo minimal-versions build --workspace --no-private --detach-path-deps=skip-exact --all-features --direct

View File

@@ -2,16 +2,33 @@
name = "install-action-manifest-schema"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"
rust-version = "1.79" # Align to cargo-binstall: https://crates.io/crates/cargo-binstall
license = "Apache-2.0 OR MIT"
repository = "https://github.com/taiki-e/install-action"
keywords = []
categories = []
description = """
Structured access to the install-action manifests.
"""
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[package.metadata.cargo_check_external_types]
# The following are external types that are allowed to be exposed in our public API.
allowed_external_types = [
"semver::*",
"serde::*",
]
[lib]
doc-scrape-examples = false
# Note: semver and serde are public dependencies.
[dependencies]
semver = { version = "1", features = ["serde"] }
serde = "1"
serde_derive = "1"
serde = "1.0.165"
serde_derive = "1.0.165"
[lints]
workspace = true
[package.metadata.cargo_check_external_types]
allowed_external_types = ["semver::*", "serde::*"]

View File

@@ -1,5 +1,28 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
/*!
Structured access to the install-action manifests.
*/
#![doc(test(
no_crate_inject,
attr(
deny(warnings, rust_2018_idioms, single_use_lifetimes),
allow(dead_code, unused_variables)
)
))]
#![warn(
// Lints that may help when writing public library.
missing_debug_implementations,
// missing_docs,
clippy::alloc_instead_of_core,
// clippy::exhaustive_enums,
// clippy::exhaustive_structs,
clippy::impl_trait_in_params,
// clippy::missing_inline_in_public_items,
// clippy::std_instead_of_alloc,
// clippy::std_instead_of_core,
)]
#![allow(clippy::missing_panics_doc, clippy::too_long_first_doc_paragraph)]
use std::{
@@ -303,7 +326,7 @@ impl StringOrArray {
}
}
#[must_use]
pub fn map(&self, mut f: impl FnMut(&String) -> String) -> Self {
pub fn map<F: FnMut(&String) -> String>(&self, mut f: F) -> Self {
match self {
Self::String(s) => Self::String(f(s)),
Self::Array(v) => Self::Array(v.iter().map(f).collect()),