Skip to content
This repository has been archived by the owner on Mar 10, 2023. It is now read-only.

Commit

Permalink
Add Github Actions build for faas-cli components
Browse files Browse the repository at this point in the history
This builds the faas-cli components with github actions as part of CI

Signed-off-by: Alistair Hey <[email protected]>
  • Loading branch information
Waterdrips committed Nov 13, 2020
1 parent bc868ad commit 707889f
Show file tree
Hide file tree
Showing 22 changed files with 167 additions and 157 deletions.
46 changes: 24 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,25 @@ on:
- '*'

jobs:

test-chart:
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: Run Tests
run: curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash && make test-chart
# Run the CI tests
test:
build-stack:
strategy:
matrix:
go-version: [1.13.x]
Expand Down Expand Up @@ -49,6 +66,9 @@ jobs:
- name: Get TAG
id: get_tag
run: echo ::set-output name=TAG::latest-dev
- name: Get Repo
id: get_repo_owner
run: echo ::set-output name=repo_owner::$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
- name: Build ${{ matrix.svc }}
uses: docker/build-push-action@v2
with:
Expand All @@ -57,24 +77,6 @@ jobs:
outputs: "type=image,push=false"
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: |
ghcr.io/openfaas/${{ matrix.svc }}:${{ steps.get_tag.outputs.TAG }}
ghcr.io/openfaas/${{ matrix.svc }}:${{ github.sha }}
ghcr.io/openfaas/${{ matrix.svc }}:latest
# TODO add build for all containers in here
build-stack:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.13.x]
svc: [
edge-auth,
edge-router,
of-builder
]
steps:
- uses: actions/checkout@master
with:
fetch-depth: 1
- name: Get TAG
id: get_tag
run: echo ::set-output name=TAG::latest-dev
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ matrix.svc }}:${{ steps.get_tag.outputs.TAG }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ matrix.svc }}:${{ github.sha }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ matrix.svc }}:latest
63 changes: 44 additions & 19 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,40 @@ on:
tags:
- '*'


jobs:
publish:
# Run the CI tests
publish-stack:
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: Login to Docker Registry
uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ghcr.io
- name: Get TAG
id: get_tag
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
- name: Get Repo Owner
id: get_repo_owner
run: echo ::set-output name=repo_owner::$(echo ${{ github.event.repository.owner.login }} | tr '[:upper:]' '[:lower:]')
- name: Deploy Stacks
run: TAG=${{ steps.get_tag.outputs.TAG }} repo_owner=${{ steps.get_repo_owner.outputs.repo_owner }} sh ./contrib/publish.sh

# Test building the non-cli Containers
publish-containers:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -20,37 +52,30 @@ jobs:
- uses: actions/checkout@master
with:
fetch-depth: 1
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Get TAG
id: get_tag
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ghcr.io
- name: Build and push ${{ matrix.svc }}
- name: Get TAG
id: get_tag
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
- name: Get Repo Owner
id: get_repo_owner
run: echo ::set-output name=repo_owner::$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
- name: Build ${{ matrix.svc }}
uses: docker/build-push-action@v2
with:
context: ./${{ matrix.svc }}
file: ./${{ matrix.svc }}/Dockerfile
outputs: "type=registry,push=true"
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: |
ghcr.io/openfaas/${{ matrix.svc }}:${{ steps.get_tag.outputs.TAG }}
ghcr.io/openfaas/${{ matrix.svc }}:${{ github.sha }}
ghcr.io/openfaas/${{ matrix.svc }}:latest
# Need a section for faas-cli on each fn in stack.yaml
# section for of-dashboard's stack.yaml
# https://github.com/alexellis/multiarch-templates/
# Section to run the chart tests
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ matrix.svc }}:${{ steps.get_tag.outputs.TAG }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ matrix.svc }}:${{ github.sha }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ matrix.svc }}:latest
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ charts:
mv chart/*.tgz docs/
helm repo index docs --url https://openfaas-cloud.github.io/openfaas-cloud/ --merge ./docs/index.yaml


test-chart:
cd chart/test && go test -v -mod=vendor ./...
3 changes: 1 addition & 2 deletions chart/test/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
tmp/**/*.yaml
tmp/**/*.yml
tmp/
28 changes: 0 additions & 28 deletions chart/test/Gopkg.lock

This file was deleted.

34 changes: 0 additions & 34 deletions chart/test/Gopkg.toml

This file was deleted.

