mirror of
https://dev.azure.com/schwarzit/schwarzit.stackit-public/_git/audit-go
synced 2026-02-18 13:42:01 +00:00
90 lines
2.6 KiB
YAML
90 lines
2.6 KiB
YAML
pool:
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
variables:
|
|
- name: bufVersion
|
|
value: v1.45.0
|
|
- name: golangCiLintVersion
|
|
value: v1.61.0
|
|
- name: goVersion
|
|
value: 1.23.0
|
|
- name: protobufValidateVersion
|
|
value: v1.1.0
|
|
- name: protobufVersion
|
|
value: v1.34.2
|
|
- name: GOPATH
|
|
value: '$(system.defaultWorkingDirectory)/gopath'
|
|
|
|
stages:
|
|
- stage: Build
|
|
jobs:
|
|
- job: GoBuildTest
|
|
displayName: Run build and tests
|
|
steps:
|
|
- task: GoTool@0
|
|
displayName: Install Go $(goVersion)
|
|
inputs:
|
|
version: $(goVersion)
|
|
|
|
- bash: |
|
|
set -e
|
|
go env -w GOMODCACHE="$(pwd)/.gomodcache"
|
|
displayName: Configure GOMODCACHE
|
|
|
|
- bash: |
|
|
set -e
|
|
go install google.golang.org/protobuf/cmd/protoc-gen-go@$(protobufVersion)
|
|
go install github.com/envoyproxy/protoc-gen-validate@$(protobufValidateVersion)
|
|
go install github.com/bufbuild/buf/cmd/buf@$(bufVersion)
|
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin $(golangCiLintVersion)
|
|
condition: succeeded()
|
|
displayName: Install build dependencies
|
|
|
|
- bash: |
|
|
set -e
|
|
echo on
|
|
go mod download
|
|
go mod tidy
|
|
go get ./...
|
|
condition: succeeded()
|
|
displayName: Download dependencies
|
|
|
|
- bash: |
|
|
set -e
|
|
echo on
|
|
rm -rf gen/
|
|
export PATH="$PATH:$GOPATH/bin"
|
|
buf format proto -w
|
|
cd proto
|
|
buf lint
|
|
buf generate
|
|
cd -
|
|
condition: succeeded()
|
|
displayName: Regenerate code from schema
|
|
|
|
- bash: |
|
|
set -e
|
|
echo on
|
|
export PATH="$PATH:$GOPATH/bin"
|
|
go fmt ./... && go vet ./... && golangci-lint run
|
|
condition: succeeded()
|
|
displayName: Format and lint
|
|
|
|
- bash: |
|
|
set -e
|
|
echo on
|
|
git diff HEAD --name-only --exit-code
|
|
condition: succeeded()
|
|
displayName: Check local changes after code generation and formatting
|
|
|
|
- bash: go build ./...
|
|
condition: succeeded()
|
|
displayName: Build
|
|
|
|
- bash: go test ./...
|
|
condition: succeeded()
|
|
displayName: Run tests
|
|
|
|
- bash: sudo rm -rf .gomodcache
|
|
condition: always()
|
|
displayName: Clean up the local cache (.gomodcache)
|