diff --git a/.github/actions/run-tests/Dockerfile b/.github/actions/run-tests/Dockerfile new file mode 100644 index 00000000..c4484cef --- /dev/null +++ b/.github/actions/run-tests/Dockerfile @@ -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"] diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml new file mode 100644 index 00000000..6679361a --- /dev/null +++ b/.github/actions/run-tests/action.yml @@ -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 }} diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index ff06427d..e7cdce0d 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -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: |