Skip to content

Commit ed07799

Browse files
committed
ci: refactors commit.yaml
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
1 parent 329f0f6 commit ed07799

1 file changed

Lines changed: 40 additions & 14 deletions

File tree

.github/workflows/commit.yaml

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ jobs:
9797
- run: go build -buildmode=c-shared -o main.so
9898
- run: go tool golangci-lint run
9999

100-
docker_build:
101-
name: Build and Push multi-arch Docker image
100+
docker_build_and_integration_test:
101+
name: Build and Run Integration Tests
102102
runs-on: ubuntu-latest
103103
steps:
104104
- name: Checkout
@@ -110,36 +110,62 @@ jobs:
110110
- name: Set up Docker Buildx
111111
uses: docker/setup-buildx-action@v3
112112

113-
- name: Login into GitHub Container Registry
114-
uses: docker/login-action@v3
115-
with:
116-
registry: ghcr.io
117-
username: ${{ github.repository_owner }}
118-
password: ${{ secrets.GITHUB_TOKEN }}
119-
120-
- name: Build and push
113+
- name: Docker Build
121114
uses: docker/build-push-action@v6
122115
if: github.event_name != 'push'
123116
with:
124117
platforms: linux/amd64,linux/arm64
125-
push: true
118+
load: true
119+
push: false
126120
tags: ghcr.io/${{ github.repository_owner }}/dynamic-modules-examples:${{ github.sha }}
127121
cache-from: type=gha
128122
cache-to: type=gha,mode=max
129123

130-
- name: Build and push
131-
uses: docker/build-push-action@v6
124+
- uses: actions/setup-go@v5
125+
with:
126+
cache: false
127+
go-version-file: integration/go.mod
128+
129+
- uses: actions/cache@v4
130+
with:
131+
path: |
132+
~/.cache/go-build
133+
~/go/pkg/mod
134+
~/go/bin
135+
key: unittest-${{ hashFiles('**/go.mod', '**/go.sum') }}-${{ matrix.platform.os }}
136+
137+
- name: Run integration tests
138+
env:
139+
ENVOY_IMAGE: ghcr.io/${{ github.repository_owner }}/dynamic-modules-examples:${{ github.sha }}
140+
run: go test -v -count=1 ./...
141+
142+
- name: Login into GitHub Container Registry
143+
# This step will only run on push events to the main branch.
132144
if: github.event_name == 'push'
145+
uses: docker/login-action@v3
146+
with:
147+
registry: ghcr.io
148+
username: ${{ github.repository_owner }}
149+
password: ${{ secrets.GITHUB_TOKEN }}
150+
151+
- name: Build and Push
152+
# This step will only run on push events to the main branch.
153+
if: github.event_name == 'push'
154+
uses: docker/build-push-action@v6
133155
with:
134156
platforms: linux/amd64,linux/arm64
135157
push: true
136158
tags: ghcr.io/${{ github.repository_owner }}/dynamic-modules-examples:${{ github.sha }},ghcr.io/${{ github.repository_owner }}/dynamic-modules-examples:latest
137159
cache-from: type=gha
138160
cache-to: type=gha,mode=max
139161

140-
integration_test:
162+
integration_test_on_main:
141163
needs: [docker_build]
142164
name: Integration Test (${{ matrix.platform.arch }})
165+
# This will only run on push events to the main branch.
166+
# Mainly to check the multi-arch image by running the
167+
# integration tests on both architectures.
168+
if: github.event_name == 'push'
143169
runs-on: ${{ matrix.platform.os }}
144170
defaults:
145171
run:

0 commit comments

Comments
 (0)