Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow running additional setup steps post-install #32

Merged
merged 1 commit into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
src/setup.rs
8 changes: 8 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -21,13 +25,17 @@ 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:
minrust: false
prefix: "bin_"
envs:
ENV_IS_SET: true
setup:
- script: touch src/setup.rs

resources:
repositories:
Expand Down
2 changes: 2 additions & 0 deletions azure/cargo-check.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
parameters:
rust: stable
benches: false
setup: []

jobs:
- job: ${{ parameters.name }}
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions azure/cargo-clippy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
parameters:
rust: stable
allow_fail: false
setup: []

jobs:
- job: ${{ parameters.name }}
Expand All @@ -15,6 +16,7 @@ jobs:
- template: install-rust.yml
parameters:
rust: ${{ parameters.rust }}
setup: ${{ parameters.setup }}
components:
- clippy
- script: cargo clippy --all
Expand Down
4 changes: 4 additions & 0 deletions azure/install-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ parameters:
rust: stable
components: []
targets: []
setup: []

steps:
# Linux and macOS.
Expand Down Expand Up @@ -50,3 +51,6 @@ steps:
cargo --version
rustup --version
displayName: Check installed rust version

# Run any user-specific setup steps
- ${{ parameters.setup }}
6 changes: 6 additions & 0 deletions azure/stages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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) }}
Expand All @@ -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) }}
Expand All @@ -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, '') }}:
Expand Down
5 changes: 5 additions & 0 deletions azure/style.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
parameters:
setup: []

jobs:
- template: rustfmt.yml
parameters:
Expand All @@ -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
2 changes: 2 additions & 0 deletions azure/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ parameters:
rust: stable
allow_fail: false
envs: {}
setup: []

jobs:
- job: ${{ parameters.name }}
Expand All @@ -28,6 +29,7 @@ jobs:
- template: install-rust.yml
parameters:
rust: ${{ parameters.rust }}
setup: ${{ parameters.setup }}
- script: cargo test --all
displayName: Run tests
env:
Expand Down
4 changes: 4 additions & 0 deletions azure/tests.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
parameters:
envs: {}
setup: []

jobs:
- template: test.yml
parameters:
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 }}
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;