diff --git a/.ci/general-jobs b/.ci/general-jobs new file mode 100755 index 0000000..7580af1 --- /dev/null +++ b/.ci/general-jobs @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Copyright 2020 Revcore Technologies Ltd +# +# 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. + +# This script contains test-related jobs. + +case "${CI_JOB}" in + "test") + for dir in ${CI_JOB_ARGS}; do + printf "executing tests in directory \`%s\`...\n" "${dir}" + cd "${dir}" && \ + cargo test --release && \ + cd - > /dev/null || exit 1 + done + ;; +esac diff --git a/.ci/install.yml b/.ci/install.yml new file mode 100644 index 0000000..680851a --- /dev/null +++ b/.ci/install.yml @@ -0,0 +1,9 @@ +steps: + - script: | + choco install -y llvm + displayName: Windows Install LLVM + condition: eq( variables['Agent.OS'], 'Windows_NT' ) + - script: | + brew uninstall llvm + displayName: macOS Uninstall LLVM + condition: eq( variables['Agent.OS'], 'Darwin' ) diff --git a/.ci/release.yml b/.ci/release.yml new file mode 100644 index 0000000..7d28f98 --- /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: 'aloevera' + targetFolder: '$(Build.BinariesDirectory)/aloevera' + - task: ArchiveFiles@2 + displayName: Gather assets + condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + inputs: + rootFolderOrFile: '$(Build.BinariesDirectory)/aloevera' + archiveType: 'tar' + tarCompression: 'gz' + archiveFile: '$(Build.ArtifactStagingDirectory)/aloevera-$(build.my_tag)-$(build.platform).tar.gz' + - script: | + openssl sha256 $(Build.ArtifactStagingDirectory)/aloevera-$(build.my_tag)-$(build.platform).tar.gz > $(Build.ArtifactStagingDirectory)/aloevera-$(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: 'yeastplume' + repositoryName: 'yeastplume/aloevera' + action: 'edit' + target: '$(build.sourceVersion)' + tagSource: 'manual' + tag: '$(build.my_tag)' + assets: | + $(Build.ArtifactStagingDirectory)/aloevera-$(build.my_tag)-$(build.platform).tar.gz + $(Build.ArtifactStagingDirectory)/aloevera-$(build.my_tag)-$(build.platform)-sha256sum.txt + title: '$(build.my_tag)' + assetUploadMode: 'replace' + addChangeLog: true diff --git a/.ci/test.yml b/.ci/test.yml new file mode 100644 index 0000000..65c9bee --- /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/windows-release.yml b/.ci/windows-release.yml new file mode 100644 index 0000000..190612d --- /dev/null +++ b/.ci/windows-release.yml @@ -0,0 +1,53 @@ +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 clean' + displayName: Cargo Clean + 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: 'aloevera.exe' + targetFolder: '$(Build.BinariesDirectory)\aloevera' + - task: ArchiveFiles@2 + displayName: Gather assets + condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['CI_JOB'], 'release' )) + inputs: + rootFolderOrFile: '$(Build.BinariesDirectory)\aloevera' + archiveType: 'zip' + archiveFile: '$(Build.ArtifactStagingDirectory)\aloevera-$(build.my_tag)-$(build.platform).zip' + - script: | + powershell -Command "get-filehash -algorithm sha256 $(Build.ArtifactStagingDirectory)\aloevera-$(build.my_tag)-$(build.platform).zip | Format-List |  Out-String | ForEach-Object { $_.Trim() } > $(Build.ArtifactStagingDirectory)\aloevera-$(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: 'yeastplume' + repositoryName: 'yeastplume/aloevera' + action: 'edit' + target: '$(build.sourceVersion)' + tagSource: 'manual' + tag: '$(build.my_tag)' + assets: | + $(Build.ArtifactStagingDirectory)\aloevera-$(build.my_tag)-$(build.platform).zip + $(Build.ArtifactStagingDirectory)\aloevera-$(build.my_tag)-$(build.platform)-sha256sum.txt + title: '$(build.my_tag)' + assetUploadMode: 'replace' + addChangeLog: true