Skip to content

Commit 2eb8d09

Browse files
committed
Run unit tests in CI
1 parent 30318d6 commit 2eb8d09

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM giantswarm/tiny-tools
2+
3+
COPY entrypoint.sh /entrypoint.sh
4+
RUN chmod +x /entrypoint.sh
5+
6+
ENTRYPOINT ["/entrypoint.sh"]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: 'kubebuilder'
2+
description: 'A GitHub Action to run kubebuilder commands'
3+
author: 'Stefan Prodan'
4+
branding:
5+
icon: 'command'
6+
color: 'blue'
7+
runs:
8+
using: 'docker'
9+
image: 'Dockerfile'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh -l
2+
3+
VERSION=2.3.1
4+
5+
curl -sL https://go.kubebuilder.io/dl/${VERSION}/linux/amd64 | tar -xz -C /tmp/
6+
7+
mkdir -p $GITHUB_WORKSPACE/kubebuilder
8+
mv /tmp/kubebuilder_${VERSION}_linux_amd64/* $GITHUB_WORKSPACE/kubebuilder/
9+
ls -lh $GITHUB_WORKSPACE/kubebuilder/bin
10+
11+
echo "::add-path::$GITHUB_WORKSPACE/kubebuilder/bin"
12+
echo "::add-path::$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)/kubebuilder/bin"

.github/workflows/test.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
unit:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: Restore Go cache
16+
uses: actions/cache@v1
17+
with:
18+
path: ~/go/pkg/mod
19+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
20+
restore-keys: |
21+
${{ runner.os }}-go-
22+
- name: Setup Go
23+
uses: actions/setup-go@v2
24+
with:
25+
go-version: 1.14.x
26+
- name: Setup Kubebuilder
27+
uses: ./.github/actions/kubebuilder
28+
- name: Run tests
29+
run: make test
30+
env:
31+
KUBEBUILDER_ASSETS: ${{ github.workspace }}/kubebuilder/bin
32+
- name: Check if working tree is dirty
33+
run: |
34+
if [[ $(git diff --stat) != '' ]]; then
35+
echo 'run make test and commit changes'
36+
exit 1
37+
fi

0 commit comments

Comments
 (0)