4 changes: 2 additions & 2 deletions chart/test/core_edge_auth_dep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ func makeEdgeAuthDep(httpProbe, customersSecret, secureCookie bool) YamlSpec {
ApiVersion: "apps/v1",
Kind: "Deployment",
Metadata: MetadataItems{
Name: "edge-auth",
Name: "edge-auth",
Namespace: "openfaas",
Labels: labels,
Labels: labels,
},
Spec: Spec{
Replicas: 1,
Expand Down
4 changes: 2 additions & 2 deletions chart/test/core_edge_router_dep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ func makeEdgeRouterDep(httpProbe, oauthEnabled bool) YamlSpec {
ApiVersion: "apps/v1",
Kind: "Deployment",
Metadata: MetadataItems{
Name: "edge-router",
Name: "edge-router",
Namespace: "openfaas",
Labels: labels,
Labels: labels,
},
Spec: Spec{
Replicas: 1,
Expand Down
6 changes: 3 additions & 3 deletions chart/test/core_of_builder_dep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ func makeOFBuilderDep(httpProbe, isECR bool, replicas int, buildkitPrivileged, o
ApiVersion: "apps/v1",
Kind: "Deployment",
Metadata: MetadataItems{
Name: "of-builder",
Name: "of-builder",
Namespace: "openfaas",
Labels: labels,
Labels: labels,
},
Spec: Spec{
Replicas: replicas,
Expand All @@ -69,7 +69,7 @@ func makeOFBuilderDep(httpProbe, isECR bool, replicas int, buildkitPrivileged, o
Volumes: deployVolumes,
Containers: []DeploymentContainers{{
Name: "of-builder",
Image: "openfaas/of-builder:0.7.2",
Image: "openfaas/of-builder:0.8.0",
ImagePullPolicy: "IfNotPresent",
ContainerReadinessProbe: readinessProbe,
ContainerEnvironment: containerEnvironment,
Expand Down
8 changes: 8 additions & 0 deletions chart/test/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/openfaas/openfaas-cloud/chart/test

go 1.15

require (
github.com/alexellis/go-execute v0.0.0-20191029181357-d17947259f74
gopkg.in/yaml.v2 v2.2.7
)
6 changes: 6 additions & 0 deletions chart/test/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
github.com/alexellis/go-execute v0.0.0-20191029181357-d17947259f74 h1:3NSYa7HnT2RgQxFn1dHw7GJDgk5v1XzuNE3b1IdJVwY=
github.com/alexellis/go-execute v0.0.0-20191029181357-d17947259f74/go.mod h1:zfRbgnPVxXCSpiKrg1CE72hNUWInqxExiaz2D9ppTts=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
2 changes: 1 addition & 1 deletion chart/test/helm_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func helmRunnerToLocation(location string, parts ...string) (execute.ExecResult,
}
fullParts := append(firstParts, parts...)
task := execute.ExecTask{
Command: "helm3",
Command: "helm",
Args: fullParts,
}

Expand Down
2 changes: 1 addition & 1 deletion chart/test/network_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"
)

func Test_YamlSpec_NoNW_Policies(t *testing.T){
func Test_YamlSpec_NoNW_Policies(t *testing.T) {
parts := []string{
"--set", "networkPolicies.enabled=false",
}
Expand Down
6 changes: 3 additions & 3 deletions chart/test/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ func serviceBuilder(svcName, svcType string, srcPort, targetPort int) SvcSpec {
ApiVersion: "v1",
Kind: "Service",
Metadata: MetadataItems{
Name: svcName,
Name: svcName,
Namespace: "openfaas",
Labels: labelMap,
Labels: labelMap,
},
Spec: MapSpec{
Type: svcType,
Expand Down Expand Up @@ -110,4 +110,4 @@ func runYamlTestNoFileExpected(parts []string, filename string, t *testing.T) {
if !os.IsNotExist(err) {
t.Errorf("Expected file not to exist, got err: %v", err)
}
}
}
8 changes: 2 additions & 6 deletions contrib/ci.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#!/bin/sh

set -e
# Run this command from one-level higher in the folder path, not this folder.

(cd of-builder && make) && \
(cd edge-router && make build) && \
(cd sdk && go build) && \

CLI="faas-cli"
if ! [ -x "$(command -v faas-cli)" ]; then
HERE=`pwd`
Expand All @@ -21,4 +17,4 @@ fi
echo "Working folder: `pwd`"

$CLI build --parallel=4
#
$CLI build -f dashboard/stack.yml
24 changes: 24 additions & 0 deletions contrib/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
set -e

# Run this command from one-level higher in the folder path, not this folder.

CLI="faas-cli"
if ! [ -x "$(command -v faas-cli)" ]; then
HERE=`pwd`
cd /tmp/
curl -sL https://github.com/openfaas/faas-cli/releases/download/0.9.3/faas-cli > faas-cli
chmod +x ./faas-cli
CLI="/tmp/faas-cli"

echo "Returning to $HERE"
cd $HERE
fi

echo "Working folder: `pwd`"

$CLI up --parallel=4 --skip-deploy
HERE=`pwd`
cd dashboard
$CLI up -f stack.yml --skip-deploy
cd $HERE
3 changes: 1 addition & 2 deletions dashboard/stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ provider:
name: openfaas
gateway: http://127.0.0.1:8080

# TODO Waterdrips this multi-arch
functions:
system-dashboard:
lang: node12
handler: ./of-cloud-dashboard
image: functions/of-cloud-dashboard:0.8.2
image: ghcr.io/${REPO:-openfaas}/of-cloud-dashboard:${TAG:-latest-dev}
labels:
openfaas-cloud: "1"
role: openfaas-system
Expand Down
Loading

0 comments on commit 707889f

Please sign in to comment.