diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..c6751c2 --- /dev/null +++ b/.github/workflows/test.yaml @@ -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/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c2fbf0c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,53 +0,0 @@ -language: go -go: - - 1.14.x - -dist: xenial -services: - - docker - -env: - global: - - IP=127.0.0.1 - - USER_NAME=$(whoami) - - KUBECONFIG_FOLDER_PATH=/home/$USER_NAME/.kube - - KUBECONFIG_PATH=$KUBECONFIG_FOLDER_PATH/config - - KUBECONFIG=$KUBECONFIG_PATH - - KUBECTL_VERSION=v1.16.8 - -jobs: - include: - - stage: lint - env: - - golangci_version=v1.24.0 - install: - - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin $golangci_version - script: make lint - - stage: test - name: faas-swarm - env: - - OPENFAAS_URL=http://$IP:8080/ - before_install: - - docker swarm init - - git clone https://github.com/openfaas/faas.git - - cd faas && echo "$(pwd)" && ./deploy_stack.sh --no-auth && cd .. - - sleep 15 - script: make test-swarm - after_script: - - "docker swarm leave --force" - # stage key is omitted because it is still par of "test" and run in parallel - - name: faas-netes - env: - - OPENFAAS_URL=http://$IP:31112/ - before_install: - - curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl && - chmod +x kubectl && sudo mv kubectl /usr/local/bin/ - - sudo curl -sLS https://get.k3sup.dev | sh - - sudo install k3sup /usr/local/bin/ - - mkdir -p $KUBECONFIG_FOLDER_PATH - - k3sup install --local --ip $IP --user $USER_NAME - - cp `pwd`/kubeconfig $KUBECONFIG_PATH - - curl -sLS https://dl.get-arkade.dev | sudo sh - - arkade install openfaas --basic-auth=false - - kubectl rollout status -n openfaas deploy/gateway -w - script: make test-kubernetes diff --git a/Makefile b/Makefile index 055e946..f55076b 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/contrib/clean_swarm_cluster.sh b/contrib/clean_swarm_cluster.sh new file mode 100755 index 0000000..d53e0eb --- /dev/null +++ b/contrib/clean_swarm_cluster.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +echo ">>> Leaving Swarm cluster" + +docker swarm leave --force \ No newline at end of file diff --git a/contrib/create_kubernetes_cluster.sh b/contrib/create_kubernetes_cluster.sh new file mode 100755 index 0000000..f352d55 --- /dev/null +++ b/contrib/create_kubernetes_cluster.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -euo pipefail + +USER_NAME=$(whoami) + +echo ">>> Creating kubernetes cluster" +k3sup install --local --ip $IP --user $USER_NAME \ No newline at end of file diff --git a/contrib/create_swarm_cluster.sh b/contrib/create_swarm_cluster.sh new file mode 100755 index 0000000..35adebe --- /dev/null +++ b/contrib/create_swarm_cluster.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +echo ">>> Creating Swarm cluster" + +docker swarm init \ No newline at end of file diff --git a/contrib/deploy_openfaas.sh b/contrib/deploy_openfaas.sh new file mode 100755 index 0000000..1daf775 --- /dev/null +++ b/contrib/deploy_openfaas.sh @@ -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 \ No newline at end of file diff --git a/contrib/deploy_stack.sh b/contrib/deploy_stack.sh new file mode 100755 index 0000000..88e3b3a --- /dev/null +++ b/contrib/deploy_stack.sh @@ -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 .. \ No newline at end of file diff --git a/contrib/get_tools.sh b/contrib/get_tools.sh new file mode 100755 index 0000000..7c3a703 --- /dev/null +++ b/contrib/get_tools.sh @@ -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/ \ No newline at end of file