-
Notifications
You must be signed in to change notification settings - Fork 14
/
azure-pipelines.yml
134 lines (130 loc) · 4.56 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
trigger:
branches:
include: ['*']
tags:
include: ['*']
jobs:
- job: 'Clippy'
pool:
vmImage: 'ubuntu-latest'
container: 'rust:latest'
steps:
- script: rustup component add clippy
displayName: Install clippy
- script: cargo clippy --all
displayName: Run Clippy
- job: 'Rustfmt'
pool:
vmImage: 'ubuntu-latest'
container: 'rust:latest'
condition: eq(variables['Build.Reason'], 'PullRequest')
steps:
- script: rustup component add rustfmt
displayName: Install Rustfmt
- script: cargo fmt --all -- --check
displayName: Run fmt
- job: 'Test'
strategy:
matrix:
windows-stable:
imageName: 'windows-latest'
rustup_toolchain: stable
mac-stable:
imageName: 'macos-latest'
rustup_toolchain: stable
linux-stable:
imageName: 'ubuntu-latest'
rustup_toolchain: stable
linux-beta:
imageName: 'ubuntu-latest'
rustup_toolchain: beta
linux-nightly:
imageName: 'ubuntu-latest'
rustup_toolchain: nightly
pool:
vmImage: $(imageName)
steps:
- script: |
set -e
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain $RUSTUP_TOOLCHAIN
echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
displayName: "Install rust (*nix)"
condition: not(eq(variables['Agent.OS'], 'Windows_NT'))
- script: |
curl -sSf -o rustup-init.exe https://win.rustup.rs
rustup-init.exe -y --profile minimal --default-toolchain %RUSTUP_TOOLCHAIN%
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin"
displayName: "Install rust (windows)"
condition: eq(variables['Agent.OS'], 'Windows_NT')
- bash: |
rustup default $RUSTUP_TOOLCHAIN
rustup update $RUSTUP_TOOLCHAIN
displayName: "Set correct Rust version"
- script: cargo install diesel_cli --no-default-features --features sqlite-bundled
displayName: Install dependencies
- script: cargo build --all
displayName: Cargo build
- script: cargo test --all
displayName: Cargo test
- job: 'Cross'
strategy:
matrix:
musl:
target: 'x86_64-unknown-linux-musl'
imageName: 'ubuntu-latest'
gnu:
target: 'x86_64-unknown-linux-gnu'
imageName: 'ubuntu-latest'
mac:
target: 'x86_64-apple-darwin'
imageName: 'macos-latest'
pool:
vmImage: $(imageName)
steps:
- script: |
DATE="$(date +%Y-%m-%d)"
echo "##vso[task.setvariable variable=build.date]$DATE"
displayName: "Create date variable"
- script: |
MY_TAG="$(Build.SourceBranch)"
MY_TAG=${MY_TAG#refs/tags/}
echo $MY_TAG
echo "##vso[task.setvariable variable=build.my_tag]$MY_TAG"
displayName: "Create my tag variable"
- script: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
displayName: Install rust
- script: cargo install --git https://github.com/rust-embedded/cross
displayName: Install cross
- script: cross build --release --all --target $TARGET
displayName: Build
- task: CopyFiles@2
displayName: Copy assets
inputs:
sourceFolder: '$(Build.SourcesDirectory)/target/$(TARGET)/release'
contents: |
rrinlog
rrinlog-server
targetFolder: '$(Build.BinariesDirectory)/rrinlog'
- task: ArchiveFiles@2
displayName: Gather assets
inputs:
rootFolderOrFile: '$(Build.BinariesDirectory)/rrinlog'
archiveType: 'tar'
tarCompression: 'gz'
archiveFile: '$(Build.ArtifactStagingDirectory)/rrinlog-$(build.my_tag)-$(TARGET).tar.gz'
- task: GithubRelease@0
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
gitHubConnection: 'nickbabcock'
repositoryName: 'nickbabcock/rrinlog'
action: 'edit'
target: '$(build.sourceVersion)'
tagSource: 'manual'
tag: '$(build.my_tag)'
assets: '$(Build.ArtifactStagingDirectory)/rrinlog-$(build.my_tag)-$(TARGET).tar.gz'
title: '$(build.my_tag) - $(build.date)'
assetUploadMode: 'replace'
addChangeLog: false