Skip to content

Commit 832fe86

Browse files
Added Azure DevOps CI pipeline
Signed-off-by: iamabhishek-dubey <abhishekbhardwaj510@gmail.com>
1 parent ae99f5b commit 832fe86

File tree

7 files changed

+266
-49
lines changed

7 files changed

+266
-49
lines changed

.azure-pipelines/pipeline.yml

+196
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
---
2+
trigger:
3+
- master
4+
5+
pr:
6+
branches:
7+
include:
8+
- master
9+
10+
variables:
11+
- group: RuntimeVariables
12+
13+
stages:
14+
- stage: precheck
15+
jobs:
16+
- job: govet
17+
dependsOn: []
18+
pool:
19+
vmImage: "ubuntu-18.04"
20+
steps:
21+
- task: GoTool@0
22+
displayName: "Installing Golang"
23+
inputs:
24+
version: '1.16'
25+
- task: Go@0
26+
displayName: "Executing go vet"
27+
inputs:
28+
command: 'custom'
29+
customCommand: 'vet'
30+
31+
- stage: code_quality
32+
dependsOn: ["precheck"]
33+
jobs:
34+
- job: golang_ci_lint
35+
dependsOn: []
36+
pool:
37+
vmImage: "ubuntu-18.04"
38+
steps:
39+
- task: GoTool@0
40+
displayName: "Installing Golang"
41+
inputs:
42+
version: '1.16'
43+
- script: |
44+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.40.0
45+
./bin/golangci-lint run --timeout 5m0s ./...
46+
displayName: "Executing golang-ci lint"
47+
48+
- stage: dockerfile_lint
49+
dependsOn: ["precheck"]
50+
jobs:
51+
- job: dockerfile_lint
52+
dependsOn: []
53+
pool:
54+
vmImage: "ubuntu-18.04"
55+
steps:
56+
- script: scripts/dockerfile-linter.sh
57+
displayName: "Executing dockerlinter"
58+
59+
- stage: build
60+
dependsOn: ["code_quality"]
61+
jobs:
62+
- job: linux_amd64
63+
dependsOn: []
64+
pool:
65+
vmImage: "ubuntu-18.04"
66+
steps:
67+
- task: GoTool@0
68+
displayName: "Installing Golang"
69+
inputs:
70+
version: '1.16'
71+
- task: Go@0
72+
displayName: "Executing go build"
73+
inputs:
74+
command: 'build'
75+
arguments: '-o $(Agent.BuildDirectory)/k8s-vault-webhook'
76+
- task: ArchiveFiles@2
77+
displayName: 'Archiving go binary'
78+
inputs:
79+
rootFolderOrFile: '$(Agent.BuildDirectory)/k8s-vault-webhook'
80+
includeRootFolder: true
81+
archiveType: 'zip'
82+
archiveFile: '$(Build.ArtifactStagingDirectory)/compiled/k8s-vault-webhook-linux-amd64.zip'
83+
replaceExistingArchive: true
84+
- task: PublishBuildArtifacts@1
85+
inputs:
86+
PathtoPublish: '$(Build.ArtifactStagingDirectory)/compiled'
87+
ArtifactName: 'drop'
88+
publishLocation: 'Container'
89+
90+
- stage: build_image
91+
dependsOn: ["dockerfile_lint"]
92+
jobs:
93+
- job: linux_amd64
94+
dependsOn: []
95+
steps:
96+
- task: Docker@2
97+
displayName: "Building docker image"
98+
inputs:
99+
command: 'build'
100+
Dockerfile: '**/Dockerfile'
101+
tags: '$(Build.BuildId)'
102+
103+
- stage: release_binaries
104+
dependsOn: ["build", "build_image"]
105+
jobs:
106+
- job: goreleaser
107+
dependsOn: []
108+
pool:
109+
vmImage: "ubuntu-18.04"
110+
steps:
111+
- script: scripts/goreleaser.sh
112+
displayName: "Releasing go binaries"
113+
env:
114+
GITHUB_TOKEN: $(GithubToken)
115+
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
116+
117+
- stage: release_quay
118+
dependsOn: ["build", "build_image"]
119+
jobs:
120+
- job: quay
121+
dependsOn: []
122+
pool:
123+
vmImage: "ubuntu-18.04"
124+
steps:
125+
- task: Docker@2
126+
displayName: "Publish quay image"
127+
inputs:
128+
containerRegistry: 'QuayServiceConnection'
129+
repository: 'opstree/k8s-vault-webhook'
130+
command: 'buildAndPush'
131+
Dockerfile: '**/Dockerfile'
132+
tags: |
133+
latest
134+
$(Build.SourceBranchName)
135+
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
136+
137+
- stage: release_github_image
138+
dependsOn: ["build", "build_image"]
139+
jobs:
140+
- job: github
141+
dependsOn: []
142+
pool:
143+
vmImage: "ubuntu-18.04"
144+
steps:
145+
- task: Docker@2
146+
displayName: "Publish github image"
147+
inputs:
148+
containerRegistry: 'GithubServiceConnection'
149+
repository: 'ot-container-kit/k8s-vault-webhook/k8s-vault-webhook'
150+
command: 'buildAndPush'
151+
Dockerfile: '**/Dockerfile'
152+
tags: |
153+
latest
154+
$(Build.SourceBranchName)
155+
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
156+
157+
- stage: verify
158+
dependsOn: ["release_binaries", "release_quay", "release_github_image"]
159+
jobs:
160+
- job: verfiy
161+
dependsOn: []
162+
pool:
163+
vmImage: "ubuntu-18.04"
164+
steps:
165+
- task: DownloadBuildArtifacts@0
166+
displayName: "Downloading the artifact"
167+
inputs:
168+
buildType: 'current'
169+
downloadType: 'single'
170+
artifactName: 'drop'
171+
downloadPath: '$(System.ArtifactsDirectory)'
172+
- task: ExtractFiles@1
173+
displayName: "Extracting files"
174+
inputs:
175+
archiveFilePatterns: '$(System.ArtifactsDirectory)/drop/k8s-vault-webhook-linux-amd64.zip'
176+
destinationFolder: '$(Agent.BuildDirectory)'
177+
cleanDestinationFolder: false
178+
overwriteExistingFiles: true
179+
- script: |
180+
$(Agent.BuildDirectory)/k8s-vault-webhook --help
181+
displayName: "Executing k8s-vault-webhook"
182+
183+
- stage: docs
184+
dependsOn: ["release_binaries", "release_quay", "release_github_image"]
185+
jobs:
186+
- job: verfiy
187+
dependsOn: []
188+
pool:
189+
vmImage: "ubuntu-18.04"
190+
steps:
191+
- task: NodeTool@0
192+
displayName: "Installing NodeJS"
193+
inputs:
194+
versionSpec: '6.x'
195+
- script: scripts/build-docs.sh
196+
displayName: "Building documentation"

