chore(CI): update workflows

Signed-off-by: zhanghongtong <rory-z@outlook.com>
This commit is contained in:
zhanghongtong 2021-08-23 09:41:37 +08:00 committed by Rory Z
parent 335b8fec63
commit 41f2b77ec3
3 changed files with 302 additions and 286 deletions

View File

@ -8,300 +8,186 @@ on:
pull_request: pull_request:
jobs: jobs:
docker_test: prepare:
runs-on: ubuntu-20.04 strategy:
matrix:
container:
- "emqx/build-env:erl23.2.7.2-emqx-2-ubuntu20.04"
- "emqx/build-env:erl24.0.5-emqx-1-ubuntu20.04"
steps: runs-on: ubuntu-20.04
- uses: actions/checkout@v1 container: ${{ matrix.container }}
- uses: gleam-lang/setup-erlang@v1.1.2
id: install_erlang
with:
otp-version: 24.0.5
- name: prepare
run: |
if make emqx-ee --dry-run > /dev/null 2>&1; then
echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
git config --global credential.helper store
echo "${{ secrets.CI_GIT_TOKEN }}" >> scripts/git-token
make deps-emqx-ee
echo "PROFILE=emqx-ee" >> $GITHUB_ENV
echo "TARGET=emqx/emqx-ee" >> $GITHUB_ENV
echo "EMQX_TAG=$(./pkg-vsn.sh)" >> $GITHUB_ENV
else
echo "PROFILE=emqx" >> $GITHUB_ENV
echo "TARGET=emqx/emqx" >> $GITHUB_ENV
echo "EMQX_TAG=$(./pkg-vsn.sh)" >> $GITHUB_ENV
fi
- name: make emqx image
run: make $PROFILE-docker
- name: run emqx
timeout-minutes: 5
run: |
set -e -u -x
echo "HOCON_ENV_OVERRIDE_PREFIX=EMQX_" >> .ci/docker-compose-file/conf.cluster.env
echo "EMQX_ZONES__DEFAULT__MQTT__RETRY_INTERVAL=2s" >> .ci/docker-compose-file/conf.cluster.env
echo "EMQX_ZONES__DEFAULT__MQTT__MAX_TOPIC_ALIAS=10" >> .ci/docker-compose-file/conf.cluster.env
docker-compose \
-f .ci/docker-compose-file/docker-compose-emqx-cluster.yaml \
-f .ci/docker-compose-file/docker-compose-python.yaml \
up -d
while ! docker exec -i node1.emqx.io bash -c "emqx eval \"['emqx@node1.emqx.io','emqx@node2.emqx.io'] = maps:get(running_nodes, ekka_cluster:info()).\"" > /dev/null 2>&1; do
echo "['$(date -u +"%Y-%m-%dT%H:%M:%SZ")']:waiting emqx";
sleep 5;
done
# - name: verify EMQX_LOADED_PLUGINS override working
# run: |
# expected="{emqx_sn, true}."
# output=$(docker exec -i node1.emqx.io bash -c "cat data/loaded_plugins" | tail -n1)
# if [ "$expected" != "$output" ]; then
# exit 1
# fi
- name: make paho tests
run: |
if ! docker exec -i python /scripts/pytest.sh; then
echo "DUMP_CONTAINER_LOGS_BGN"
docker logs haproxy
docker logs node1.emqx.io
docker logs node2.emqx.io
echo "DUMP_CONTAINER_LOGS_END"
exit 1
fi
helm_test: outputs:
runs-on: ubuntu-20.04 profile: ${{ steps.profile.outputs.profile }}
steps: steps:
- uses: actions/checkout@v1 - name: get otp version
- uses: gleam-lang/setup-erlang@v1.1.2 id: get_otp_version
id: install_erlang run: |
with: otp="$(erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"])), io:fwrite(Version), halt().' -noshell)"
otp-version: 24.0.5 echo "::set-output name=otp::$otp"
- name: prepare - uses: actions/checkout@v2
run: | with:
if make emqx-ee --dry-run > /dev/null 2>&1; then path: source
echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials fetch-depth: 0
git config --global credential.helper store - name: set profile
echo "${{ secrets.CI_GIT_TOKEN }}" >> scripts/git-token id: profile
make deps-emqx-ee shell: bash
echo "TARGET=emqx/emqx-ee" >> $GITHUB_ENV working-directory: source
echo "PROFILE=emqx-ee" >> $GITHUB_ENV run: |
else vsn="$(./pkg-vsn.sh)"
echo "TARGET=emqx/emqx" >> $GITHUB_ENV if make emqx-ee --dry-run > /dev/null 2>&1; then
echo "PROFILE=emqx" >> $GITHUB_ENV echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
fi git config --global credential.helper store
- name: make emqx image echo "::set-output name=profile::emqx-ee"
run: make $PROFILE-docker else
- name: install k3s echo "::set-output name=profile::emqx"
env: fi
KUBECONFIG: "/etc/rancher/k3s/k3s.yaml" - name: get deps
run: | working-directory: source
sudo sh -c "echo \"127.0.0.1 $(hostname)\" >> /etc/hosts" run: |
curl -sfL https://get.k3s.io | sh - make ensure-rebar3
sudo chmod 644 /etc/rancher/k3s/k3s.yaml ./rebar3 as default get-deps
kubectl cluster-info rm -rf rebar.lock
- name: install helm - name: gen zip file
env: run: zip -ryq source-${{ steps.get_otp_version.outputs.otp }}.zip source/* source/.[^.]*
KUBECONFIG: "/etc/rancher/k3s/k3s.yaml" - uses: actions/upload-artifact@v2
run: | with:
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 name: source-${{ steps.get_otp_version.outputs.otp }}
sudo chmod 700 get_helm.sh path: source-${{ steps.get_otp_version.outputs.otp }}.zip
sudo ./get_helm.sh
helm version
- name: run emqx on chart
env:
KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
timeout-minutes: 5
run: |
version=$(./pkg-vsn.sh)
sudo docker save ${TARGET}:$version -o emqx.tar.gz
sudo k3s ctr image import emqx.tar.gz
sed -i -r "s/^appVersion: .*$/appVersion: \"${version}\"/g" deploy/charts/emqx/Chart.yaml docker_test:
sed -i '/emqx_telemetry/d' deploy/charts/emqx/values.yaml runs-on: ubuntu-20.04
needs: prepare
helm install emqx \ strategy:
--set image.repository=${TARGET} \ fail-fast: false
--set image.pullPolicy=Never \ matrix:
--set emqxAclConfig="" \ otp:
--set image.pullPolicy=Never \ - 23.2.7.2-emqx-2
--set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__RETRY_INTERVAL=2s \ - 24.0.5-emqx-1
--set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__MAX_TOPIC_ALIAS=10 \
deploy/charts/emqx \
--debug
while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \ steps:
!= "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do - uses: actions/download-artifact@v2
echo "=============================="; with:
kubectl get pods; name: source-${{ matrix.otp }}
echo "=============================="; path: .
echo "waiting emqx started"; - name: unzip source code
sleep 10; run: unzip -q source-${{ matrix.otp }}.zip
done - name: make docker image
- name: get emqx-0 pods log working-directory: source
if: failure() env:
env: OTP: ${{ matrix.otp }}
KUBECONFIG: "/etc/rancher/k3s/k3s.yaml" run: |
run: | make ${{ needs.prepare.outputs.profile }}-docker
kubectl describe pods emqx-0 echo "TARGET=emqx/${{ needs.prepare.outputs.profile }}" >> $GITHUB_ENV
kubectl logs emqx-0 echo "EMQX_TAG=$(./pkg-vsn.sh)" >> $GITHUB_ENV
- name: get emqx-1 pods log - name: run emqx
if: failure() timeout-minutes: 5
env: working-directory: source
KUBECONFIG: "/etc/rancher/k3s/k3s.yaml" run: |
run: | set -e -u -x
kubectl describe pods emqx-1 echo "HOCON_ENV_OVERRIDE_PREFIX=EMQX_" >> .ci/docker-compose-file/conf.cluster.env
kubectl logs emqx-1 echo "EMQX_ZONES__DEFAULT__MQTT__RETRY_INTERVAL=2s" >> .ci/docker-compose-file/conf.cluster.env
- name: get emqx-2 pods log echo "EMQX_ZONES__DEFAULT__MQTT__MAX_TOPIC_ALIAS=10" >> .ci/docker-compose-file/conf.cluster.env
if: failure() docker-compose \
env: -f .ci/docker-compose-file/docker-compose-emqx-cluster.yaml \
KUBECONFIG: "/etc/rancher/k3s/k3s.yaml" -f .ci/docker-compose-file/docker-compose-python.yaml \
run: | up -d
kubectl describe pods emqx-2 while ! docker exec -i node1.emqx.io bash -c "emqx eval \"['emqx@node1.emqx.io','emqx@node2.emqx.io'] = maps:get(running_nodes, ekka_cluster:info()).\"" > /dev/null 2>&1; do
kubectl logs emqx-2 echo "['$(date -u +"%Y-%m-%dT%H:%M:%SZ")']:waiting emqx";
- uses: actions/checkout@v2 sleep 5;
with: done
repository: emqx/paho.mqtt.testing - name: make paho tests
ref: develop-4.0 run: |
path: paho.mqtt.testing if ! docker exec -i python /scripts/pytest.sh; then
- name: install pytest echo "DUMP_CONTAINER_LOGS_BGN"
run: | docker logs haproxy
pip install pytest docker logs node1.emqx.io
echo "$HOME/.local/bin" >> $GITHUB_PATH docker logs node2.emqx.io
- name: run paho test echo "DUMP_CONTAINER_LOGS_END"
env: exit 1
KUBECONFIG: "/etc/rancher/k3s/k3s.yaml" fi
run: |
emqx_svc=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
emqx1=$(kubectl get pods emqx-1 -o jsonpath='{.status.podIP}')
emqx2=$(kubectl get pods emqx-2 -o jsonpath='{.status.podIP}')
pytest -v paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host $emqx_svc helm_test:
RESULT=$? runs-on: ubuntu-20.04
pytest -v paho.mqtt.testing/interoperability/test_cluster --host1 $emqx1 --host2 $emqx2 needs: prepare
RESULT=$((RESULT + $?))
if [ 0 -ne $RESULT ]; then
kubectl logs emqx-1
kubectl logs emqx-2
fi
exit $RESULT
relup_test: strategy:
strategy: fail-fast: false
matrix: matrix:
container: otp:
- "emqx/build-env:erl23.2.7.2-emqx-2-ubuntu20.04" - 23.2.7.2-emqx-2
- "emqx/build-env:erl24.0.5-emqx-1-ubuntu20.04" - 24.0.5-emqx-1
runs-on: ubuntu-20.04 steps:
container: ${{ matrix.container }} - uses: actions/download-artifact@v2
with:
name: source-${{ matrix.otp }}
path: .
- name: unzip source code
run: unzip -q source-${{ matrix.otp }}.zip
- name: make docker image
working-directory: source
env:
OTP: ${{ matrix.otp }}
run: |
make ${{ needs.prepare.outputs.profile }}-docker
echo "TARGET=emqx/${{ needs.prepare.outputs.profile }}" >> $GITHUB_ENV
echo "EMQX_TAG=$(./pkg-vsn.sh)" >> $GITHUB_ENV
- run: minikube start
- name: run emqx on chart
timeout-minutes: 5
working-directory: source
run: |
minikube image load $TARGET:$EMQX_TAG
defaults: sed -i -r "s/^appVersion: .*$/appVersion: \"$EMQX_TAG\"/g" deploy/charts/emqx/Chart.yaml
run:
shell: bash
steps:
- uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'
- uses: actions/checkout@v2
with:
repository: emqx/paho.mqtt.testing
ref: develop-4.0
path: paho.mqtt.testing
- uses: actions/checkout@v2
with:
repository: terry-xiaoyu/one_more_emqx
ref: master
path: one_more_emqx
- uses: actions/checkout@v2
with:
repository: emqx/emqtt-bench
ref: master
path: emqtt-bench
- uses: actions/checkout@v2
with:
repository: hawk/lux
ref: lux-2.6
path: lux
- uses: actions/checkout@v2
with:
repository: ${{ github.repository }}
path: emqx
fetch-depth: 0
- name: prepare
run: |
if make -C emqx emqx-ee --dry-run > /dev/null 2>&1; then
echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
git config --global credential.helper store
echo "${{ secrets.CI_GIT_TOKEN }}" >> emqx/scripts/git-token
echo "PROFILE=emqx-ee" >> $GITHUB_ENV
else
echo "PROFILE=emqx" >> $GITHUB_ENV
fi
- name: get version
run: |
set -e -x -u
cd emqx
if [ $PROFILE = "emqx" ];then
broker="emqx-ce"
edition='opensource'
else
broker="emqx-ee"
edition='enterprise'
fi
echo "BROKER=$broker" >> $GITHUB_ENV
vsn="$(./pkg-vsn.sh)" helm install emqx \
echo "VSN=$vsn" >> $GITHUB_ENV --set image.repository=$TARGET \
--set image.pullPolicy=Never \
--set emqxAclConfig="" \
--set image.pullPolicy=Never \
--set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__RETRY_INTERVAL=2s \
--set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__MAX_TOPIC_ALIAS=10 \
deploy/charts/emqx \
--debug
pre_vsn="$(echo $vsn | grep -oE '^[0-9]+.[0-9]')" while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
if [ $PROFILE = "emqx" ]; then != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
old_vsns="$(git tag -l "v$pre_vsn.[0-9]" | xargs echo -n | sed "s/v$vsn//")" echo "==============================";
else kubectl get pods;
old_vsns="$(git tag -l "e$pre_vsn.[0-9]" | xargs echo -n | sed "s/e$vsn//")" echo "==============================";
fi echo "waiting emqx started";
echo "OLD_VSNS=$old_vsns" >> $GITHUB_ENV sleep 10;
- name: download emqx done
run: | - name: get emqx-0 pods log
set -e -x -u if: failure()
mkdir -p emqx/_upgrade_base run: |
cd emqx/_upgrade_base kubectl describe pods emqx-0
old_vsns=($(echo $OLD_VSNS | tr ' ' ' ')) kubectl logs emqx-0
for old_vsn in ${old_vsns[@]}; do - name: get emqx-1 pods log
wget --no-verbose https://s3-us-west-2.amazonaws.com/packages.emqx/$BROKER/$old_vsn/$PROFILE-ubuntu20.04-${old_vsn#[e|v]}-amd64.zip if: failure()
done run: |
- name: build emqx kubectl describe pods emqx-1
run: make -C emqx ${PROFILE}-zip kubectl logs emqx-1
- name: build emqtt-bench - name: get emqx-2 pods log
run: make -C emqtt-bench if: failure()
- name: build lux run: |
run: | kubectl describe pods emqx-2
set -e -u -x kubectl logs emqx-2
cd lux - uses: actions/checkout@v2
autoconf with:
./configure repository: emqx/paho.mqtt.testing
make ref: develop-4.0
make install path: paho.mqtt.testing
- name: run relup test - name: install pytest
timeout-minutes: 20 run: |
run: | pip install pytest
set -e -x -u echo "$HOME/.local/bin" >> $GITHUB_PATH
if [ -n "$OLD_VSNS" ]; then - name: run paho test
mkdir -p packages run: |
cp emqx/_packages/${PROFILE}/*.zip packages kubectl port-forward service/emqx 1883:1883 > /dev/null &
cp emqx/_upgrade_base/*.zip packages pytest -v paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host "127.0.0.1"
lux \
--case_timeout infinity \
--var PROFILE=$PROFILE \
--var PACKAGE_PATH=$(pwd)/packages \
--var BENCH_PATH=$(pwd)/emqtt-bench \
--var ONE_MORE_EMQX_PATH=$(pwd)/one_more_emqx \
--var VSN="$VSN" \
--var OLD_VSNS="$OLD_VSNS" \
emqx/.ci/fvt_tests/relup.lux
fi
- uses: actions/upload-artifact@v1
if: failure()
with:
name: lux_logs
path: lux_logs

130
.github/workflows/run_relup_tests.yaml vendored Normal file
View File

@ -0,0 +1,130 @@
name: Release Upgrade Tests
on:
push:
tags:
- v*
- e*
pull_request:
jobs:
relup_test:
strategy:
matrix:
container:
- "emqx/build-env:erl23.2.7.2-emqx-2-ubuntu20.04"
- "emqx/build-env:erl24.0.5-emqx-1-ubuntu20.04"
runs-on: ubuntu-20.04
container: ${{ matrix.container }}
defaults:
run:
shell: bash
steps:
- uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'
- uses: actions/checkout@v2
with:
repository: emqx/paho.mqtt.testing
ref: develop-4.0
path: paho.mqtt.testing
- uses: actions/checkout@v2
with:
repository: terry-xiaoyu/one_more_emqx
ref: master
path: one_more_emqx
- uses: actions/checkout@v2
with:
repository: emqx/emqtt-bench
ref: master
path: emqtt-bench
- uses: actions/checkout@v2
with:
repository: hawk/lux
ref: lux-2.6
path: lux
- uses: actions/checkout@v2
with:
repository: ${{ github.repository }}
path: emqx
fetch-depth: 0
- name: prepare
run: |
if make -C emqx emqx-ee --dry-run > /dev/null 2>&1; then
echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
git config --global credential.helper store
echo "${{ secrets.CI_GIT_TOKEN }}" >> emqx/scripts/git-token
echo "PROFILE=emqx-ee" >> $GITHUB_ENV
else
echo "PROFILE=emqx" >> $GITHUB_ENV
fi
- name: get version
run: |
set -e -x -u
cd emqx
if [ $PROFILE = "emqx" ];then
broker="emqx-ce"
edition='opensource'
else
broker="emqx-ee"
edition='enterprise'
fi
echo "BROKER=$broker" >> $GITHUB_ENV
vsn="$(./pkg-vsn.sh)"
echo "VSN=$vsn" >> $GITHUB_ENV
pre_vsn="$(echo $vsn | grep -oE '^[0-9]+.[0-9]')"
if [ $PROFILE = "emqx" ]; then
old_vsns="$(git tag -l "v$pre_vsn.[0-9]" | xargs echo -n | sed "s/v$vsn//")"
else
old_vsns="$(git tag -l "e$pre_vsn.[0-9]" | xargs echo -n | sed "s/e$vsn//")"
fi
echo "OLD_VSNS=$old_vsns" >> $GITHUB_ENV
- name: download emqx
run: |
set -e -x -u
mkdir -p emqx/_upgrade_base
cd emqx/_upgrade_base
old_vsns=($(echo $OLD_VSNS | tr ' ' ' '))
for old_vsn in ${old_vsns[@]}; do
wget --no-verbose https://s3-us-west-2.amazonaws.com/packages.emqx/$BROKER/$old_vsn/$PROFILE-ubuntu20.04-${old_vsn#[e|v]}-amd64.zip
done
- name: build emqx
run: make -C emqx ${PROFILE}-zip
- name: build emqtt-bench
run: make -C emqtt-bench
- name: build lux
run: |
set -e -u -x
cd lux
autoconf
./configure
make
make install
- name: run relup test
timeout-minutes: 20
run: |
set -e -x -u
if [ -n "$OLD_VSNS" ]; then
mkdir -p packages
cp emqx/_packages/${PROFILE}/*.zip packages
cp emqx/_upgrade_base/*.zip packages
lux \
--case_timeout infinity \
--var PROFILE=$PROFILE \
--var PACKAGE_PATH=$(pwd)/packages \
--var BENCH_PATH=$(pwd)/emqtt-bench \
--var ONE_MORE_EMQX_PATH=$(pwd)/one_more_emqx \
--var VSN="$VSN" \
--var OLD_VSNS="$OLD_VSNS" \
emqx/.ci/fvt_tests/relup.lux
fi
- uses: actions/upload-artifact@v1
if: failure()
with:
name: lux_logs
path: lux_logs

2
build
View File

@ -128,7 +128,7 @@ make_docker() {
docker build --no-cache \ docker build --no-cache \
--build-arg PKG_VSN="$PKG_VSN" \ --build-arg PKG_VSN="$PKG_VSN" \
--build-arg BUILD_FROM=emqx/build-env:erl23.2.7.2-emqx-2-alpine \ --build-arg BUILD_FROM="emqx/build-env:erl${OTP:-23.2.7.2-emqx-2}-alpine" \
--build-arg EMQX_NAME="$PROFILE" \ --build-arg EMQX_NAME="$PROFILE" \
--tag "emqx/$PROFILE:$PKG_VSN" \ --tag "emqx/$PROFILE:$PKG_VSN" \
-f deploy/docker/Dockerfile . -f deploy/docker/Dockerfile .