Skip to content

Commit

Permalink
Merge pull request #175 from weaveworks/173-e2e-ci
Browse files Browse the repository at this point in the history
ci: Run e2e test on PRs and merges to main
  • Loading branch information
yiannistri authored Apr 20, 2023
2 parents a653580 + 1f1a6b4 commit 4266c83
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 4 deletions.
31 changes: 28 additions & 3 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: e2e

on:
pull_request:
push:
branches:
- main
workflow_dispatch:

jobs:
Expand All @@ -9,12 +13,33 @@ jobs:
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup
- name: Setup | Go
uses: actions/[email protected]
with:
go-version: 1.20.x
- name: Prepare
- name: Setup | Kubernetes Cluster
uses: helm/[email protected]
with:
version: v0.18.0
cluster_name: pipeline-controller
node_image: kindest/node:v1.26.3@sha256:61b92f38dff6ccc29969e7aa154d34e38b89443af1a2c14e6cfbd2df6419c66f
- name: Setup | Flux
run: curl -s https://fluxcd.io/install.sh | sudo bash
- name: Prepare | Go # .netrc is used by docker-build, ~/.netrc is used by go test
run: echo "machine github.com login ${{ github.actor }} password ${{ secrets.BUILD_BOT_TOKEN }}" | tee ~/.netrc .netrc
- name: Prepare | Kubernetes Cluster
run: |
echo "machine github.com login ${{ github.actor }} password ${{ secrets.BUILD_BOT_TOKEN }}" > ~/.netrc
echo "Create flux-system namespace"
kubectl create namespace flux-system
echo "Adding GitHub promotion credentials"
kubectl create secret generic -n flux-system github-promotion-credentials \
--from-literal="username=${{ secrets.PROMOTION_GITHUB_USERNAME }}" \
--from-literal="password=${{ secrets.PROMOTION_GITHUB_TOKEN }}" \
--from-literal="token=${{ secrets.PROMOTION_GITHUB_TOKEN }}"
echo "Adding GitLab promotion credentials"
kubectl create secret generic -n flux-system gitlab-promotion-credentials \
--from-literal="username=${{ secrets.PROMOTION_GITLAB_USERNAME }}" \
--from-literal="password=${{ secrets.PROMOTION_GITLAB_TOKEN }}" \
--from-literal="token=${{ secrets.PROMOTION_GITLAB_TOKEN }}"
- name: Run E2E tests
run: make e2e
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,13 @@ e2e: e2e-setup e2e-test e2e-clean
.PHONY: e2e-setup
e2e-setup: e2e-kind deploy
kubectl wait -n pipeline-system deployment/pipeline-controller --for=condition=available
kubectl apply -f e2e/testdata --recursive
kubectl apply -k e2e/testdata/pipelines/github
kubectl apply -k e2e/testdata/pipelines/gitlab

e2e-kind: docker-build
ifneq ($(CI), true)
kind create cluster --name=pipeline-controller || kubectx kind-pipeline-controller
endif
kind load docker-image --name=pipeline-controller $(IMG)
flux install

Expand All @@ -227,4 +230,9 @@ e2e-test:

.PHONY: e2e-clean
e2e-clean:
kubectl delete -k e2e/testdata/pipelines/github
kubectl delete -k e2e/testdata/pipelines/gitlab
flux uninstall --silent
ifneq ($(CI), true)
kind delete cluster --name=pipeline-controller
endif
6 changes: 6 additions & 0 deletions e2e/testdata/pipelines/github/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- podinfo-dev/
- podinfo-prod/
- pipeline.yaml
7 changes: 7 additions & 0 deletions e2e/testdata/pipelines/github/podinfo-dev/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- source.yaml
- release.yaml
- notification.yaml
6 changes: 6 additions & 0 deletions e2e/testdata/pipelines/github/podinfo-prod/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- source.yaml
- release.yaml
6 changes: 6 additions & 0 deletions e2e/testdata/pipelines/gitlab/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- podinfo-dev/
- podinfo-prod/
- pipeline.yaml
7 changes: 7 additions & 0 deletions e2e/testdata/pipelines/gitlab/podinfo-dev/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- source.yaml
- release.yaml
- notification.yaml
6 changes: 6 additions & 0 deletions e2e/testdata/pipelines/gitlab/podinfo-prod/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- source.yaml
- release.yaml

0 comments on commit 4266c83

Please sign in to comment.