mirror of
https://github.com/taiki-e/install-action.git
synced 2026-04-08 18:05:42 +08:00
manifest-schema: Apply clippy::exhaustive_enums and
clippy::exhaustive_structs
This commit is contained in:
@@ -431,23 +431,26 @@ fn main() -> Result<()> {
|
|||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
download_info.insert(platform, ManifestDownloadInfo {
|
download_info.insert(
|
||||||
url: Some(url),
|
platform,
|
||||||
etag,
|
ManifestDownloadInfo::new(
|
||||||
hash,
|
Some(url),
|
||||||
bin: base_download_info.bin.as_ref().or(base_info.bin.as_ref()).map(|s| {
|
etag,
|
||||||
s.map(|s| {
|
hash,
|
||||||
replace_vars(
|
base_download_info.bin.as_ref().or(base_info.bin.as_ref()).map(|s| {
|
||||||
s,
|
s.map(|s| {
|
||||||
package,
|
replace_vars(
|
||||||
Some(version),
|
s,
|
||||||
Some(platform),
|
package,
|
||||||
base_info.rust_crate.as_deref(),
|
Some(version),
|
||||||
)
|
Some(platform),
|
||||||
.unwrap()
|
base_info.rust_crate.as_deref(),
|
||||||
})
|
)
|
||||||
}),
|
.unwrap()
|
||||||
});
|
})
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
buf.clear();
|
buf.clear();
|
||||||
}
|
}
|
||||||
if download_info.is_empty() {
|
if download_info.is_empty() {
|
||||||
@@ -503,10 +506,7 @@ fn main() -> Result<()> {
|
|||||||
if semver_version.pre.is_empty() {
|
if semver_version.pre.is_empty() {
|
||||||
semver_versions.insert(semver_version.clone());
|
semver_versions.insert(semver_version.clone());
|
||||||
}
|
}
|
||||||
manifests.map.insert(
|
manifests.map.insert(reverse_semver, ManifestRef::Real(Manifest::new(download_info)));
|
||||||
reverse_semver,
|
|
||||||
ManifestRef::Real(Manifest { previous_stable_version: None, download_info }),
|
|
||||||
);
|
|
||||||
|
|
||||||
// update an existing manifests.json to avoid discarding work done in the event of a fetch error.
|
// update an existing manifests.json to avoid discarding work done in the event of a fetch error.
|
||||||
if existing_manifest.is_some() && !version_req_given {
|
if existing_manifest.is_some() && !version_req_given {
|
||||||
@@ -635,7 +635,7 @@ fn main() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let original_manifests = manifests.clone();
|
let original_manifests = manifests.clone();
|
||||||
let mut template = Some(ManifestTemplate { download_info: BTreeMap::new() });
|
let mut template = Some(ManifestTemplate::default());
|
||||||
'outer: for (version, manifest) in &mut manifests.map {
|
'outer: for (version, manifest) in &mut manifests.map {
|
||||||
let ManifestRef::Real(manifest) = manifest else {
|
let ManifestRef::Real(manifest) = manifest else {
|
||||||
continue;
|
continue;
|
||||||
@@ -652,10 +652,10 @@ fn main() -> Result<()> {
|
|||||||
break 'outer;
|
break 'outer;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
t.download_info.insert(*platform, ManifestTemplateDownloadInfo {
|
t.download_info.insert(
|
||||||
url: template_url,
|
*platform,
|
||||||
bin: template_bin,
|
ManifestTemplateDownloadInfo::new(template_url, template_bin),
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
|
|||||||
|
|
||||||
- Rename `ManifestDownloadInfo::checksum` field to `hash` to reduce manifest size.
|
- Rename `ManifestDownloadInfo::checksum` field to `hash` to reduce manifest size.
|
||||||
|
|
||||||
|
- Make `Version`, `Manifests`, `Manifest`, `ManifestDownloadInfo`, `ManifestTemplate`, `ManifestTemplateDownloadInfo`, and `HostPlatform` `#[non_exhaustive]`.
|
||||||
|
|
||||||
|
- Add `Manifest::new`, `ManifestDownloadInfo::new`, and `ManifestTemplateDownloadInfo::new`.
|
||||||
|
|
||||||
|
- Implement `Default` for `ManifestTemplate`.
|
||||||
|
|
||||||
- Remove `BaseManifest` and related types since they are unrelated to public manifests.
|
- Remove `BaseManifest` and related types since they are unrelated to public manifests.
|
||||||
|
|
||||||
## [0.1.1] - 2025-09-20
|
## [0.1.1] - 2025-09-20
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ Structured access to the install-action manifests.
|
|||||||
missing_debug_implementations,
|
missing_debug_implementations,
|
||||||
// missing_docs,
|
// missing_docs,
|
||||||
clippy::alloc_instead_of_core,
|
clippy::alloc_instead_of_core,
|
||||||
// clippy::exhaustive_enums,
|
clippy::exhaustive_enums,
|
||||||
// clippy::exhaustive_structs,
|
clippy::exhaustive_structs,
|
||||||
clippy::impl_trait_in_params,
|
clippy::impl_trait_in_params,
|
||||||
clippy::std_instead_of_alloc,
|
clippy::std_instead_of_alloc,
|
||||||
clippy::std_instead_of_core,
|
clippy::std_instead_of_core,
|
||||||
@@ -58,6 +58,7 @@ pub fn get_manifest_schema_branch_name() -> &'static str {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub struct Version {
|
pub struct Version {
|
||||||
pub major: Option<u64>,
|
pub major: Option<u64>,
|
||||||
pub minor: Option<u64>,
|
pub minor: Option<u64>,
|
||||||
@@ -195,6 +196,7 @@ impl<'de> Deserialize<'de> for Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub struct Manifests {
|
pub struct Manifests {
|
||||||
pub rust_crate: Option<String>,
|
pub rust_crate: Option<String>,
|
||||||
pub template: Option<ManifestTemplate>,
|
pub template: Option<ManifestTemplate>,
|
||||||
@@ -206,12 +208,14 @@ pub struct Manifests {
|
|||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
#[allow(clippy::exhaustive_enums)]
|
||||||
pub enum ManifestRef {
|
pub enum ManifestRef {
|
||||||
Ref { version: Version },
|
Ref { version: Version },
|
||||||
Real(Manifest),
|
Real(Manifest),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub struct Manifest {
|
pub struct Manifest {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub previous_stable_version: Option<Version>,
|
pub previous_stable_version: Option<Version>,
|
||||||
@@ -219,7 +223,15 @@ pub struct Manifest {
|
|||||||
pub download_info: BTreeMap<HostPlatform, ManifestDownloadInfo>,
|
pub download_info: BTreeMap<HostPlatform, ManifestDownloadInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Manifest {
|
||||||
|
#[must_use]
|
||||||
|
pub fn new(download_info: BTreeMap<HostPlatform, ManifestDownloadInfo>) -> Self {
|
||||||
|
Self { previous_stable_version: None, download_info }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub struct ManifestDownloadInfo {
|
pub struct ManifestDownloadInfo {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub url: Option<String>,
|
pub url: Option<String>,
|
||||||
@@ -230,13 +242,27 @@ pub struct ManifestDownloadInfo {
|
|||||||
pub bin: Option<StringOrArray>,
|
pub bin: Option<StringOrArray>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
impl ManifestDownloadInfo {
|
||||||
|
#[must_use]
|
||||||
|
pub fn new(
|
||||||
|
url: Option<String>,
|
||||||
|
etag: String,
|
||||||
|
hash: String,
|
||||||
|
bin: Option<StringOrArray>,
|
||||||
|
) -> Self {
|
||||||
|
Self { url, etag, hash, bin }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub struct ManifestTemplate {
|
pub struct ManifestTemplate {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub download_info: BTreeMap<HostPlatform, ManifestTemplateDownloadInfo>,
|
pub download_info: BTreeMap<HostPlatform, ManifestTemplateDownloadInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub struct ManifestTemplateDownloadInfo {
|
pub struct ManifestTemplateDownloadInfo {
|
||||||
pub url: String,
|
pub url: String,
|
||||||
/// Path to binaries in archive. Default to `${tool}${exe}`.
|
/// Path to binaries in archive. Default to `${tool}${exe}`.
|
||||||
@@ -244,8 +270,16 @@ pub struct ManifestTemplateDownloadInfo {
|
|||||||
pub bin: Option<StringOrArray>,
|
pub bin: Option<StringOrArray>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ManifestTemplateDownloadInfo {
|
||||||
|
#[must_use]
|
||||||
|
pub fn new(url: String, bin: Option<StringOrArray>) -> Self {
|
||||||
|
Self { url, bin }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
#[allow(clippy::exhaustive_enums)]
|
||||||
pub enum StringOrArray {
|
pub enum StringOrArray {
|
||||||
String(String),
|
String(String),
|
||||||
Array(Vec<String>),
|
Array(Vec<String>),
|
||||||
@@ -291,6 +325,7 @@ impl StringOrArray {
|
|||||||
// TODO: support musl with dynamic linking like wasmtime and cyclonedx's musl binaries.
|
// TODO: support musl with dynamic linking like wasmtime and cyclonedx's musl binaries.
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum HostPlatform {
|
pub enum HostPlatform {
|
||||||
x86_64_linux_gnu,
|
x86_64_linux_gnu,
|
||||||
x86_64_linux_musl,
|
x86_64_linux_musl,
|
||||||
|
|||||||
Reference in New Issue
Block a user