diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1a61cc4..04d90e8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,22 +9,148 @@ schedules: branches: include: - master +variables: + minrust: 1.40.0 + codecov_token: $(CODECOV_TOKEN_SECRET) + windows_vm: vs2017-win2016 + mac_vm: macos-10.14 + linux_vm: ubuntu-16.04 stages: +- stage: check + displayName: Compilation Check + jobs: + - job: cargo_check + displayName: cargo check + pool: + vmImage: ${{ variables.linux_vm }} + steps: + - template: install-rust.yml@templates + parameters: + rust: stable + - script: cargo check --all --bins --examples --tests + displayName: Default features + - job: cargo_check_bench + displayName: cargo check --benches + pool: + vmImage: ${{ variables.linux_vm }} + continueOnError: true + steps: + - template: install-rust.yml@templates + parameters: + rust: nightly + - script: cargo check --all --benches + displayName: Default features - stage: test + displayName: Test + jobs: + - job: test + displayName: Test + strategy: + matrix: + windows: + imageName: ${{ variables.windows_vm }} + target: 'x86_64-pc-windows-msvc' + channel: stable + mac: + imageName: ${{ variables.mac_vm }} + target: 'x86_64-apple-darwin' + channel: stable + linux: + imageName: ${{ variables.linux_vm }} + target: 'x86_64-unknown-linux-gnu' + channel: stable + linux_beta: + imageName: ${{ variables.linux_vm }} + target: 'x86_64-unknown-linux-gnu' + channel: beta + linux_nightly: + imageName: ${{ variables.linux_vm }} + target: 'x86_64-unknown-linux-gnu' + channel: nightly + continueOnError: ${{ eq(variables.channel, 'nightly') }} + pool: + vmImage: $(imageName) + steps: + - template: install-rust.yml@templates + parameters: + rust: $(channel) + targets: ["$(TARGET)"] + - script: cargo test --target $(TARGET) --all + displayName: cargo test + - script: cargo doc --target $(TARGET) --no-deps --all + displayName: cargo doc + - job: msrv + displayName: "${{ format('Minimum supported Rust version: {0}', variables.minrust) }}" + dependsOn: [] + pool: + vmImage: ${{ variables.linux_vm }} + steps: + - template: install-rust.yml@templates + parameters: + rust: ${{ variables.minrust }} + - script: cargo check --all + displayName: cargo check +- stage: style + displayName: Style checks dependsOn: [] jobs: - - template: default.yml@templates - parameters: - minrust: 1.40.0 - codecov_token: $(CODECOV_TOKEN_SECRET) + - job: "Committed" + pool: + vmImage: ${{ variables.linux_vm }} + steps: + - checkout: self + - template: v1/azdo-step.yml@gh-install + parameters: + git: crate-ci/committed + target: 'x86_64-unknown-linux-gnu' + to: $(Build.StagingDirectory)/tools + - script: | + echo "This project uses Conventional style, see https://www.conventionalcommits.org" + $(Build.StagingDirectory)/tools/committed HEAD~..HEAD^2 --no-merge-commit -vv + displayName: Committed + condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest')) + - job: style + displayName: Style linting + strategy: + matrix: + current: + channel: stable + next: + channel: beta + continueOnError: ${{ eq(variables.channel, 'beta') }} + pool: + vmImage: ${{ variables.linux_vm }} + steps: + - template: install-rust.yml@templates + parameters: + rust: $(channel) + components: + - rustfmt + - clippy + - script: cargo fmt --all -- --check + displayName: rustfmt + - script: cargo check --all + displayName: Warnings + env: + RUSTFLAGS: "-D warnings" + - script: cargo clippy --all -- -D warnings + displayName: clippy +- ${{ if ne('', variables.codecov_token) }}: + - stage: coverage + displayName: Code coverage + dependsOn: test + jobs: + - template: coverage.yml@templates + parameters: + token: ${{ variables.codecov_token }} - stage: codegen displayName: Verify Code-gen - dependsOn: [] + dependsOn: ["check"] jobs: - job: codegen pool: - vmImage: 'ubuntu-16.04' + vmImage: ${{ variables.linux_vm }} steps: - template: install-rust.yml@templates - script: | @@ -42,25 +168,6 @@ stages: - script: | cargo run --package varcon-codegen -- --output crates/varcon/src/codegen.rs --check displayName: Verify varcon-dict -- stage: committed - displayName: Lint History - dependsOn: [] - jobs: - - job: "Committed" - pool: - vmImage: 'ubuntu-16.04' - steps: - - checkout: self - - template: v1/azdo-step.yml@gh-install - parameters: - git: crate-ci/committed - target: 'x86_64-unknown-linux-gnu' - to: $(Build.StagingDirectory)/tools - - script: | - echo "This project uses Conventional style, see https://www.conventionalcommits.org" - $(Build.StagingDirectory)/tools/committed HEAD~..HEAD^2 --no-merge-commit -vv - displayName: Committed - condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest')) - stage: Release dependsOn: test condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/') @@ -69,15 +176,15 @@ stages: strategy: matrix: windows: - imageName: 'vs2017-win2016' + imageName: ${{ variables.windows_vm }} target: 'x86_64-pc-windows-msvc' crate_name: typos mac: - imageName: 'macos-10.14' + imageName: ${{ variables.mac_vm }} target: 'x86_64-apple-darwin' crate_name: typos linux: - imageName: 'ubuntu-16.04' + imageName: ${{ variables.linux_vm }} target: 'x86_64-unknown-linux-gnu' crate_name: typos pool: diff --git a/crates/typos/src/report.rs b/crates/typos/src/report.rs index 67dc312..6080fa8 100644 --- a/crates/typos/src/report.rs +++ b/crates/typos/src/report.rs @@ -1,3 +1,5 @@ +#![allow(clippy::needless_update)] + use std::borrow::Cow; use std::io::{self, Write}; diff --git a/crates/varcon/codegen/src/main.rs b/crates/varcon/codegen/src/main.rs index 524472e..cd19935 100644 --- a/crates/varcon/codegen/src/main.rs +++ b/crates/varcon/codegen/src/main.rs @@ -17,7 +17,7 @@ fn generate(file: &mut W) { writeln!(file, "use crate::*;").unwrap(); writeln!(file).unwrap(); - writeln!(file, "pub static VARCON: &'static [Cluster] = &[").unwrap(); + writeln!(file, "pub static VARCON: &[Cluster] = &[").unwrap(); for mut cluster in clusters { cluster.infer(); writeln!(file, "Cluster {{").unwrap(); diff --git a/crates/varcon/src/codegen.rs b/crates/varcon/src/codegen.rs index 1c8bc73..1267af4 100644 --- a/crates/varcon/src/codegen.rs +++ b/crates/varcon/src/codegen.rs @@ -3,7 +3,7 @@ use crate::*; -pub static VARCON: &'static [Cluster] = &[ +pub static VARCON: &[Cluster] = &[ Cluster { header: Some("abettor (level 50)"), entries: &[ diff --git a/src/config.rs b/src/config.rs index 9880df0..50ba6b8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -291,10 +291,7 @@ impl FileConfig { } pub fn identifier_leading_chars(&self) -> &str { - self.identifier_leading_chars - .as_ref() - .map(|s| s.as_str()) - .unwrap_or("_") + self.identifier_leading_chars.as_deref().unwrap_or("_") } pub fn identifier_include_digits(&self) -> bool { @@ -302,10 +299,7 @@ impl FileConfig { } pub fn identifier_include_chars(&self) -> &str { - self.identifier_include_chars - .as_ref() - .map(|s| s.as_str()) - .unwrap_or("_'") + self.identifier_include_chars.as_deref().unwrap_or("_'") } } @@ -327,7 +321,7 @@ impl FileSource for FileConfig { } fn identifier_leading_chars(&self) -> Option<&str> { - self.identifier_leading_chars.as_ref().map(|s| s.as_str()) + self.identifier_leading_chars.as_deref() } fn identifier_include_digits(&self) -> Option { @@ -335,7 +329,7 @@ impl FileSource for FileConfig { } fn identifier_include_chars(&self) -> Option<&str> { - self.identifier_include_chars.as_ref().map(|s| s.as_str()) + self.identifier_include_chars.as_deref() } }