From 567ed95fc2083bd3c83340f46b003d8446ae3400 Mon Sep 17 00:00:00 2001 From: Quentin Le Sceller Date: Thu, 9 May 2019 13:15:10 -0400 Subject: [PATCH] Set up CI with Azure Pipelines (#2744) Set up CI with Azure Pipelines --- .ci/install.yml | 21 +++++++++++ .ci/release-jobs | 0 .ci/release.yml | 50 +++++++++++++++++++++++++ .ci/test.yml | 10 +++++ .ci/win.patch | 15 ++++++++ .ci/windows-release.yml | 50 +++++++++++++++++++++++++ azure-pipelines.yml | 83 +++++++++++++++++++++++++++++++++++++++++ store/tests/pmmr.rs | 2 +- 8 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 .ci/install.yml mode change 100755 => 100644 .ci/release-jobs create mode 100644 .ci/release.yml create mode 100644 .ci/test.yml create mode 100644 .ci/win.patch create mode 100644 .ci/windows-release.yml create mode 100644 azure-pipelines.yml diff --git a/.ci/install.yml b/.ci/install.yml new file mode 100644 index 0000000000..29c54b0307 --- /dev/null +++ b/.ci/install.yml @@ -0,0 +1,21 @@ +steps: + - script: | + curl -sSf -o rustup-init.exe https://win.rustup.rs + rustup-init.exe -y + echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin" + git apply .ci/win.patch + choco install -y llvm + displayName: Windows Install Rust + condition: eq( variables['Agent.OS'], 'Windows_NT' ) + - script: | + curl https://sh.rustup.rs -sSf | sh -s -- -y + echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin" + displayName: macOS Install Rust + condition: eq( variables['Agent.OS'], 'Darwin' ) + - script: | + curl https://sh.rustup.rs -sSf | sh -s -- -y + sudo apt-get update -yqq + sudo apt-get install -yqq --no-install-recommends libncursesw5-dev + echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin" + displayName: Linux Install Rust and Dependencies + condition: eq( variables['Agent.OS'], 'Linux' ) \ No newline at end of file diff --git a/.ci/release-jobs b/.ci/release-jobs old mode 100755 new mode 100644 diff --git a/.ci/release.yml b/.ci/release.yml new file mode 100644 index 0000000000..6033f7b426 --- /dev/null +++ b/.ci/release.yml @@ -0,0 +1,50 @@ +steps: + - script: 'cargo test --all' + displayName: Cargo Test All + condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + - script: 'cargo build --release' + displayName: Build Release + condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + - script: | + MY_TAG="$(Build.SourceBranch)" + MY_TAG=${MY_TAG#refs/tags/} + echo $MY_TAG + echo "##vso[task.setvariable variable=build.my_tag]$MY_TAG" + echo "##vso[task.setvariable variable=build.platform]$PLATFORM" + displayName: "Create my tag variable" + condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + - task: CopyFiles@2 + displayName: Copy assets + condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + inputs: + sourceFolder: '$(Build.SourcesDirectory)/target/release' + contents: 'grin' + targetFolder: '$(Build.BinariesDirectory)/grin' + - task: ArchiveFiles@2 + displayName: Gather assets + condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + inputs: + rootFolderOrFile: '$(Build.BinariesDirectory)/grin' + archiveType: 'tar' + tarCompression: 'gz' + archiveFile: '$(Build.ArtifactStagingDirectory)/grin-$(build.my_tag)-$(build.platform).tar.gz' + - script: | + openssl sha256 $(Build.ArtifactStagingDirectory)/grin-$(build.my_tag)-$(build.platform).tar.gz > $(Build.ArtifactStagingDirectory)/grin-$(build.my_tag)-$(build.platform)-sha256sum.txt + displayName: Create Checksum + condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + - task: GithubRelease@0 + displayName: Github release + condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + inputs: + gitHubConnection: 'ignopeverell' + repositoryName: 'mimblewimble/grin' + action: 'edit' + target: '$(build.sourceVersion)' + tagSource: 'manual' + tag: '$(build.my_tag)' + assets: | + $(Build.ArtifactStagingDirectory)/grin-$(build.my_tag)-$(build.platform).tar.gz + $(Build.ArtifactStagingDirectory)/grin-$(build.my_tag)-$(build.platform)-sha256sum.txt + title: '$(build.my_tag)' + assetUploadMode: 'replace' + addChangeLog: true \ No newline at end of file diff --git a/.ci/test.yml b/.ci/test.yml new file mode 100644 index 0000000000..65c9bee2f1 --- /dev/null +++ b/.ci/test.yml @@ -0,0 +1,10 @@ +steps: + - script: 'cargo test --all' + displayName: Windows Cargo Test + condition: and(eq( variables['Agent.OS'], 'Windows_NT' ), eq( variables['CI_JOB'], 'test-all' )) + - script: 'cargo test --all' + displayName: macOS Cargo Test + condition: and(eq( variables['Agent.OS'], 'Darwin' ), eq( variables['CI_JOB'], 'test-all' )) + - script: '.ci/general-jobs' + displayName: Linux Cargo Test + condition: eq( variables['Agent.OS'], 'Linux' ) \ No newline at end of file diff --git a/.ci/win.patch b/.ci/win.patch new file mode 100644 index 0000000000..09d54f28e5 --- /dev/null +++ b/.ci/win.patch @@ -0,0 +1,15 @@ +diff --git a/Cargo.toml b/Cargo.toml +index fc8615b6..5ffbf06f 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -45,8 +45,8 @@ cursive = { version = "0.11.0", default-features = false, features = ["pancurses + [target.'cfg(windows)'.dependencies.pancurses] + version = "0.16.0" + features = ["win32"] +-[target.'cfg(unix)'.dependencies] +-cursive = "0.11.0" ++#[target.'cfg(unix)'.dependencies] ++#cursive = "0.11.0" + + [build-dependencies] + built = "0.3" diff --git a/.ci/windows-release.yml b/.ci/windows-release.yml new file mode 100644 index 0000000000..070c5a7245 --- /dev/null +++ b/.ci/windows-release.yml @@ -0,0 +1,50 @@ +steps: + - script: 'cargo test --all' + displayName: Cargo Test All + condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + - script: 'cargo build --release' + displayName: Build Release + condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + - script: | + SET MY_TAG=$(Build.SourceBranch) + SET MY_TAG=%MY_TAG:~10% + echo %MY_TAG% + echo %PLATFORM% + echo ##vso[task.setvariable variable=build.my_tag]%MY_TAG% + echo ##vso[task.setvariable variable=build.platform]%PLATFORM% + displayName: "Create my tag variable" + condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + - task: CopyFiles@2 + displayName: Copy assets + condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + inputs: + sourceFolder: '$(Build.SourcesDirectory)\target\release' + contents: 'grin.exe' + targetFolder: '$(Build.BinariesDirectory)\grin' + - task: ArchiveFiles@2 + displayName: Gather assets + condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + inputs: + rootFolderOrFile: '$(Build.BinariesDirectory)\grin' + archiveType: 'zip' + archiveFile: '$(Build.ArtifactStagingDirectory)\grin-$(build.my_tag)-$(build.platform).zip' + - script: | + powershell -Command "get-filehash -algorithm sha256 $(Build.ArtifactStagingDirectory)\grin-$(build.my_tag)-$(build.platform).zip | Format-List |  Out-String | ForEach-Object { $_.Trim() } > $(Build.ArtifactStagingDirectory)\grin-$(build.my_tag)-$(build.platform)-sha256sum.txt" + displayName: Create Checksum + condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + - task: GithubRelease@0 + displayName: Github release + condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + inputs: + gitHubConnection: 'ignopeverell' + repositoryName: 'mimblewimble/grin' + action: 'edit' + target: '$(build.sourceVersion)' + tagSource: 'manual' + tag: '$(build.my_tag)' + assets: | + $(Build.ArtifactStagingDirectory)\grin-$(build.my_tag)-$(build.platform).zip + $(Build.ArtifactStagingDirectory)\grin-$(build.my_tag)-$(build.platform)-sha256sum.txt + title: '$(build.my_tag)' + assetUploadMode: 'replace' + addChangeLog: true diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000000..5c041509a8 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,83 @@ +# Copyright 2019 The Grin Developers +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +trigger: + branches: + include: + - master + - milestone/* + tags: + include: ['*'] + +pr: + branches: + include: ['*'] + +variables: + RUST_BACKTRACE: '1' + RUST_FLAGS: '-C debug-assertions' + +jobs: +- job: linux + pool: + vmImage: ubuntu-16.04 + strategy: + matrix: + servers: + CI_JOB: test + CI_JOB_ARGS: servers + chain/core/keychain: + CI_JOB: test + CI_JOB_ARGS: chain core keychain + pool/p2p/src: + CI_JOB: test + CI_JOB_ARGS: pool p2p src + api/util/store: + CI_JOB: test + CI_JOB_ARGS: api util store + release: + CI_JOB: release + PLATFORM: linux-amd64 + steps: + - template: '.ci/install.yml' + - template: '.ci/test.yml' + - template: '.ci/release.yml' +- job: macos + pool: + vmImage: macos-10.13 + strategy: + matrix: + test: + CI_JOB: test-all + release: + CI_JOB: release + PLATFORM: macos + steps: + - template: '.ci/install.yml' + - template: '.ci/test.yml' + - template: '.ci/release.yml' +- job: windows + pool: + vmImage: vs2017-win2016 + strategy: + matrix: + test: + CI_JOB: test-all + release: + CI_JOB: release + PLATFORM: win-x64 + steps: + - template: '.ci/install.yml' + - template: '.ci/test.yml' + - template: '.ci/windows-release.yml' diff --git a/store/tests/pmmr.rs b/store/tests/pmmr.rs index e3970540ef..e70717c658 100644 --- a/store/tests/pmmr.rs +++ b/store/tests/pmmr.rs @@ -776,7 +776,7 @@ fn cleanup_rewind_files_test() { &data_dir, expected, prefix_to_delete, - seconds_to_delete_after, + seconds_to_delete_after + 1, expected, ); // create some files with the save prefix that are old enough to delete, but will be saved because they don't start