|
| 1 | +version: "1" |
| 2 | + |
| 3 | +build: &build |
| 4 | + image: golang:1.13 |
| 5 | + environment: |
| 6 | + - CGO_ENABLED=0 |
| 7 | + - GOOS=linux |
| 8 | + - GO111MODULE=on |
| 9 | + commands: |
| 10 | + - go get github.com/axw/gocov/gocov |
| 11 | + - go get github.com/AlekSi/gocov-xml |
| 12 | + - go test -v -coverpkg=./... -coverprofile=coverage.txt ./... |
| 13 | + - go tool cover -func=coverage.txt |
| 14 | + - gocov convert coverage.txt | gocov-xml > ./coverage.xml |
| 15 | + - cat ./coverage.xml |
| 16 | + - go build -a -installsuffix cgo -o bin/plugin |
| 17 | + |
| 18 | +check-pr-code-coverage: &check-pr-code-coverage |
| 19 | + image: alpine:latest |
| 20 | + environment: |
| 21 | + - PLUGIN_COVERAGE_FILE=./coverage.xml |
| 22 | + - PLUGIN_COVERAGE_TYPE=cobertura |
| 23 | + - PLUGIN_SOURCE_DIRS=git.target.com/searchoss/pull-request-code-coverage |
| 24 | + - PLUGIN_RUN_DIR=bin |
| 25 | + - PLUGIN_GH_API_BASE_URL=https://git.target.com |
| 26 | + secrets: |
| 27 | + - source: pull_request_api_key |
| 28 | + target: plugin_gh_api_key |
| 29 | + commands: |
| 30 | + - apk --no-cache add ca-certificates git bash openssh-client |
| 31 | + - ./scripts/start.sh |
| 32 | +steps: |
| 33 | + - name: build-push |
| 34 | + image: golang:1.13 |
| 35 | + <<: *build |
| 36 | + ruleset: |
| 37 | + branch: |
| 38 | + - master |
| 39 | + event: |
| 40 | + - push |
| 41 | + |
| 42 | + - name : check-format-on-pr |
| 43 | + image: golang:1.13 |
| 44 | + commands: |
| 45 | + - make format |
| 46 | + ruleset: |
| 47 | + branch: |
| 48 | + - master |
| 49 | + event: |
| 50 | + - pull_request |
| 51 | + |
| 52 | + - name : check-lint-on-pr |
| 53 | + image: golangci/golangci-lint |
| 54 | + pull: true |
| 55 | + commands: |
| 56 | + - golangci-lint run |
| 57 | + ruleset: |
| 58 | + branch: |
| 59 | + - master |
| 60 | + event: |
| 61 | + - pull_request |
| 62 | + |
| 63 | + - name : build-on-pr |
| 64 | + <<: *build |
| 65 | + ruleset: |
| 66 | + branch: |
| 67 | + - master |
| 68 | + event: |
| 69 | + - pull_request |
| 70 | + |
| 71 | + - name: check-pr-code-coverage |
| 72 | + <<: *check-pr-code-coverage |
| 73 | + ruleset: |
| 74 | + branch: |
| 75 | + - master |
| 76 | + event: |
| 77 | + - pull_request |
| 78 | + when: |
| 79 | + event: [pull_request] |
| 80 | + |
| 81 | + - name: docker-pull-request |
| 82 | + image: docker.target.com/vela-plugins/docker:v0.2.3-1 |
| 83 | + ruleset: |
| 84 | + branch: |
| 85 | + - master |
| 86 | + event: |
| 87 | + - pull_request |
| 88 | + secrets: [ docker_password ] |
| 89 | + parameters: |
| 90 | + dry_run: true |
| 91 | + registry: docker.target.com |
| 92 | + repo: docker.target.com/app/pull-request-code-coverage |
| 93 | + tags: |
| 94 | + - latest |
| 95 | + - 1-${BUILD_COMMIT:0:7} |
| 96 | + dockerfile: Dockerfile |
| 97 | + username: svcpejkn001 |
| 98 | + |
| 99 | + |
| 100 | + - name: docker-push |
| 101 | + image: docker.target.com/vela-plugins/docker:v0.2.3-1 |
| 102 | + ruleset: |
| 103 | + branch: |
| 104 | + - master |
| 105 | + event: |
| 106 | + - push |
| 107 | + secrets: [ docker_password ] |
| 108 | + parameters: |
| 109 | + registry: docker.target.com |
| 110 | + repo: docker.target.com/app/pull-request-code-coverage |
| 111 | + tags: |
| 112 | + - latest |
| 113 | + - 1-${BUILD_COMMIT:0:7} |
| 114 | + dockerfile: Dockerfile |
| 115 | + username: svcpejkn001 |
| 116 | + |
| 117 | +secrets: |
| 118 | + - name: docker_password |
| 119 | + key: tap/vela-secrets/ARTIFACTORY_SVCPEJKN001_BINREPO |
| 120 | + engine: native |
| 121 | + type: shared |
| 122 | + |
0 commit comments