-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (181 loc) · 7.36 KB
/
buildpack-integration-test.yml
File metadata and controls
185 lines (181 loc) · 7.36 KB
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
name: Buildpack Integration Test
on:
workflow_call:
inputs:
http-builder-source:
description: HTTP function source; relative to repo root
type: string
required: true
http-builder-target:
description: HTTP function target
type: string
required: true
cloudevent-builder-source:
description: CloudEvent function source; relative to repo root
type: string
required: true
cloudevent-builder-target:
description: CloudEvent function target
type: string
required: true
builder-runtime:
description: GCF runtime (e.g. 'go116')
type: string
required: true
builder-runtime-version:
description: GCF runtime version (e.g. 3.7.0 for python37 runtime or 1.16 for go116)
type: string
default: ''
required: false
builder-url:
description: Builder image including builder tag to use while building. (e.g. gcr.io/gae-runtimes/buildpacks/go/builder:latest or gcr.io/buildpacks/builder:latest )
type: string
default: ''
required: false
event-builder-source:
description: Background function source; relative to repo root
type: string
required: false
event-builder-target:
description: Background function target
type: string
required: false
prerun:
description: Bash script to run before test; relative to repo root
type: string
required: false
start-delay:
description: Start delay, in seconds, between starting the containerized function and sending test requests
type: number
required: false
default: 1
output-file:
description: The output file conformance test files should write to for verification; relative to the source code directory
type: string
required: false
default: 'function_output.json'
builder-tag:
description: GCF builder image tag
type: string
default: 'latest'
required: false
conformance-client-version:
# Can be used to pin to older conformance test standards while
# developing a Functions Framework
description: Conformance test client version
type: string
default: 'latest'
required: false
conformance-action-version:
# Can be used to pin to older conformance GitHub Actions if there are
# breaking changes
description: Conformance GitHub Actions version by git ref
type: string
default: 'main'
required: false
jobs:
# Download and cache the Functions Framework conformance test client
download-conformance-client:
runs-on: ubuntu-latest
outputs:
# Pass the conformance client version key to the next job
# so the client can be retrieved from the GitHub cache.
cache-key: ${{ steps.set-cached-client-version.outputs.key }}
steps:
# Checkout the conformance repo at the specified branch and refer to the
# included GitHub Actions by local path. This effectively "versions"
# this Workflow by enforcing the the Actions and Workflow are at the
# same commit.
- name: Write GitHub context to log
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Checkout functions-framework-conformance
uses: actions/checkout@v3
with:
repository: 'GoogleCloudPlatform/functions-framework-conformance'
ref: ${{ inputs.conformance-action-version }}
# RESOLVE CONFORMANCE CLIENT VERSION
- name: Set conformance test client version from Workflow input
run: echo CLIENT_VERSION=${{ inputs.conformance-client-version }} >> $GITHUB_ENV
- name: Resolve latest conformance test client version
if: ${{ inputs.conformance-client-version == 'latest' }}
id: conformance-client-latest
uses: ./.github/actions/client/resolve-latest
- name: Set conformance test client version from latest
if: ${{ inputs.conformance-client-version == 'latest' }}
run: echo CLIENT_VERSION=${{ steps.conformance-client-latest.outputs.version }} >> $GITHUB_ENV
- name: Set cache key for client version
id: set-cached-client-version
run: echo "::set-output name=key::conformance-client-${{ env.CLIENT_VERSION }}"
# INSTALL CONFORMANCE CLIENT
- name: Check for cached conformance test client
id: check-for-cached-client
uses: actions/cache@v4
with:
path: ~/go/bin/client
key: ${{ steps.set-cached-client-version.outputs.key }}
# Cache miss, need to download conformance test client using Go tooling
- name: Download conformance test client
if: ${{ steps.check-for-cached-client.outputs.cache-hit != 'true' }}
uses: ./.github/actions/client/install
with:
client-version: ${{ env.CLIENT_VERSION }}
cache-path: ~/go/bin/client
cache-key: ${{ steps.set-cached-client-version.outputs.key }}
run-buildpack-integration-test:
needs:
- download-conformance-client
runs-on: ubuntu-latest
# Run tests in parallel on different GitHub runners
strategy:
matrix:
type: [http, cloudevent, event]
include:
- type: http
builder-source: ${{ inputs.http-builder-source }}
builder-target: ${{ inputs.http-builder-target }}
- type: cloudevent
builder-source: ${{ inputs.cloudevent-builder-source }}
builder-target: ${{ inputs.cloudevent-builder-target }}
- type: event
builder-source: ${{ inputs.event-builder-source }}
builder-target: ${{ inputs.event-builder-target }}
steps:
# if-condition on each step will effectively skip optional tests
- name: Retrieve conformance client
if: ${{ matrix.builder-source }}
uses: actions/cache@v4
with:
path: ~/go/bin/client
key: ${{ needs.download-conformance-client.outputs.cache-key }}
- name: Add client to PATH
if: ${{ matrix.builder-source }}
run: echo "$HOME/go/bin" >> $GITHUB_PATH
- name: Check out repository
if: ${{ matrix.builder-source }}
uses: actions/checkout@v3
- name: Prerun script
if: ${{ matrix.builder-source && inputs.prerun }}
run: bash -x ${{ inputs.prerun }}
- name: Buildpack integration test
if: ${{ matrix.builder-source }}
run: |
client \
-type=${{ matrix.type }} \
-builder-source=${{ matrix.builder-source }} \
-builder-target=${{ matrix.builder-target }} \
-builder-runtime=${{ inputs.builder-runtime }} \
-builder-runtime-version=${{ inputs.builder-runtime-version }} \
-builder-tag=${{ inputs.builder-tag }} \
-builder-url=${{ inputs.builder-url }} \
-start-delay=${{ inputs.start-delay }} \
-output-file=${{ inputs.output-file }} \
-validate-mapping=false
- name: 'Upload Artifact'
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.type }}_${{ inputs.builder-runtime }}_${{ inputs.builder-url == '' && 'no_builder_url' || 'with_builder_url' }}_buildpack_integ_logs
path: /tmp/ff_*
retention-days: 5