Skip to content

Commit

Permalink
feat(actions): add github workflows for test
Browse files Browse the repository at this point in the history
Signed-off-by: Dentrax <[email protected]>
Signed-off-by: Batuhan Apaydın <[email protected]>
  • Loading branch information
Dentrax authored and alexellis committed Dec 3, 2020
1 parent 30c5ee5 commit 3c685c0
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 57 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: build

on:
push:
branches: [ "*" ]
pull_request:
branches: [ "*" ]

env:
IP: 127.0.0.1

jobs:
lint:
strategy:
matrix:
go-version: [ 1.13.x ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
with:
fetch-depth: 1
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.29
test-swarm:
strategy:
matrix:
go-version: [ 1.13.x ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
with:
fetch-depth: 1
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: create swarm cluster
run: ./contrib/create_swarm_cluster.sh
- name: deploy stack
run: ./contrib/deploy_stack.sh
- name: wait 15 seconds
run: sleep 15
- name: test swarm
run: make test-swarm
env:
OPENFAAS_URL: http://${{ env.IP }}:8080/
- name: clean swarm cluster
run: ./contrib/clean_swarm_cluster.sh
test-kubernetes:
strategy:
matrix:
go-version: [ 1.13.x ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
with:
fetch-depth: 1
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: get tools
run: ./contrib/get_tools.sh
- name: create kubernetes cluster
run: ./contrib/create_kubernetes_cluster.sh
- name: deploy openfaas
run: ./contrib/deploy_openfaas.sh
- name: test kubernetes
run: make test-kubernetes
env:
OPENFAAS_URL: http://${{ env.IP }}:31112/
53 changes: 0 additions & 53 deletions .travis.yml

This file was deleted.

4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ clean-swarm:
clean-kubernetes:
- kubectl delete -n openfaas-fn deploy,svc ${.TEST_FUNCTIONS} 2>/dev/null || : ;

lint:
@golangci-lint version
golangci-lint run --timeout=1m ./...

.TEST_FLAGS= # additional test flags, e.g. -run ^Test_ScaleFromZeroDuringIvoke$
.FEATURE_FLAGS= # set config feature flags, e.g. -swarm

Expand Down
5 changes: 5 additions & 0 deletions contrib/clean_swarm_cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

echo ">>> Leaving Swarm cluster"

docker swarm leave --force
8 changes: 8 additions & 0 deletions contrib/create_kubernetes_cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -euo pipefail

USER_NAME=$(whoami)

echo ">>> Creating kubernetes cluster"
k3sup install --local --ip $IP --user $USER_NAME
5 changes: 5 additions & 0 deletions contrib/create_swarm_cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

echo ">>> Creating Swarm cluster"

docker swarm init
18 changes: 18 additions & 0 deletions contrib/deploy_openfaas.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -euo pipefail

USER_NAME=$(whoami)
KUBECONFIG_FOLDER_PATH=/home/$USER_NAME/.kube
KUBECONFIG_PATH=$KUBECONFIG_FOLDER_PATH/config
KUBECONFIG=$KUBECONFIG_PATH

echo ">>> Setup kubectl configuration"
mkdir -p $KUBECONFIG_FOLDER_PATH
cp `pwd`/kubeconfig $KUBECONFIG_PATH

echo ">>> Installing openfaas"
arkade install openfaas --basic-auth=false

echo ">>> Waiting for helm install to complete."
kubectl rollout status -n openfaas deploy/gateway -w
7 changes: 7 additions & 0 deletions contrib/deploy_stack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

echo ">>> Cloning the faas project"
git clone https://github.com/openfaas/faas.git

echo ">>> Deploying the stack"
cd faas && echo "$(pwd)" && ./deploy_stack.sh --no-auth && cd ..
16 changes: 16 additions & 0 deletions contrib/get_tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -euo pipefail

KUBE_VERSION=v1.18.8

echo ">>> Installing k3sup"
sudo curl -sLS https://get.k3sup.dev | sh
sudo install k3sup /usr/local/bin/

echo ">>> Installing arkade"
curl -sLS https://dl.get-arkade.dev | sudo sh

echo ">>> Installing kubectl $KUBE_VERSION"
arkade get kubectl --version $KUBE_VERSION
sudo mv $HOME/.arkade/bin/kubectl /usr/local/bin/

0 comments on commit 3c685c0

Please sign in to comment.