Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(actions): add github workflows for test #58

Merged
merged 1 commit into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are installing arkade, why not download kubectl with arkade?

arkade get kubectl --version $KUBE_VERSION
mv $HOME/.arkade/bin/kubectl /usr/local/bin/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thank you 🙏

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/