.github/workflows/workflow.yaml

-49
This file was deleted.

VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v4.0

scripts/build-docs.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
build_docs() {
4+
cd docs; yarn install
5+
cd docs; yarn build
6+
}
7+
8+
build_docs

scripts/dockerfile-linter.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
download_hadolint() {
4+
wget https://github.com/hadolint/hadolint/releases/download/v2.4.0/hadolint-Linux-x86_64
5+
chmod +x hadolint-Linux-x86_64
6+
}
7+
8+
execute_hadolint() {
9+
./hadolint-Linux-x86_64 Dockerfile --ignore DL3007 --ignore DL3018
10+
}
11+
12+
main() {
13+
download_hadolint
14+
execute_hadolint
15+
}
16+
17+
main

scripts/goreleaser.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
install_goreleaser() {
4+
curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh
5+
}
6+
7+
release() {
8+
install_goreleaser
9+
./bin/goreleaser release --rm-dist
10+
}
11+
12+
compare_version() {
13+
version=$(cat VERSION)
14+
if ! git tag -l | grep "${version}"
15+
then
16+
echo "git tag ${version}"
17+
git tag "${version}"
18+
release
19+
else
20+
git tag -l
21+
echo "Latest version is already updated"
22+
fi
23+
}
24+
25+
compare_version

scripts/spellcheck.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
install_spellcheck() {
4+
sudo apt-get update -y
5+
sudo apt-get install -y aspell
6+
}
7+
8+
run_spellcheck() {
9+
aspell ../README.md
10+
aspell ../CHANGELOG.md
11+
aspell ../DEVELOPMENT.md
12+
}
13+
14+
main() {
15+
install_spellcheck
16+
run_spellcheck
17+
}
18+
19+
main

0 commit comments

Comments
 (0)