summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.azure-pipelines.yml10
-rw-r--r--src/main.rs9
-rw-r--r--src/validate.rs10
3 files changed, 22 insertions, 7 deletions
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index a0ce0fd..d78709d 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -20,6 +20,9 @@ steps:
- checkout: self
fetchDepth: 1
+ # Store the GitHub authentication token in the git config. This allows the
+ # next steps to retrieve it.
+ persistCredentials: true
- bash: |
set -e
@@ -29,7 +32,12 @@ steps:
rustc -vV
displayName: Install Rust stable
- - bash: cargo run -- check
+ - bash: |
+ set -euo pipefail
+ # Extract the GitHub authentication token from the git config. The token
+ # will be used to authenticate with the GitHub API.
+ export GITHUB_TOKEN=$(git config -l | grep "\.extraheader=AUTHORIZATION" | awk '{print($3)}' | base64 -d | awk '{split($0,a,":"); print(a[2])}')
+ cargo run -- check --strict
displayName: Validate the repository contents
- bash: cargo fmt -- --check
diff --git a/src/main.rs b/src/main.rs
index c47f270..e46acae 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,7 +18,10 @@ use structopt::StructOpt;
#[structopt(name = "team", about = "manage the rust team members")]
enum Cli {
#[structopt(name = "check", help = "check if the configuration is correct")]
- Check,
+ Check {
+ #[structopt(long = "strict", help = "fail if optional checks are not executed")]
+ strict: bool,
+ },
#[structopt(
name = "add-person",
help = "add a new person from their GitHub profile"
@@ -65,8 +68,8 @@ fn run() -> Result<(), Error> {
let cli = Cli::from_args();
let data = Data::load()?;
match cli {
- Cli::Check => {
- crate::validate::validate(&data)?;
+ Cli::Check { strict } => {
+ crate::validate::validate(&data, strict)?;
}
Cli::AddPerson { ref github_name } => {
#[derive(serde::Serialize)]
diff --git a/src/validate.rs b/src/validate.rs
index 3965a58..82f2fee 100644
--- a/src/validate.rs
+++ b/src/validate.rs
@@ -27,7 +27,7 @@ static CHECKS: &[fn(&Data, &mut Vec<String>)] = &[
static GITHUB_CHECKS: &[fn(&Data, &GitHubApi, &mut Vec<String>)] = &[validate_github_usernames];
-pub(crate) fn validate(data: &Data) -> Result<(), Error> {
+pub(crate) fn validate(data: &Data, strict: bool) -> Result<(), Error> {
let mut errors = Vec::new();
for check in CHECKS {
@@ -41,8 +41,12 @@ pub(crate) fn validate(data: &Data) -> Result<(), Error> {
}
}
Err(err) => {
- warn!("couldn't perform checks relying on the GitHub API, some errors will not be detected");
- warn!("cause: {}", err);
+ if strict {
+ return Err(err);
+ } else {
+ warn!("couldn't perform checks relying on the GitHub API, some errors will not be detected");
+ warn!("cause: {}", err);
+ }
}
}