GitHub Actions smoke tests (#288)

- added ci smoke tests to repo
This commit is contained in:
Daniel Sanche 2020-02-21 15:26:03 -08:00 committed by GitHub
parent d66cbdd27f
commit ccff406cdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 115 additions and 18 deletions

62
.github/workflows/README.md vendored Normal file
View File

@ -0,0 +1,62 @@
# GitHub Actions Workflows
## Setup
- workloads run using [GitHub self-hosted runners](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/about-self-hosted-runners)
- project admins maintain a private Google Compute Engine VM for running tests
- VM should be at least n1-standard-4 with 50GB persistent disk
- instructions for setting up the VM can be found in repo settings under "Actions"
- ⚠️ WARNING: VM should be set up with no GCP service account
- external contributors could contribute malicious PRs to run code on our test VM. Ensure no service accounts or other secrets exist on the VM
- An empty GCP project should be used for extra security
- to set up dependencies, run the following commands:
```
# install kubectl
sudo apt-get install kubectl
# install kind
curl -Lo ./kind "https://github.com/kubernetes-sigs/kind/releases/download/v0.7.0/kind-$(uname)-amd64" && \
chmod +x ./kind && \
sudo mv ./kind /usr/local/bin
# install skaffold
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && \
chmod +x skaffold && \
sudo mv skaffold /usr/local/bin
# install docker
sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common && \
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - && \
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" && \
sudo apt update && \
sudo apt install docker-ce && \
sudo usermod -aG docker ${USER}
# logout and back on
exit
```
- ensure GitHub Actions runs as background service:
```
sudo /actions-runner/svc.sh install
sudo /actions-runner/svc.sh start
```
---
## Workflows
### ci.yaml
#### Triggers
- commits pushed to master
- PRs to master
- PRs to release/ branches
#### Actions
- ensures kind cluster is running
- builds all containers in src/
- deploys local containers to kind
- ensures all pods reach ready state
- ensures HTTP request to frontend returns HTTP status 200
- deploys manifests from /releases
- ensures all pods reach ready state
- ensures HTTP request to frontend returns HTTP status 200

53
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,53 @@
name: "Continuous Integration"
on:
push:
# run on pushes to master or release/*
branches:
- master
- release/*
pull_request:
# run on pull requests targeting master
branches:
- master
jobs:
run-tests:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: Setup Cluster
run: |
set -x
kind delete cluster || true
kind create cluster
kubectl get nodes
- name: Deploy From Source
run: |
skaffold run
- name: Wait For Pods
timeout-minutes: 20
run: |
set -x
kubectl wait --for=condition=available --timeout=500s deployment/adservice
kubectl wait --for=condition=available --timeout=500s deployment/cartservice
kubectl wait --for=condition=available --timeout=500s deployment/checkoutservice
kubectl wait --for=condition=available --timeout=500s deployment/currencyservice
kubectl wait --for=condition=available --timeout=500s deployment/emailservice
kubectl wait --for=condition=available --timeout=500s deployment/frontend
kubectl wait --for=condition=available --timeout=500s deployment/loadgenerator
kubectl wait --for=condition=available --timeout=500s deployment/paymentservice
kubectl wait --for=condition=available --timeout=500s deployment/productcatalogservice
kubectl wait --for=condition=available --timeout=500s deployment/recommendationservice
kubectl wait --for=condition=available --timeout=500s deployment/shippingservice
- name: Smoke Test
timeout-minutes: 5
run: |
set -x
RESULT=" "
while [[ "$RESULT" != " HTTP/1.1 200 OK" ]]; do
sleep 1
RESULT=$(kubectl exec deployments/frontend -- sh -c "wget --spider -S "http://frontend" 2>&1 | grep 'HTTP/'")
echo "front end response: $RESULT"
done
if [[ "$RESULT" != " HTTP/1.1 200 OK" ]]; then
exit 1
fi

View File

@ -1,12 +0,0 @@
sudo: required
services:
- docker
install:
- curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v0.20.0/skaffold-linux-amd64
- chmod +x skaffold
- sudo mv skaffold /usr/local/bin
script:
- skaffold build --profile travis-ci

View File

@ -49,12 +49,6 @@ deploy:
manifests:
- ./kubernetes-manifests/**.yaml
profiles:
# "travis-ci" profile is used to build the images without
# pushing them.
- name: travis-ci
build:
local:
push: false
# "gcb" profile allows building and pushing the images
# on Google Container Builder without requiring docker
# installed on the developer machine. However, note that