Merge pull request #1 from fluxcd/ci-e2e

Implement CI with GitHub Actions
This commit is contained in:
Stefan Prodan 2020-04-08 15:22:53 +03:00 committed by GitHub
commit a55cae2e2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 122 additions and 7 deletions

View File

@ -0,0 +1,6 @@
FROM giantswarm/tiny-tools
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View File

@ -0,0 +1,9 @@
name: 'kubebuilder'
description: 'A GitHub Action to run kubebuilder commands'
author: 'Stefan Prodan'
branding:
icon: 'command'
color: 'blue'
runs:
using: 'docker'
image: 'Dockerfile'

View File

@ -0,0 +1,12 @@
#!/bin/sh -l
VERSION=2.3.1
curl -sL https://go.kubebuilder.io/dl/${VERSION}/linux/amd64 | tar -xz -C /tmp/
mkdir -p $GITHUB_WORKSPACE/kubebuilder
mv /tmp/kubebuilder_${VERSION}_linux_amd64/* $GITHUB_WORKSPACE/kubebuilder/
ls -lh $GITHUB_WORKSPACE/kubebuilder/bin
echo "::add-path::$GITHUB_WORKSPACE/kubebuilder/bin"
echo "::add-path::$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)/kubebuilder/bin"

6
.github/actions/kustomize/Dockerfile vendored Normal file
View File

@ -0,0 +1,6 @@
FROM giantswarm/tiny-tools
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

9
.github/actions/kustomize/action.yml vendored Normal file
View File

@ -0,0 +1,9 @@
name: 'kustomize'
description: 'A GitHub Action to run kustomize commands'
author: 'Stefan Prodan'
branding:
icon: 'command'
color: 'blue'
runs:
using: 'docker'
image: 'Dockerfile'

12
.github/actions/kustomize/entrypoint.sh vendored Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh -l
VERSION=3.1.0
curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v${VERSION}/kustomize_${VERSION}_linux_amd64
mkdir -p $GITHUB_WORKSPACE/bin
cp ./kustomize $GITHUB_WORKSPACE/bin
chmod +x $GITHUB_WORKSPACE/bin/kustomize
ls -lh $GITHUB_WORKSPACE/bin
echo "::add-path::$GITHUB_WORKSPACE/bin"
echo "::add-path::$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)/bin"

55
.github/workflows/e2e.yaml vendored Normal file
View File

@ -0,0 +1,55 @@
name: e2e
on:
pull_request:
push:
branches:
- master
jobs:
kind:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Restore Go cache
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup Go
uses: actions/setup-go@v2-beta
with:
go-version: 1.13.x
- name: Setup Kubernetes
uses: engineerd/setup-kind@v0.3.0
- name: Setup Kustomize
uses: ./.github/actions/kustomize
- name: Setup Kubebuilder
uses: ./.github/actions/kubebuilder
- name: Run tests and build image
run: make docker-build IMG=test/source-controller:latest
env:
KUBEBUILDER_ASSETS: ${{ github.workspace }}/kubebuilder/bin
- name: Load test image
run: kind load docker-image test/source-controller:latest
- name: Deploy controller
run: make dev-deploy IMG=test/source-controller:latest
env:
KUBEBUILDER_ASSETS: ${{ github.workspace }}/kubebuilder/bin
- name: Run smoke tests
run: |
kubectl apply -f ./config/samples
kubectl -n sourcer-system rollout status deploy/sourcer-controller --timeout=1m
kubectl wait gitrepository/podinfo --for=condition=ready --timeout=1m
kubectl wait helmrepository/podinfo --for=condition=ready --timeout=1m
kubectl -n sourcer-system logs deploy/sourcer-controller
- name: Debug failure
if: failure()
run: |
kubectl get gitrepositories -oyaml
kubectl get helmrepositories -oyaml
kubectl -n sourcer-system get all
kubectl -n sourcer-system logs deploy/sourcer-controller

View File

@ -35,9 +35,16 @@ uninstall: manifests
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests
cd config/manager && kustomize edit set image controller=${IMG}
cd config/manager && kustomize edit set image fluxcd/sourcer=${IMG}
kustomize build config/default | kubectl apply -f -
# Deploy controller dev image in the configured Kubernetes cluster in ~/.kube/config
dev-deploy: manifests
mkdir -p config/dev && cp config/default/* config/dev
cd config/dev && kustomize edit set image fluxcd/sourcer=${IMG}
kustomize build config/dev | kubectl apply -f -
rm -rf config/dev
# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role paths="./..." output:crd:artifacts:config=config/crd/bases
@ -62,8 +69,7 @@ docker-build: test
docker-push:
docker push ${IMG}
# find or download controller-gen
# download controller-gen if necessary
# Find or download controller-gen
controller-gen:
ifeq (, $(shell which controller-gen))
@{ \

View File

@ -21,7 +21,8 @@ spec:
terminationGracePeriodSeconds: 10
containers:
- name: manager
image: controller
image: fluxcd/sourcer
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
name: http

View File

@ -5,6 +5,5 @@ resources:
- service.yaml
- deployment.yaml
images:
- name: controller
newName: fluxcd/sourcer
- name: fluxcd/sourcer
newTag: 0.0.1-alpha.1