Skip to content

Customize image build and integration test #452

Customize image build and integration test

Customize image build and integration test #452

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
env:
TEST_KUBECTL: yes
TEST_MINIKUBE_ENABLED: yes
TEST_MQTT_LOCAL_ENABLED: yes
TEST_DOCKER_ENABLED: yes
TEST_K8S_STATE: yes
TEST_SYMPHONY_HELM_VERSION: yes
TEST_HELM_CHART: yes
TEST_CONFIGMAP: yes # requires minikube start
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21
- name: Set up custom GOPATH
run: |
mkdir -p /home/runner/go
echo "export GOPATH=/home/runner/go" >> $HOME/.bashrc
echo "export PATH=\$PATH:\$GOPATH/bin" >> $HOME/.bashrc
source $HOME/.bashrc
- name: Install make
run: sudo apt-get update && sudo apt-get install -y build-essential
- name: Check docker version and images
run: docker --version && docker images
- name: Install kubectl
run: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version --client
kubectl config view
- name: Install minikube
run: |
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
chmod +x minikube
sudo mv minikube /usr/local/bin/
minikube start
kubectl config view
- name: Install Mqtt
run: |
sudo apt-get update
sudo apt-get install mosquitto mosquitto-clients
sudo service mosquitto start
sudo service mosquitto status
- name: Install Mage
run: |
cd ..
git clone https://github.com/magefile/mage
cd mage
go run bootstrap.go
cd ..
- name: COA Test
run: cd coa && mage cleanTest
- name: API Build
run: cd api && go build -o symphony-api
- name: API Test
run: |
echo "TEST_KUBECTL:$TEST_KUBECTL TEST_MINIKUBE_ENABLED:$TEST_MINIKUBE_ENABLED TEST_K8S_STATE: $TEST_K8S_STATE TEST_CONFIGMAP: $TEST_CONFIGMAP"
export REPOPATH="${{ github.workspace }}"
echo "REPOPATH=$REPOPATH"
cd api && mage cleanTest
- name: K8S Test
run: cd k8s && mage operatorTest
- name: target-api-testcoverage-app
run: |
cd api
COVERAGE=`mage printCoverage`
echo "coverage=$COVERAGE"
go tool cover -html=coverage.out -o coverage-api.html
continue-on-error: true
if: always()
- name: target-k8s-testcoverage-app
run: |
cd k8s
COVERAGE=`mage printCoverage`
echo "coverage=$COVERAGE"
go tool cover -html=coverage.out -o coverage-k8s.html
continue-on-error: true
if: always()
- name: target-coa-testcoverage-app
run: |
cd coa
COVERAGE=`mage printCoverage`
echo "coverage=$COVERAGE"
go tool cover -html=coverage.out -o coverage-coa.html
continue-on-error: true
if: always()
- name: Upload test assets
uses: actions/upload-artifact@v2
with:
name: test-coverage
path: |
api/coverage-api.html
k8s/coverage-k8s.html
coa/coverage-coa.html