Skip to content

Commit

Permalink
Fixed #xxx: Run Skupper integration tests for skupper-router image
Browse files Browse the repository at this point in the history
  • Loading branch information
jiridanek committed Mar 11, 2022
1 parent 0e2c88b commit b29e6d5
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 18 deletions.
113 changes: 113 additions & 0 deletions .github/actions/skupper-integration-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

name: Test skupper-router main
description: Execute skupper integration testing

inputs:

qdrouterdImage:
required: true
description: Image to use in skupper integration tests

skupperGitRef:
required: false
description: Reference to skupper version
default: "0.8.7"

runs:
using: "composite"
steps:

- name: Get Go cache paths
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
shell: bash

- name: Install microk8s
run: |
sudo snap install microk8s --classic --channel=1.21/stable
sudo microk8s enable dns ingress storage registry:size=20Gi host-access:ip=10.0.1.1 metallb:10.64.140.43-10.64.140.49
sudo microk8s status --wait-ready
shell: bash

- name: Export microk8s config
if: "${{ always() }}"
run: |
mkdir -p $HOME/.kube
sudo microk8s config > $HOME/.kube/config
shell: bash

- name: Push image into microk8s
run: |
docker tag "${{ inputs.qdrouterdImage }}" localhost:32000/skupper-router:registry
timeout 5m bash -c 'until nc -z localhost 32000; do sleep 1; done' || :
docker push localhost:32000/skupper-router:registry
shell: bash

- name: Checkout Skupper
uses: actions/checkout@v2
with:
repository: 'skupperproject/skupper'
ref: "${{ inputs.skupperGitRef }}"
path: 'skupper'

- name: Restore Go cache
uses: actions/cache@v2
with:
path: |
${{ steps.go-cache-paths.outputs.go-build }}
${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}

- name: Compile Skupper
run: |
make all
sudo install skupper /usr/local/bin
working-directory: skupper
shell: bash

- name: Run Skupper integration tests
run: |
export PUBLIC_1_INGRESS_HOST=10.0.1.1
export QDROUTERD_IMAGE=localhost:32000/skupper-router:registry
go test -count=1 -p=1 -timeout=60m -tags=integration -v ./test/integration/...
working-directory: skupper
shell: bash

- name: Dump microk8s log (apiserver)
if: "${{ always() }}"
run: |
sudo journalctl -u snap.microk8s.daemon-apiserver
shell: bash

- name: Dump microk8s log (kubelet)
if: "${{ always() }}"
run: |
sudo journalctl -u snap.microk8s.daemon-kubelet
shell: bash

- name: Dump microk8s log (kubelite)
if: "${{ always() }}"
run: |
sudo journalctl -u snap.microk8s.daemon-kubelite
shell: bash
26 changes: 26 additions & 0 deletions .github/scripts/image-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

. ./.github/scripts/common.sh

# Building the skupper-router image
${DOCKER} build -t ${PROJECT_NAME}:${PROJECT_TAG} -f ./.github/scripts/Dockerfile .

echo "::set-output name=image-tag::${PROJECT_NAME}:${PROJECT_TAG}"

3 changes: 0 additions & 3 deletions .github/scripts/image.sh → .github/scripts/image-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@

. ./.github/scripts/common.sh

# Building the skupper-router image
${DOCKER} build -t ${PROJECT_NAME}:${PROJECT_TAG} -f ./.github/scripts/Dockerfile .

# Pushing only when credentials available
if [[ -n "${DOCKER_USER}" && -n "${DOCKER_PASSWORD}" ]]; then
${DOCKER} login -u ${DOCKER_USER} -p ${DOCKER_PASSWORD} ${DOCKER_REGISTRY}
Expand Down
30 changes: 21 additions & 9 deletions .github/workflows/image-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,34 @@
#

name: Publish skupper-router main
on:
workflow_run:
workflows: ["Build"]
branches: [main]
types:
- completed
on: [push, pull_request, workflow_dispatch]
jobs:
build-image:
name: Publish skupper-router image
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2
- run: |
# build and publish the main image

- name: build the main image
id: image-build
run: |
. ./.github/scripts/common.sh
./.github/scripts/image.sh
./.github/scripts/image-build.sh
env:
DOCKER_USER: '${{ secrets.DOCKER_USER }}'
DOCKER_PASSWORD: '${{ secrets.DOCKER_PASSWORD }}'

- name: run tests (skupper integration tests)
uses: ./.github/actions/skupper-integration-tests
with:
qdrouterdImage: "${{ steps.image-build.outputs.image-tag }}"

- name: publish the main image
if: ${{ github.ref == 'refs/heads/main' }}
run: |
. ./.github/scripts/common.sh
./.github/scripts/image-push.sh
env:
DOCKER_USER: '${{ secrets.DOCKER_USER }}'
DOCKER_PASSWORD: '${{ secrets.DOCKER_PASSWORD }}'
29 changes: 23 additions & 6 deletions .github/workflows/image-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ jobs:
name: Build and publish skupper-router image
runs-on: ubuntu-latest
steps:
- run: |
# validate DOCKER_TAG

- name: validate DOCKER_TAG
run: |
[[ ! "${DOCKER_TAG}" =~ ^[a-z0-9][a-z0-9.-]+[a-z0-9]$ ]] && echo "invalid tag - it must begin and end with letter or digit and contains - and ." && exit 1
protected=(latest nightly master)
for ptag in ${protected[@]}; do
Expand All @@ -46,14 +47,30 @@ jobs:
done
env:
DOCKER_TAG: '${{github.event.inputs.dockerTag}}'

- uses: actions/checkout@v2
- run: |
# build, run tests and if all worked publish a custom image

- name: build a custom image
id: image-build
run: |
. ./.github/scripts/common.sh
export PROJECT_TAG="${DOCKER_TAG}"
./.github/scripts/image.sh
./.github/scripts/image-build.sh
env:
PROTON_SOURCE_URL: '${{github.event.inputs.protonSourceUrl}}'
DOCKER_TAG: '${{github.event.inputs.dockerTag}}'

- name: run tests (skupper integration tests)
uses: ./.github/actions/skupper-integration-tests
with:
qdrouterdImage: "${{ steps.image-build.outputs.image-tag }}"

- name: publish a custom image
run: |
. ./.github/scripts/common.sh
export PROJECT_TAG="${DOCKER_TAG}"
./.github/scripts/image-push.sh
env:
DOCKER_USER: '${{ secrets.DOCKER_USER }}'
DOCKER_PASSWORD: '${{ secrets.DOCKER_PASSWORD }}'
PROTON_SOURCE_URL: '${{github.event.inputs.protonSourceUrl}}'
DOCKER_TAG: '${{github.event.inputs.dockerTag}}'

0 comments on commit b29e6d5

Please sign in to comment.