Skip to content

Commit e5056a5

Browse files
authored
improve single image build & test workflows (#7422)
1 parent 282d6bb commit e5056a5

File tree

2 files changed

+56
-13
lines changed

2 files changed

+56
-13
lines changed

.github/workflows/build-single-image.yml

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,20 @@ jobs:
5050
ref: ${{ inputs.branch }}
5151
fetch-depth: 0
5252

53+
- name: Setup Golang Environment
54+
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
55+
with:
56+
go-version-file: go.mod
57+
5358
- name: Output Variables
5459
id: vars
5560
run: |
5661
./.github/scripts/variables.sh go_code_md5 >> $GITHUB_OUTPUT
62+
echo "go_path=$(go env GOPATH)" >> $GITHUB_OUTPUT
63+
source .github/data/version.txt
64+
echo "ic_version=${IC_VERSION}" >> $GITHUB_OUTPUT
5765
cat $GITHUB_OUTPUT
5866
59-
- name: Setup Golang Environment
60-
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
61-
with:
62-
go-version-file: go.mod
63-
6467
- name: Authenticate to Google Cloud
6568
id: auth
6669
uses: google-github-actions/auth@71f986410dfbc7added4569d411d040a91dc6935 # v2.1.8
@@ -96,11 +99,37 @@ jobs:
9699
path: ${{ github.workspace }}/dist
97100
key: nginx-ingress-${{ steps.vars.outputs.go_code_md5 }}
98101

102+
- name: Build binaries
103+
uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3 # v6.2.1
104+
with:
105+
version: latest
106+
args: build --snapshot --clean
107+
env:
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109+
GOPATH: ${{ steps.vars.outputs.go_path }}
110+
AWS_PRODUCT_CODE: ${{ secrets.AWS_PRODUCT_CODE }}
111+
AWS_PUB_KEY: ${{ secrets.AWS_PUB_KEY }}
112+
AWS_NAP_DOS_PRODUCT_CODE: ${{ secrets.AWS_NAP_DOS_PRODUCT_CODE }}
113+
AWS_NAP_DOS_PUB_KEY: ${{ secrets.AWS_NAP_DOS_PUB_KEY }}
114+
AWS_NAP_WAF_PRODUCT_CODE: ${{ secrets.AWS_NAP_WAF_PRODUCT_CODE }}
115+
AWS_NAP_WAF_PUB_KEY: ${{ secrets.AWS_NAP_WAF_PUB_KEY }}
116+
AWS_NAP_WAF_DOS_PRODUCT_CODE: ${{ secrets.AWS_NAP_WAF_DOS_PRODUCT_CODE }}
117+
AWS_NAP_WAF_DOS_PUB_KEY: ${{ secrets.AWS_NAP_WAF_DOS_PUB_KEY }}
118+
GORELEASER_CURRENT_TAG: "v${{ steps.vars.outputs.ic_version }}"
119+
if: ${{ steps.binary-cache.outputs.binary_cache_hit != 'true' }}
120+
121+
- name: Store Artifacts in Cache
122+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
123+
with:
124+
path: ${{ github.workspace }}/dist
125+
key: nginx-ingress-${{ steps.vars.outputs.go_code_md5 }}
126+
if: ${{ steps.binary-cache.outputs.binary_cache_hit != 'true' }}
127+
99128
- name: Build Image
100129
run: |
101130
make ${{ inputs.target }}
102131
env:
103-
REGISTRY: gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/${{ github.actor }}-dev
132+
REGISTRY: gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev
104133
PREFIX: ${{ inputs.prefix }}
105134
TAG: ${{ inputs.tag }}
106135
PLUS_REPO: ${{ inputs.plus_repo }}
@@ -110,6 +139,6 @@ jobs:
110139
run:
111140
docker push ${REGISTRY}/${PREFIX}:${TAG}
112141
env:
113-
REGISTRY: gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/${{ github.actor }}-dev
142+
REGISTRY: gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev
114143
PREFIX: ${{ inputs.prefix }}
115144
TAG: ${{ inputs.tag }}

.github/workflows/single-image-regression.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ on:
2626
description: "pytest markers to apply"
2727
required: false
2828
default: "'not upgrade'"
29-
test-image-tag:
30-
type: string
31-
description: "The tag for the test image"
32-
required: false
33-
default: latest
3429
workflow_call:
3530
inputs:
3631
image:
@@ -97,6 +92,25 @@ jobs:
9792
run: |
9893
docker pull ${{ inputs.image }}:${{ inputs.tag }}
9994
95+
- name: Check if test image exists
96+
id: check-image
97+
run: |
98+
docker manifest inspect "gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/test-runner:${{ hashFiles('./tests/requirements.txt', './tests/Dockerfile') }}"
99+
shell: bash
100+
continue-on-error: true
101+
102+
- name: Build Test-Runner Container
103+
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6.13.0
104+
with:
105+
file: tests/Dockerfile
106+
context: "."
107+
cache-from: type=gha,scope=test-runner
108+
tags: "gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/test-runner:${{ hashFiles('./tests/requirements.txt', './tests/Dockerfile') }}"
109+
pull: true
110+
push: false
111+
load: true
112+
if: ${{ steps.check-image.outcome == 'failure' }}
113+
100114
- name: Run Tests
101115
uses: ./.github/actions/smoke-tests
102116
with:
@@ -108,5 +122,5 @@ jobs:
108122
k8s-version: ${{ inputs.k8s-version }}
109123
azure-ad-secret: ${{ secrets.AZURE_AD_AUTOMATION }}
110124
registry-token: ${{ steps.auth.outputs.access_token }}
111-
test-image: "gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/test-runner:${{ inputs.test-image-tag }}"
125+
test-image: "gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/test-runner:${{ hashFiles('./tests/requirements.txt', './tests/Dockerfile') }}"
112126
plus-jwt: ${{ secrets.PLUS_JWT }}

0 commit comments

Comments
 (0)