Skip to content

Commit ccff406

Browse files
GitHub Actions smoke tests (GoogleCloudPlatform#288)
- added ci smoke tests to repo
1 parent d66cbdd commit ccff406

File tree

4 files changed

+115
-18
lines changed

4 files changed

+115
-18
lines changed

.github/workflows/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# GitHub Actions Workflows
2+
3+
## Setup
4+
- workloads run using [GitHub self-hosted runners](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/about-self-hosted-runners)
5+
- project admins maintain a private Google Compute Engine VM for running tests
6+
- VM should be at least n1-standard-4 with 50GB persistent disk
7+
- instructions for setting up the VM can be found in repo settings under "Actions"
8+
- ⚠️ WARNING: VM should be set up with no GCP service account
9+
- external contributors could contribute malicious PRs to run code on our test VM. Ensure no service accounts or other secrets exist on the VM
10+
- An empty GCP project should be used for extra security
11+
- to set up dependencies, run the following commands:
12+
```
13+
# install kubectl
14+
sudo apt-get install kubectl
15+
16+
# install kind
17+
curl -Lo ./kind "https://github.com/kubernetes-sigs/kind/releases/download/v0.7.0/kind-$(uname)-amd64" && \
18+
chmod +x ./kind && \
19+
sudo mv ./kind /usr/local/bin
20+
21+
# install skaffold
22+
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && \
23+
chmod +x skaffold && \
24+
sudo mv skaffold /usr/local/bin
25+
26+
# install docker
27+
sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common && \
28+
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - && \
29+
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" && \
30+
sudo apt update && \
31+
sudo apt install docker-ce && \
32+
sudo usermod -aG docker ${USER}
33+
34+
# logout and back on
35+
exit
36+
```
37+
- ensure GitHub Actions runs as background service:
38+
```
39+
sudo ∼/actions-runner/svc.sh install
40+
sudo ∼/actions-runner/svc.sh start
41+
```
42+
43+
44+
---
45+
## Workflows
46+
47+
### ci.yaml
48+
49+
#### Triggers
50+
- commits pushed to master
51+
- PRs to master
52+
- PRs to release/ branches
53+
54+
#### Actions
55+
- ensures kind cluster is running
56+
- builds all containers in src/
57+
- deploys local containers to kind
58+
- ensures all pods reach ready state
59+
- ensures HTTP request to frontend returns HTTP status 200
60+
- deploys manifests from /releases
61+
- ensures all pods reach ready state
62+
- ensures HTTP request to frontend returns HTTP status 200

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: "Continuous Integration"
2+
on:
3+
push:
4+
# run on pushes to master or release/*
5+
branches:
6+
- master
7+
- release/*
8+
pull_request:
9+
# run on pull requests targeting master
10+
branches:
11+
- master
12+
jobs:
13+
run-tests:
14+
runs-on: self-hosted
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Setup Cluster
18+
run: |
19+
set -x
20+
kind delete cluster || true
21+
kind create cluster
22+
kubectl get nodes
23+
- name: Deploy From Source
24+
run: |
25+
skaffold run
26+
- name: Wait For Pods
27+
timeout-minutes: 20
28+
run: |
29+
set -x
30+
kubectl wait --for=condition=available --timeout=500s deployment/adservice
31+
kubectl wait --for=condition=available --timeout=500s deployment/cartservice
32+
kubectl wait --for=condition=available --timeout=500s deployment/checkoutservice
33+
kubectl wait --for=condition=available --timeout=500s deployment/currencyservice
34+
kubectl wait --for=condition=available --timeout=500s deployment/emailservice
35+
kubectl wait --for=condition=available --timeout=500s deployment/frontend
36+
kubectl wait --for=condition=available --timeout=500s deployment/loadgenerator
37+
kubectl wait --for=condition=available --timeout=500s deployment/paymentservice
38+
kubectl wait --for=condition=available --timeout=500s deployment/productcatalogservice
39+
kubectl wait --for=condition=available --timeout=500s deployment/recommendationservice
40+
kubectl wait --for=condition=available --timeout=500s deployment/shippingservice
41+
- name: Smoke Test
42+
timeout-minutes: 5
43+
run: |
44+
set -x
45+
RESULT=" "
46+
while [[ "$RESULT" != " HTTP/1.1 200 OK" ]]; do
47+
sleep 1
48+
RESULT=$(kubectl exec deployments/frontend -- sh -c "wget --spider -S "http://frontend" 2>&1 | grep 'HTTP/'")
49+
echo "front end response: $RESULT"
50+
done
51+
if [[ "$RESULT" != " HTTP/1.1 200 OK" ]]; then
52+
exit 1
53+
fi

.travis.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

skaffold.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ deploy:
4949
manifests:
5050
- ./kubernetes-manifests/**.yaml
5151
profiles:
52-
# "travis-ci" profile is used to build the images without
53-
# pushing them.
54-
- name: travis-ci
55-
build:
56-
local:
57-
push: false
5852
# "gcb" profile allows building and pushing the images
5953
# on Google Container Builder without requiring docker
6054
# installed on the developer machine. However, note that

0 commit comments

Comments
 (0)