From eb48d296569a5b91b819eafb2458bc6b0e6d4aed Mon Sep 17 00:00:00 2001 From: Lukas Pustina Date: Sat, 8 Feb 2020 10:30:56 +0100 Subject: [PATCH] Move CI from GitHub Actions to Azure DevOps Pipeline --- .ci/azure-pipelines.yml | 152 ++++++++++++++++++ .ci/templates/install_dependencies.yml | 4 + .ci/templates/install_rust.yml | 15 ++ .ci/templates/restore_cargo_and_target.yml | 8 + .ci/templates/save_cargo_and_target.yml | 8 + .ci/templates/version_information.yml | 12 ++ .github/workflows/ci.yml | 177 --------------------- 7 files changed, 199 insertions(+), 177 deletions(-) create mode 100644 .ci/azure-pipelines.yml create mode 100644 .ci/templates/install_dependencies.yml create mode 100644 .ci/templates/install_rust.yml create mode 100644 .ci/templates/restore_cargo_and_target.yml create mode 100644 .ci/templates/save_cargo_and_target.yml create mode 100644 .ci/templates/version_information.yml delete mode 100644 .github/workflows/ci.yml diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml new file mode 100644 index 0000000..750b2a0 --- /dev/null +++ b/.ci/azure-pipelines.yml @@ -0,0 +1,152 @@ +name: $(Build.sourceBranchName)-$(Date:yyyyMMdd)$(Rev:.r) + +# Set global variables +variables: + crate_name: 'centerdevice-rs' + rust_minimum_version: 1.36.0 + # cf. https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops + macos_image_name: 'macOS-latest' + linux_image_name: 'ubuntu-18.04' + +trigger: + branches: + include: ['*'] + tags: + include: ['*'] + +schedules: + - cron: "0 0 * * *" + displayName: Daily midnight build + branches: + include: + - master + +stages: + - stage: Check_Build_Test + displayName: "Check, Build, and Test" + jobs: + - job: Fmt + strategy: + matrix: + linux-nightly: + imageName: ${{ variables.linux_image_name }} + rustup_toolchain: nightly + pool: + vmImage: $(imageName) + steps: + - template: templates/install_rust.yml + parameters: + rustup_toolchain: $(rustup_toolchain) + - template: templates/version_information.yml + - script: cargo fmt -- --check + displayName: Run Fmt + + - job: Audit + strategy: + matrix: + linux-stable: + imageName: ${{ variables.linux_image_name }} + rustup_toolchain: stable + pool: + vmImage: $(imageName) + steps: + - template: templates/install_rust.yml + parameters: + rustup_toolchain: $(rustup_toolchain) + - template: templates/install_dependencies.yml + - script: cargo install cargo-audit + displayName: Install Cargo Audit + - template: templates/version_information.yml + - script: cargo audit + displayName: Run Cargo Audit + + - job: Clippy + strategy: + matrix: + mac-stable: + imageName: ${{ variables.macos_image_name }} + rustup_toolchain: stable + linux-stable: + imageName: ${{ variables.linux_image_name }} + rustup_toolchain: stable + pool: + vmImage: $(imageName) + steps: + - template: templates/install_rust.yml + parameters: + rustup_toolchain: $(rustup_toolchain) + - template: templates/install_dependencies.yml + - template: templates/version_information.yml + - script: cargo clippy --all --all-features -- -D warnings $(source ".clippy.args") + displayName: Run Clippy + + - job: 'Build_n_Test' + displayName: "Build and Test" + strategy: + matrix: + mac-minimum-${{ variables.rust_minimum_version }}: + imageName: ${{ variables.macos_image_name }} + rustup_toolchain: ${{ variables.rust_minimum_version }} + mac-stable: + imageName: ${{ variables.macos_image_name }} + rustup_toolchain: stable + mac-beta: + imageName: ${{ variables.macos_image_name }} + rustup_toolchain: beta + linux-minimum-${{ variables.rust_minimum_version }}: + imageName: ${{ variables.linux_image_name }} + rustup_toolchain: ${{ variables.rust_minimum_version }} + linux-stable: + imageName: ${{ variables.linux_image_name }} + rustup_toolchain: stable + linux-beta: + imageName: ${{ variables.linux_image_name }} + rustup_toolchain: beta + pool: + vmImage: $(imageName) + steps: + - template: templates/install_rust.yml + parameters: + rustup_toolchain: $(rustup_toolchain) + - template: templates/install_dependencies.yml + - template: templates/version_information.yml + - script: cargo build --all --all-features --tests --examples --benches + displayName: Cargo build + - script: cargo test --all --all-features --examples + displayName: Cargo test + + - stage: Publish_Release + displayName: "Publish Release" + dependsOn: Build_Release_Artefacts + condition: startsWith(variables['build.sourceBranch'], 'refs/tags/') + jobs: + - job: 'Publish_To_GitHub' + displayName: "Publish to GitHub" + steps: + - task: GitHubRelease@0 + displayName: "Create GitHub Release" + inputs: + gitHubConnection: 'lukaspustina-releaseupload' + repositoryName: '$(Build.Repository.Name)' + action: create + target: '$(Build.SourceVersion)' + tagSource: 'auto' + tagPattern: 'v.*' + tag: $(tagName) + isDraft: false + isPreRelease: false + addChangeLog: true + compareWith: 'lastFullRelease' + - job: 'Publish_To_Crates_Io' + displayName: "Publish to crates.io" + steps: + - template: templates/install_rust.yml + parameters: + rustup_toolchain: stable + - template: templates/install_dependencies.yml + - template: templates/version_information.yml + - script: cargo publish + displayName: "Cargo publish" + env: + CARGO_REGISTRY_TOKEN: $(CARGO_REGISTRY_TOKEN) + diff --git a/.ci/templates/install_dependencies.yml b/.ci/templates/install_dependencies.yml new file mode 100644 index 0000000..ea61b1f --- /dev/null +++ b/.ci/templates/install_dependencies.yml @@ -0,0 +1,4 @@ +steps: + - script: | + echo "No dependencies required for this crate." + displayName: Install Dependencies diff --git a/.ci/templates/install_rust.yml b/.ci/templates/install_rust.yml new file mode 100644 index 0000000..ca34a5d --- /dev/null +++ b/.ci/templates/install_rust.yml @@ -0,0 +1,15 @@ +parameters: + rustup_toolchain: stable + +steps: + - script: | + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${{ parameters.rustup_toolchain }} + echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin" + displayName: Install rust ${{ parameters.rustup_toolchain }} + - script: rustup default ${{ parameters.rustup_toolchain }} + displayName: Setting rust default toolchain to ${{ parameters.rustup_toolchain }} + - script: rustup component add clippy + displayName: Install clippy + - script: rustup component add rustfmt + displayName: Install rustfmt + diff --git a/.ci/templates/restore_cargo_and_target.yml b/.ci/templates/restore_cargo_and_target.yml new file mode 100644 index 0000000..f691f38 --- /dev/null +++ b/.ci/templates/restore_cargo_and_target.yml @@ -0,0 +1,8 @@ +steps: + - download: current + artifact: Cargo + displayName: Restoring .cargo directory + - publish: current + artifact: Target + displayName: Restoring target directory + diff --git a/.ci/templates/save_cargo_and_target.yml b/.ci/templates/save_cargo_and_target.yml new file mode 100644 index 0000000..f18f5c4 --- /dev/null +++ b/.ci/templates/save_cargo_and_target.yml @@ -0,0 +1,8 @@ +steps: + - publish: /home/vsts/.cargo + artifact: Cargo + displayName: Storing .cargo directory + - publish: $(Build.SourcesDirectory)/target + artifact: Target + displayName: Storing target directory + diff --git a/.ci/templates/version_information.yml b/.ci/templates/version_information.yml new file mode 100644 index 0000000..fbc0a89 --- /dev/null +++ b/.ci/templates/version_information.yml @@ -0,0 +1,12 @@ +steps: + - script: | + rustup --version + rustup toolchain list + rustc --version + cargo --version + cargo --list + cargo clippy --version && echo "Clippy installed" + cargo fmt --version && echo "Rustfmt installed" + clang --version && echo "Clang installed" + displayName: Gather Build Environment Information + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 922e0da..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,177 +0,0 @@ -on: - push: - pull_request: - schedule: - - cron: '01 01 * * *' - -name: CI - -jobs: - check: - name: Check - runs-on: ${{ matrix.os.name }} - strategy: - fail-fast: false - matrix: - os: - - name: ubuntu-latest - allow_fail: false - - name: macOS-latest - allow_fail: false - rust: - - name: 1.36.0 - allow_fail: false - - name: stable - allow_fail: false - - name: beta - allow_fail: true - - name: nightly - allow_fail: true - steps: - - name: Checkout sources - uses: actions/checkout@v1 - - - name: Install toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust.name }} - override: true - - - name: Run cargo check - uses: actions-rs/cargo@v1 - with: - toolchain: ${{ matrix.rust.name }} - command: check - continue-on-error: ${{ matrix.os.allow_fail || matrix.rust.allow_fail }} - - audit: - name: Cargo Audit - runs-on: ${{ matrix.os.name }} - strategy: - matrix: - os: - - name: ubuntu-latest - - name: macOS-latest - rust: - - name: stable - steps: - - name: Checkout sources - uses: actions/checkout@v1 - - - name: Install toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust.name }} - override: true - - - name: Install cargo audit - run: cargo install cargo-audit - - - name: Run cargo audit - uses: actions-rs/cargo@v1 - with: - command: audit - args: --deny-warnings - - clippy: - name: Clippy - runs-on: ${{ matrix.os.name }} - strategy: - matrix: - os: - - name: ubuntu-latest - - name: macOS-latest - steps: - - name: Checkout sources - uses: actions/checkout@v1 - - - id: component - name: Search for latest nightly clippy - uses: actions-rs/components-nightly@v1 - with: - component: clippy - - - name: Install nightly toolchain with clippy available - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ steps.component.outputs.toolchain }} - override: true - - - name: Install clippy - run: rustup component add clippy - - - name: Run cargo clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - # For lints see /.clippy.args - args: -- -D warnings -A renamed_and_removed_lints -A clippy::match_bool -A clippy::get_unwrap -A clippy::new_without_default -A clippy::identity-conversion -A clippy::needless_lifetimes - - rustfmt: - name: Format - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v1 - - - id: component - name: Search for latest nightly rustfmt - uses: actions-rs/components-nightly@v1 - with: - target: x86_64-unknown-linux-gnu - component: rustfmt - - - name: Install nightly toolchain with rustfmt available - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ steps.component.outputs.toolchain }} - override: true - - - name: Install rustfmt - run: rustup component add rustfmt - - - name: Run cargo fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - test: - name: Test - runs-on: ${{ matrix.os.name }} - strategy: - fail-fast: false - matrix: - os: - - name: ubuntu-latest - allow_fail: false - - name: macOS-latest - allow_fail: false - rust: - - name: 1.36.0 - allow_fail: false - - name: stable - allow_fail: false - - name: beta - allow_fail: true - - name: nightly - allow_fail: true - - steps: - - name: Checkout sources - uses: actions/checkout@v1 - - - name: Install toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust.name }} - override: true - - - name: Run cargo check - uses: actions-rs/cargo@v1 - with: - toolchain: ${{ matrix.rust.name }} - command: test - args: --release - continue-on-error: ${{ matrix.os.allow_fail || matrix.rust.allow_fail }} -