-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
95 lines (90 loc) · 2.56 KB
/
.gitlab-ci.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
# _ __ _ ____ ___
# | |_ / _| _ __ __ _ ___(_) / ___|_ _|
# | __| |_ _____| '_ \ _____ / _` |/ __| | | | | |
# | |_| _|_____| |_) |_____| (_| | (__| |_ _ _ | |___ | |
# \__|_| | .__/ \__, |\___|_(_|_|_) \____|___|
# |_| |___/
#
# Build; create a release if we're on a tag.
#
# ...somewhat primitive, but works for now :)
workflow:
rules:
# run for merge requests
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
# don't run duplicate when we have a MR pipeline already going
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never
# run for all other branch commits
- if: '$CI_COMMIT_BRANCH'
# run for our version tags
- if: '$CI_COMMIT_TAG =~ /^v.*/'
# skip any others
stages:
- test
- publish
test:
stage: test
image: golang:1.19
variables:
GOPATH: $CI_PROJECT_DIR/.gocache
before_script:
- mkdir -p $GOPATH
script:
- make terraform-provider-gitlabci
- TF_ACC=1 go test -v --cover ./internal/provider
rules:
- if: '$CI_COMMIT_TAG =~ /^v.*/'
when: never
- changes:
- '*.go'
- 'go.mod'
- 'go.sum'
- 'internal/**/*.go'
- 'third_party/**/*.go'
cache:
key: $CI_JOB_STAGE
paths:
- .gocache
check-generated:
# ensure our generated docs are all built out the way they should be
stage: test
image: registry.gitlab.com/rsrchboy/golang-terraform:latest
script:
# docs
- go generate
# structs, schema, etc
- make force-regen
- git diff --exit-code --quiet
# generate return is the number of untracked files
- exit "$(git ls-files --others --exclude-standard | wc -l)"
after_script:
- git diff
- git ls-files --others --exclude-standard
rules:
# run for merge requests
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
publish:
stage: publish
image:
name: docker.io/goreleaser/goreleaser
entrypoint: ['']
variables:
GITLAB_TOKEN: $CI_JOB_TOKEN
GIT_DEPTH: 0
GOPATH: $CI_PROJECT_DIR/.gocache
rules:
- if: '$CI_COMMIT_TAG =~ /^v.*/'
before_script:
- mkdir -p $GOPATH
- apk update && apk add gnupg
- gpg-agent --daemon --default-cache-ttl 7200
- cat $GPG_SIGNING_KEY | gpg --import --batch --no-tty
- echo "frobnips!" > /tmp/foo
- gpg --detach-sig --yes -v --output=/dev/null --pinentry-mode loopback --passphrase-file "$GPG_PASSWORD" /tmp/foo
script:
- goreleaser release --rm-dist
cache:
key: $CI_JOB_STAGE
paths:
- .gocache