Use string value for ref-type check (#897)
This commit is contained in:
parent
32f3132997
commit
a846a728f1
10
.github/workflows/build.yaml
vendored
10
.github/workflows/build.yaml
vendored
@ -123,12 +123,12 @@ jobs:
|
||||
sudo apt-get install ripgrep
|
||||
./bin/forbid
|
||||
|
||||
- name: Prerelease Check
|
||||
id: is_prerelease
|
||||
run: cargo run --package prerelease -- --reference ${{ github.ref }}
|
||||
- name: Ref Type
|
||||
id: ref-type
|
||||
run: cargo run --package ref-type -- --reference ${{ github.ref }}
|
||||
|
||||
- name: Test Install Script With Explicit Target
|
||||
if: matrix.os != 'windows-2016' && steps.is_prerelease.outputs.value
|
||||
if: matrix.os != 'windows-2016' && steps.ref-type.outputs.value != 'release'
|
||||
run: |
|
||||
cd `mktemp -d`
|
||||
cat $GITHUB_WORKSPACE/docs/install.sh | bash -s -- --target ${{ matrix.target }} --to .
|
||||
@ -137,7 +137,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Test Install Script Without Explicit Target
|
||||
if: matrix.os != 'windows-2016' && steps.is_prerelease.outputs.value
|
||||
if: matrix.os != 'windows-2016' && steps.ref-type.outputs.value != 'release'
|
||||
run: |
|
||||
cd `mktemp -d`
|
||||
cat $GITHUB_WORKSPACE/docs/install.sh | bash -s -- --to .
|
||||
|
18
Cargo.lock
generated
18
Cargo.lock
generated
@ -288,15 +288,6 @@ version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
||||
|
||||
[[package]]
|
||||
name = "prerelease"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"executable-path",
|
||||
"regex",
|
||||
"structopt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pretty_assertions"
|
||||
version = "0.7.2"
|
||||
@ -400,6 +391,15 @@ dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ref-type"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"executable-path",
|
||||
"regex",
|
||||
"structopt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.5.4"
|
||||
|
@ -14,7 +14,7 @@ keywords = ["command-line", "task", "runner", "development", "utility"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace]
|
||||
members = [".", "bin/prerelease"]
|
||||
members = [".", "bin/ref-type"]
|
||||
|
||||
[dependencies]
|
||||
ansi_term = "0.12.0"
|
||||
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "prerelease"
|
||||
name = "ref-type"
|
||||
version = "0.0.0"
|
||||
authors = ["Casey Rodarmor <casey@rodarmor.com>"]
|
||||
edition = "2018"
|
@ -13,8 +13,14 @@ fn main() {
|
||||
let regex = Regex::new("^refs/tags/[[:digit:]]+[.][[:digit:]]+[.][[:digit:]]+$")
|
||||
.expect("Failed to compile release regex");
|
||||
|
||||
println!(
|
||||
"::set-output name=value::{}",
|
||||
!regex.is_match(&arguments.reference)
|
||||
);
|
||||
let value = if regex.is_match(&arguments.reference) {
|
||||
"release"
|
||||
} else {
|
||||
"other"
|
||||
};
|
||||
|
||||
eprintln!("ref: {}", arguments.reference);
|
||||
eprintln!("value: {}", value);
|
||||
|
||||
println!("::set-output name=value::{}", value);
|
||||
}
|
@ -2,7 +2,7 @@ use executable_path::executable_path;
|
||||
use std::{process::Command, str};
|
||||
|
||||
fn stdout(reference: &str) -> String {
|
||||
let output = Command::new(executable_path("prerelease"))
|
||||
let output = Command::new(executable_path("ref-type"))
|
||||
.args(&["--reference", reference])
|
||||
.output()
|
||||
.unwrap();
|
||||
@ -13,30 +13,30 @@ fn stdout(reference: &str) -> String {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn junk_is_prerelease() {
|
||||
assert_eq!(stdout("refs/tags/asdf"), "::set-output name=value::true\n");
|
||||
fn junk_is_other() {
|
||||
assert_eq!(stdout("refs/tags/asdf"), "::set-output name=value::other\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valid_version_is_not_prerelease() {
|
||||
fn valid_version_is_release() {
|
||||
assert_eq!(
|
||||
stdout("refs/tags/0.0.0"),
|
||||
"::set-output name=value::false\n"
|
||||
"::set-output name=value::release\n"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valid_version_with_trailing_characters_is_prerelease() {
|
||||
fn valid_version_with_trailing_characters_is_other() {
|
||||
assert_eq!(
|
||||
stdout("refs/tags/0.0.0-rc1"),
|
||||
"::set-output name=value::true\n"
|
||||
"::set-output name=value::other\n"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valid_version_with_lots_of_digits_is_not_prerelease() {
|
||||
fn valid_version_with_lots_of_digits_is_release() {
|
||||
assert_eq!(
|
||||
stdout("refs/tags/01232132.098327498374.43268473849734"),
|
||||
"::set-output name=value::false\n"
|
||||
"::set-output name=value::release\n"
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue
Block a user