-
Notifications
You must be signed in to change notification settings - Fork 7
129 lines (117 loc) · 3.94 KB
/
build-integration.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: build-integration
env:
GO_VERSION: '1.17.3'
on:
pull_request:
types: [ opened, reopened, synchronize ]
push:
branches:
- master
concurrency:
# running pipeline per workflow per PR
group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }}
# Running a new pipeline will cancel any running pipelines that belong to the above group
cancel-in-progress: true
jobs:
unit:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- run: make test
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- run: bundle exec rubocop
check-deps-tidy:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- run: go mod tidy
- run: |
if ! git diff --exit-code -- go.mod go.sum; then
echo "Modules not tidy; please run 'go mod tidy'";
fi;
check-deps-updated:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- run: go mod download
- run: env GOPROXY=off go build -mod=readonly ./...
integration:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Build linux binary
run: make build-production
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run integration tests
run: make test-integration
need-release:
runs-on: ubuntu-latest
needs:
- integration
# If we are on main, check if we need to release
if: ${{ contains('refs/heads/main', github.ref) }}
outputs:
release: ${{ steps.get_version.outputs.release }}
version: ${{ steps.get_version.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# Check our DRAUPNIR_VERSION file against that in git, to see if we need to release
- name: Get version
id: get_version
run: |
CURRENT_VERSION="v$(cat DRAUPNIR_VERSION)"
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
if [[ $(git tag -l "${CURRENT_VERSION}") == "${CURRENT_VERSION}" ]]; then
echo "Version ${CURRENT_VERSION} is already released"
echo "release=false" >> $GITHUB_OUTPUT
else
echo "Version ${CURRENT_VERSION} can be released"
echo "release=true" >> $GITHUB_OUTPUT
fi
# expose env vars to release job
release-vars:
needs: need-release
runs-on: ubuntu-latest
# Only run if we will need to release
if: ${{ needs.need-release.outputs.release == 'true' }}
outputs:
go_version: ${{ env.GO_VERSION }}
steps:
- run: echo "Exposing env vars"
release:
needs:
- need-release
- release-vars
# Only release if we need to
if: ${{ needs.need-release.outputs.release == 'true' }}
uses: gocardless/github-actions/.github/workflows/go-gorelease.yml@master
with:
release_notes: $(git log --pretty=oneline --abbrev-commit --no-decorate --no-color "$(git describe --tags --abbrev=0)..HEAD" -- pkg cmd vendor internal | tee -a /tmp/release-notes)
repository: ${{ github.repository }}
go_version: ${{ needs.release-vars.outputs.go_version }}
secrets:
goreleaser_pat: ${{ secrets.GOCARDLESS_CI_ROBOT_TOKEN }}
service_account: ${{ secrets.GCR_PUSHER_SERVICE_ACCOUNT }}
workload_identity_provider: ${{ secrets.KEYLESS_PROVIDER_NAME }}