-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
169 lines (132 loc) · 4.34 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Security Hall of Fame Azure build pipeline
trigger:
- master
variables:
- group: DiscordWebhook-DeploymentMonitoring
stages:
- stage: Tests
jobs:
- job: check_clippy
displayName: Clippy
pool:
vmImage: 'ubuntu-latest'
steps:
- template: ci/installrust.yml
- script: rustup component add clippy
displayName: Install Clippy
- script: cargo clippy --all -- -D clippy::all
displayName: Clippy Check
- job: cargo_check
displayName: Cargo Check
dependsOn: check_clippy
strategy:
matrix:
Windows Stable:
imageName: 'vs2017-win2016'
rustup_toolchain: stable
Windows Nightly:
imageName: 'vs2017-win2016'
rustup_toolchain: nightly
Linux Stable:
imageName: 'ubuntu-latest'
rustup_toolchain: stable
Linux Nightly:
imageName: 'ubuntu-latest'
rustup_toolchain: nightly
pool:
vmImage: $(imageName)
steps:
- template: ci/installrust.yml
parameters:
rust_toolchain: $(rustup_toolchain)
- script: cargo check --all --bins
displayName: Cargo Check
- stage: Build
dependsOn: Tests
condition: succeeded()
jobs:
- job: build_release
displayName: Build Release
pool:
vmImage: 'ubuntu-latest'
steps:
- template: ci/installrust.yml
- script: cargo rustc --release -- -C lto -C link-args=-s
displayName: Release Compile
# Artifacts are needed for the startup test, even on PRs
- task: PublishPipelineArtifact@0
condition: succeeded()
inputs:
artifactName: 'security_hall'
targetPath: './target/release/security_hall'
- job: startup_test
displayName: Startup Test
dependsOn: build_release
condition: succeeded()
pool:
vmImage: 'ubuntu-latest'
steps:
- script: cp default_config.toml config.toml
displayName: Create config
- task: DownloadPipelineArtifact@1
displayName: Download Binary
inputs:
buildType: 'current'
artifactName: 'security_hall'
targetPath: '$(System.DefaultWorkingDirectory)'
- script: |
chmod +x ./security_hall
RESULTS=`./security_hall & last_pid=$!; sleep 5; kill -s TERM $last_pid`
echo "##vso[task.setvariable variable=startupResult;]$RESULTS"
displayName: Startup Panic Test
- script: 'echo $(startupResult); exit 1'
displayName: Startup failure
condition: contains(variables['startupResult'], 'thread')
- script: rm -rf config.toml ./records ./logs
displayName: Clean repo contents
- task: PublishPipelineArtifact@1
displayName: Generate deploy files
condition: succeeded()
inputs:
targetPath: '$(System.DefaultWorkingDirectory)'
artifact: 'DeployFiles'
- stage: Deploy
dependsOn: Build
condition: and(succeeded(), ne(variables['build.reason'], 'PullRequest'))
jobs:
- deployment: deploy_to_vm
displayName: Deploy to VM
environment: Production
pool:
vmImage: 'ubuntu-latest'
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@1
displayName: Download deploy files
inputs:
buildType: 'current'
artifactName: 'DeployFiles'
targetPath: '$(System.DefaultWorkingDirectory)'
- task: SSH@0
displayName: Stop Service
inputs:
sshEndpoint: 'GearBox'
runOptions: 'commands'
commands: 'sudo systemctl stop securityhall.service'
- task: CopyFilesOverSSH@0
displayName: Copy deployment to VM
inputs:
sshEndpoint: 'GearBox'
contents: '**'
targetFolder: './security_hall/'
failOnEmptySource: true
- task: SSH@0
displayName: Start Service
inputs:
sshEndpoint: 'GearBox'
runOptions: 'commands'
commands: 'chmod +x ./security_hall/security_hall; sudo systemctl start securityhall.service'
# Notify admins via Discord of the deployment
- template: ci/discordnotify.yml