Use golang image to run tests step

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
This commit is contained in:
Aurel Canciu 2020-11-26 13:38:42 +02:00
parent e7acdabc79
commit 27420c0454
No known key found for this signature in database
GPG Key ID: AB25339971E6F81E
3 changed files with 27 additions and 6 deletions

12
.github/actions/run-tests/Dockerfile vendored Normal file
View File

@ -0,0 +1,12 @@
FROM golang:1.15-alpine
# Add any build or testing essential system packages
RUN apk add --no-cache build-base git
# Use the GitHub Actions uid:gid combination for proper fs permissions
RUN addgroup -g 116 -S test && adduser -u 1001 -S -g test test
# Run as test user
USER test
ENTRYPOINT ["/bin/sh", "-c"]

12
.github/actions/run-tests/action.yml vendored Normal file
View File

@ -0,0 +1,12 @@
name: 'Run tests'
description: 'Run tests in docker container'
inputs:
command:
description: 'Command to run inside the container'
required: true
default: 'make test'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.command }}

View File

@ -15,14 +15,10 @@ jobs:
- name: Restore Go cache
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
path: /home/runner/work/_temp/_github_home/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.15.x
- name: Setup Kubernetes
uses: engineerd/setup-kind@v0.5.0
- name: Setup Kustomize
@ -32,8 +28,9 @@ jobs:
- name: Setup Helm
uses: fluxcd/pkg/actions/helm@main
- name: Run tests
run: make test
uses: ./.github/actions/run-tests
env:
GOPATH: /github/home/go
KUBEBUILDER_ASSETS: ${{ github.workspace }}/kubebuilder/bin
- name: Check if working tree is dirty
run: |