Skip to content

Commit

Permalink
Added Azure DevOps CI pipeline
Browse files Browse the repository at this point in the history
Signed-off-by: iamabhishek-dubey <abhishekbhardwaj510@gmail.com>
  • Loading branch information
iamabhishek-dubey committed May 15, 2021
1 parent ae99f5b commit 832fe86
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 49 deletions.
196 changes: 196 additions & 0 deletions .azure-pipelines/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
---
trigger:
- master

pr:
branches:
include:
- master

variables:
- group: RuntimeVariables

stages:
- stage: precheck
jobs:
- job: govet
dependsOn: []
pool:
vmImage: "ubuntu-18.04"
steps:
- task: GoTool@0
displayName: "Installing Golang"
inputs:
version: '1.16'
- task: Go@0
displayName: "Executing go vet"
inputs:
command: 'custom'
customCommand: 'vet'

- stage: code_quality
dependsOn: ["precheck"]
jobs:
- job: golang_ci_lint
dependsOn: []
pool:
vmImage: "ubuntu-18.04"
steps:
- task: GoTool@0
displayName: "Installing Golang"
inputs:
version: '1.16'
- script: |
curl -sSfL https://github.com/raw/golangci/golangci-lint/master/install.sh | sh -s v1.40.0
./bin/golangci-lint run --timeout 5m0s ./...
displayName: "Executing golang-ci lint"
- stage: dockerfile_lint
dependsOn: ["precheck"]
jobs:
- job: dockerfile_lint
dependsOn: []
pool:
vmImage: "ubuntu-18.04"
steps:
- script: scripts/dockerfile-linter.sh
displayName: "Executing dockerlinter"

- stage: build
dependsOn: ["code_quality"]
jobs:
- job: linux_amd64
dependsOn: []
pool:
vmImage: "ubuntu-18.04"
steps:
- task: GoTool@0
displayName: "Installing Golang"
inputs:
version: '1.16'
- task: Go@0
displayName: "Executing go build"
inputs:
command: 'build'
arguments: '-o $(Agent.BuildDirectory)/k8s-vault-webhook'
- task: ArchiveFiles@2
displayName: 'Archiving go binary'
inputs:
rootFolderOrFile: '$(Agent.BuildDirectory)/k8s-vault-webhook'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/compiled/k8s-vault-webhook-linux-amd64.zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/compiled'
ArtifactName: 'drop'
publishLocation: 'Container'

- stage: build_image
dependsOn: ["dockerfile_lint"]
jobs:
- job: linux_amd64
dependsOn: []
steps:
- task: Docker@2
displayName: "Building docker image"
inputs:
command: 'build'
Dockerfile: '**/Dockerfile'
tags: '$(Build.BuildId)'

- stage: release_binaries
dependsOn: ["build", "build_image"]
jobs:
- job: goreleaser
dependsOn: []
pool:
vmImage: "ubuntu-18.04"
steps:
- script: scripts/goreleaser.sh
displayName: "Releasing go binaries"
env:
GITHUB_TOKEN: $(GithubToken)
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))

- stage: release_quay
dependsOn: ["build", "build_image"]
jobs:
- job: quay
dependsOn: []
pool:
vmImage: "ubuntu-18.04"
steps:
- task: Docker@2
displayName: "Publish quay image"
inputs:
containerRegistry: 'QuayServiceConnection'
repository: 'opstree/k8s-vault-webhook'
command: 'buildAndPush'
Dockerfile: '**/Dockerfile'
tags: |
latest
$(Build.SourceBranchName)
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))

- stage: release_github_image
dependsOn: ["build", "build_image"]
jobs:
- job: github
dependsOn: []
pool:
vmImage: "ubuntu-18.04"
steps:
- task: Docker@2
displayName: "Publish github image"
inputs:
containerRegistry: 'GithubServiceConnection'
repository: 'ot-container-kit/k8s-vault-webhook/k8s-vault-webhook'
command: 'buildAndPush'
Dockerfile: '**/Dockerfile'
tags: |
latest
$(Build.SourceBranchName)
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))

- stage: verify
dependsOn: ["release_binaries", "release_quay", "release_github_image"]
jobs:
- job: verfiy
dependsOn: []
pool:
vmImage: "ubuntu-18.04"
steps:
- task: DownloadBuildArtifacts@0
displayName: "Downloading the artifact"
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(System.ArtifactsDirectory)'
- task: ExtractFiles@1
displayName: "Extracting files"
inputs:
archiveFilePatterns: '$(System.ArtifactsDirectory)/drop/k8s-vault-webhook-linux-amd64.zip'
destinationFolder: '$(Agent.BuildDirectory)'
cleanDestinationFolder: false
overwriteExistingFiles: true
- script: |
$(Agent.BuildDirectory)/k8s-vault-webhook --help
displayName: "Executing k8s-vault-webhook"
- stage: docs
dependsOn: ["release_binaries", "release_quay", "release_github_image"]
jobs:
- job: verfiy
dependsOn: []
pool:
vmImage: "ubuntu-18.04"
steps:
- task: NodeTool@0
displayName: "Installing NodeJS"
inputs:
versionSpec: '6.x'
- script: scripts/build-docs.sh
displayName: "Building documentation"
49 changes: 0 additions & 49 deletions .github/workflows/workflow.yaml

This file was deleted.

1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v4.0
8 changes: 8 additions & 0 deletions scripts/build-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

build_docs() {
cd docs; yarn install
cd docs; yarn build
}

build_docs
17 changes: 17 additions & 0 deletions scripts/dockerfile-linter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

download_hadolint() {
wget https://github.com/hadolint/hadolint/releases/download/v2.4.0/hadolint-Linux-x86_64
chmod +x hadolint-Linux-x86_64
}

execute_hadolint() {
./hadolint-Linux-x86_64 Dockerfile --ignore DL3007 --ignore DL3018
}

main() {
download_hadolint
execute_hadolint
}

main
25 changes: 25 additions & 0 deletions scripts/goreleaser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

install_goreleaser() {
curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh
}

release() {
install_goreleaser
./bin/goreleaser release --rm-dist
}

compare_version() {
version=$(cat VERSION)
if ! git tag -l | grep "${version}"
then
echo "git tag ${version}"
git tag "${version}"
release
else
git tag -l
echo "Latest version is already updated"
fi
}

compare_version
19 changes: 19 additions & 0 deletions scripts/spellcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

install_spellcheck() {
sudo apt-get update -y
sudo apt-get install -y aspell
}

run_spellcheck() {
aspell ../README.md
aspell ../CHANGELOG.md
aspell ../DEVELOPMENT.md
}

main() {
install_spellcheck
run_spellcheck
}

main

0 comments on commit 832fe86

Please sign in to comment.