forked from pact-foundation/pact-go
-
Notifications
You must be signed in to change notification settings - Fork 0
188 lines (179 loc) · 6.5 KB
/
test.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
on: [push, pull_request, workflow_dispatch]
name: Test
env:
PACT_BROKER_BASE_URL: https://testdemo.pactflow.io
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
PACT_DO_NOT_TRACK: true
APP_SHA: ${{ github.sha }}
APP_REF: ${{ github.ref }}
PACT_LD_LIBRARY_PATH: /tmp
# PACT_GO_LIB_DOWNLOAD_PATH: /tmp
LOG_LEVEL: DEBUG
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
test:
strategy:
fail-fast: false
matrix:
go-version: [ # https://endoflife.date/go
# 1.17.x, # Ended 02 Aug 2022
# 1.18.x, # Ended 01 Feb 2023
# 1.19.x, # Ended 06 Sep 2023
1.20.x, # Ended 06 Feb 2024
1.21.x,
1.22.x,
]
os: [ubuntu-latest, macos-12, macos-14, windows-latest]
cgo: [0,1]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- uses: actions/setup-java@v4 # Needed for the Avro example
with:
distribution: 'zulu'
java-version: '17'
- name: "Set CGO_ENABLED: ${{ matrix.cgo }}"
if: matrix.os == 'windows-latest'
run: |
"CGO_ENABLED=${{ matrix.cgo }}" >> $env:GITHUB_ENV
- name: "Set CGO_ENABLED: ${{ matrix.cgo }}"
if: matrix.os != 'windows-latest'
run: |
echo "CGO_ENABLED=${{ matrix.cgo }}" >> $GITHUB_ENV
- if: matrix.os == 'macos-14'
run: brew install protobuf
- name: Test
if: matrix.os == 'ubuntu-latest'
run: APP_BRANCH=${APP_REF:11} DOCKER_GATEWAY_HOST=172.17.0.1 DOCKER_HOST_HTTP="http://172.17.0.1" make
# - name: Set CGO_LDFLAGS / pact_ffi lib on PATH, and skip Avro plugin download
# if: matrix.os == 'windows-latest'
# run: |
# "CGO_LDFLAGS=-L$env:TMP" >> $env:GITHUB_ENV
# "$env:TMP" >> $env:GITHUB_PATH
# "SKIP_PLUGIN_AVRO=true" >> $env:GITHUB_ENV
- name: Set CGO_LDFLAGS / pact_ffi lib on PATH, and skip Avro plugin download
if: matrix.os == 'windows-latest'
run: |
"PACT_LD_LIBRARY_PATH=$env:TMP" >> $env:GITHUB_ENV
"SKIP_PLUGIN_AVRO=true" >> $env:GITHUB_ENV
- name: Test (unit)
if: matrix.os != 'ubuntu-latest'
run: make test
- name: Test (pact)
if: matrix.os != 'ubuntu-latest'
run: make pact_local
- name: Install goveralls
if: matrix.os != 'windows-latest'
run: go install github.com/mattn/goveralls@latest
- name: Send coverage
if: matrix.os != 'windows-latest'
run: goveralls -coverprofile=coverage.txt -service=github -parallel
- uses: actions/upload-artifact@v4
with:
name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.go-version }}-${{ matrix.os }}-cgo-${{ matrix.cgo }}.zip
path: ~/.pact/plugins/**/plugin.log
if: ${{ always() }}
test-containers:
runs-on: ubuntu-latest
name: ${{ matrix.variant }}-${{ matrix.arch }}-${{ matrix.go-version }}-test-container
strategy:
fail-fast: false
matrix:
arch:
- amd64
# - arm64
go-version: ["1.20", "1.21", "1.22"]
variant:
- debian
- alpine
cgo: [0,1]
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
if: matrix.arch != 'amd64'
uses: docker/setup-buildx-action@v3
with:
platforms: ${{ matrix.arch }}
- name: Test (unit)
run: make docker_test
env:
DOCKER_ARCH: ${{ matrix.arch }}
GO_VERSION: ${{ matrix.go-version }}
IMAGE_VARIANT: ${{ matrix.variant }}
CGO_ENABLED: ${{ matrix.cgo }}
- name: Test (pact)
run: make docker_pact
env:
DOCKER_ARCH: ${{ matrix.arch }}
GO_VERSION: ${{ matrix.go-version }}
IMAGE_VARIANT: ${{ matrix.variant }}
CGO_ENABLED: ${{ matrix.cgo }}
# - name: Build ${{ matrix.arch }} dockerfile
# run: |
# docker build \
# --platform ${{ matrix.arch }} \
# --build-arg VERSION=${{ matrix.go-version }} \
# -f Dockerfile.${{ matrix.variant }} \
# -t pactfoundation/pact-go-test-${{ matrix.go-version }} .
# - name: Test - ${{ matrix.arch }}
# if: matrix.arch == 'amd64'
# run: |
# docker run \
# --platform linux/${{ matrix.arch }} \
# -e LOG_LEVEL=${{ env.LOG_LEVEL }} \
# -e PACT_LD_LIBRARY_PATH=${{ env.PACT_LD_LIBRARY_PATH }} \
# --rm pactfoundation/pact-go-test-${{ matrix.go-version }} /bin/sh -c 'make test && make pact_local'
# - name: Test - ${{ matrix.arch }}
# if: matrix.arch == 'arm64'
# run: |
# docker run \
# --platform linux/${{ matrix.arch }} \
# -e LOG_LEVEL=${{ env.LOG_LEVEL }} \
# -e PACT_LD_LIBRARY_PATH=${{ env.PACT_LD_LIBRARY_PATH }} \
# -e SKIP_RACE=true \
# --rm pactfoundation/pact-go-test-${{ matrix.go-version }} /bin/sh -c 'make test && make pact_local'
finish:
needs: [test,test-containers]
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
# test-win:
# strategy:
# fail-fast: false
# matrix:
# go-version: [ # https://endoflife.date/go
# 1.20.x, # Ended 06 Feb 2024
# 1.21.x,
# 1.22.x,
# ]
# os: [windows-latest]
# runs-on: ${{ matrix.os }}
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - name: Install Go
# uses: actions/setup-go@v5
# with:
# go-version: ${{ matrix.go-version }}
# - name: Set CGO_LDFLAGS / pact_ffi lib on PATH, and skip Avro plugin download
# run: |
# "CGO_LDFLAGS=-L$env:TMP" >> $env:GITHUB_ENV
# "$env:TMP" >> $env:GITHUB_PATH
# "SKIP_PLUGIN_AVRO=true" >> $env:GITHUB_ENV
# - name: Build
# run: .\scripts\build.ps1
# - name: Test (unit)
# run: .\scripts\unit.ps1
# - name: Test (consumer)
# run: .\scripts\examples_consumer.ps1
# - name: Test (provider)
# run: .\scripts\examples_provider.ps1