diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..74f68a7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +target/ +src/setup.rs diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 919efbb..adc16f3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -5,6 +5,8 @@ stages: codecov_token: $(CODECOV_TOKEN_SECRET) envs: ENV_IS_SET: true + setup: + - script: touch src/setup.rs # should work without code coverage token - template: azure/stages.yml parameters: @@ -13,6 +15,8 @@ stages: codecov_token: $(DOES_NOT_EXIST) envs: ENV_IS_SET: true + setup: + - script: touch src/setup.rs # also test with various other configuration changes - template: azure/stages.yml parameters: @@ -21,6 +25,8 @@ stages: prefix: "opts_" envs: ENV_IS_SET: true + setup: + - script: touch src/setup.rs # test binary-focused stages (no min rust version test) - template: azure/stages.yml parameters: @@ -28,6 +34,8 @@ stages: prefix: "bin_" envs: ENV_IS_SET: true + setup: + - script: touch src/setup.rs resources: repositories: diff --git a/azure/cargo-check.yml b/azure/cargo-check.yml index f546855..1aa24ee 100644 --- a/azure/cargo-check.yml +++ b/azure/cargo-check.yml @@ -1,6 +1,7 @@ parameters: rust: stable benches: false + setup: [] jobs: - job: ${{ parameters.name }} @@ -14,6 +15,7 @@ jobs: - template: install-rust.yml parameters: rust: ${{ parameters.rust }} + setup: ${{ parameters.setup }} - script: cargo check --all --bins --examples --tests displayName: Check compilation w/ default features - script: cargo check --all --bins --examples --tests --no-default-features diff --git a/azure/cargo-clippy.yml b/azure/cargo-clippy.yml index 05714e3..3d401cb 100644 --- a/azure/cargo-clippy.yml +++ b/azure/cargo-clippy.yml @@ -1,6 +1,7 @@ parameters: rust: stable allow_fail: false + setup: [] jobs: - job: ${{ parameters.name }} @@ -15,6 +16,7 @@ jobs: - template: install-rust.yml parameters: rust: ${{ parameters.rust }} + setup: ${{ parameters.setup }} components: - clippy - script: cargo clippy --all diff --git a/azure/install-rust.yml b/azure/install-rust.yml index c775fd4..140dc2c 100644 --- a/azure/install-rust.yml +++ b/azure/install-rust.yml @@ -3,6 +3,7 @@ parameters: rust: stable components: [] targets: [] + setup: [] steps: # Linux and macOS. @@ -50,3 +51,6 @@ steps: cargo --version rustup --version displayName: Check installed rust version + + # Run any user-specific setup steps + - ${{ parameters.setup }} diff --git a/azure/stages.yml b/azure/stages.yml index 84dbb22..9908f66 100644 --- a/azure/stages.yml +++ b/azure/stages.yml @@ -3,6 +3,7 @@ parameters: benches: false prefix: '' envs: {} + setup: [] stages: # the format here is so that we can have _two_ instances of this whole @@ -19,6 +20,7 @@ stages: parameters: name: cargo_check benches: ${{ parameters.benches }} + setup: ${{ parameters.setup }} - ${{ if ne(parameters.minrust, 'false') }}: # This represents the minimum Rust version supported. # Tests are not run as tests may require newer versions of rust. @@ -32,6 +34,7 @@ stages: - template: cargo-check.yml parameters: rust: ${{ parameters.minrust }} + setup: ${{ parameters.setup }} - stage: ${{ format('{0}test', parameters.prefix) }} ${{ if ne(parameters.prefix, '') }}: displayName: ${{ format('Test suite ({0})', parameters.prefix) }} @@ -42,6 +45,7 @@ stages: - template: tests.yml parameters: envs: ${{ parameters.envs }} + setup: ${{ parameters.setup }} - stage: ${{ format('{0}style', parameters.prefix) }} ${{ if ne(parameters.prefix, '') }}: displayName: ${{ format('Style linting ({0})', parameters.prefix) }} @@ -50,6 +54,8 @@ stages: dependsOn: ${{ format('{0}check', parameters.prefix) }} jobs: - template: style.yml + parameters: + setup: ${{ parameters.setup }} - ${{ if ne('', parameters.codecov_token) }}: - stage: ${{ format('{0}coverage', parameters.prefix) }} ${{ if ne(parameters.prefix, '') }}: diff --git a/azure/style.yml b/azure/style.yml index 7e5659a..821a9a7 100644 --- a/azure/style.yml +++ b/azure/style.yml @@ -1,3 +1,6 @@ +parameters: + setup: [] + jobs: - template: rustfmt.yml parameters: @@ -10,8 +13,10 @@ jobs: - template: cargo-clippy.yml parameters: name: clippy + setup: ${{ parameters.setup }} - template: cargo-clippy.yml parameters: name: clippy_beta + setup: ${{ parameters.setup }} rust: beta allow_fail: true diff --git a/azure/test.yml b/azure/test.yml index 09fda80..7a07610 100644 --- a/azure/test.yml +++ b/azure/test.yml @@ -2,6 +2,7 @@ parameters: rust: stable allow_fail: false envs: {} + setup: [] jobs: - job: ${{ parameters.name }} @@ -28,6 +29,7 @@ jobs: - template: install-rust.yml parameters: rust: ${{ parameters.rust }} + setup: ${{ parameters.setup }} - script: cargo test --all displayName: Run tests env: diff --git a/azure/tests.yml b/azure/tests.yml index 7b775a5..b7be1b0 100644 --- a/azure/tests.yml +++ b/azure/tests.yml @@ -1,5 +1,6 @@ parameters: envs: {} + setup: [] jobs: - template: test.yml @@ -7,14 +8,17 @@ jobs: name: cargo_test_stable cross: true # also test on Windows and macOS envs: ${{ parameters.envs }} + setup: ${{ parameters.setup }} - template: test.yml parameters: name: cargo_test_beta rust: beta envs: ${{ parameters.envs }} + setup: ${{ parameters.setup }} - template: test.yml parameters: name: cargo_test_nightly rust: nightly allow_fail: true envs: ${{ parameters.envs }} + setup: ${{ parameters.setup }} diff --git a/src/lib.rs b/src/lib.rs index 11fd6de..51cbbe0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,6 +16,12 @@ fn require_env() { std::env::var("ENV_IS_SET").unwrap(); } +#[cfg(test)] +#[test] +fn require_setup_file() { + include_str!("setup.rs"); +} + // check that minrust gets set correctly #[allow(unused_imports)] use std::sync::atomic::AtomicU64;