ci: reduce test matrix size
Test emqx profile under OTP-25 only. Build test matrix programmatically for that purpose.
This commit is contained in:
parent
f17ebb8796
commit
501f0fc8d5
|
@ -14,38 +14,60 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
build-matrix:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
prepare: ${{ steps.matrix.outputs.prepare }}
|
||||||
|
host: ${{ steps.matrix.outputs.host }}
|
||||||
|
docker: ${{ steps.matrix.outputs.docker }}
|
||||||
|
runs-on: ${{ steps.runner.outputs.runs-on }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Build matrix
|
||||||
|
id: matrix
|
||||||
|
run: |
|
||||||
|
APPS="$(./scripts/find-apps.sh --ci)"
|
||||||
|
MATRIX="$(echo "${APPS}" | jq -c '
|
||||||
|
[
|
||||||
|
(.[] | select(.profile == "emqx") | . + {
|
||||||
|
builder: "5.0-26",
|
||||||
|
otp: "25.1.2-2",
|
||||||
|
elixir: "1.13.4"
|
||||||
|
}),
|
||||||
|
(.[] | select(.profile == "emqx-enterprise") | . + {
|
||||||
|
builder: "5.0-26",
|
||||||
|
otp: ["24.3.4.2-1", "25.1.2-2"][],
|
||||||
|
elixir: "1.13.4"
|
||||||
|
})
|
||||||
|
]
|
||||||
|
')"
|
||||||
|
echo "${MATRIX}" | jq
|
||||||
|
MATRIX_PREPARE="$(echo "${MATRIX}" | jq -c 'map({profile, builder, otp, elixir}) | unique')"
|
||||||
|
MATRIX_HOST="$(echo "${MATRIX}" | jq -c 'map(select(.runner == "host"))')"
|
||||||
|
MATRIX_DOCKER="$(echo "${MATRIX}" | jq -c 'map(select(.runner == "docker"))')"
|
||||||
|
echo "prepare=${MATRIX_PREPARE}" | tee -a $GITHUB_OUTPUT
|
||||||
|
echo "host=${MATRIX_HOST}" | tee -a $GITHUB_OUTPUT
|
||||||
|
echo "docker=${MATRIX_DOCKER}" | tee -a $GITHUB_OUTPUT
|
||||||
|
- name: Choose runner host
|
||||||
|
id: runner
|
||||||
|
run: |
|
||||||
|
RUNS_ON="ubuntu-20.04"
|
||||||
|
${{ github.repository_owner == 'emqx' }} && RUNS_ON="aws-amd64"
|
||||||
|
echo "runs-on=${RUNS_ON}" | tee -a $GITHUB_OUTPUT
|
||||||
|
|
||||||
prepare:
|
prepare:
|
||||||
runs-on: aws-amd64
|
runs-on: aws-amd64
|
||||||
|
needs: [build-matrix]
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
profile:
|
include: ${{ fromJson(needs.build-matrix.outputs.prepare) }}
|
||||||
- emqx
|
|
||||||
- emqx-enterprise
|
|
||||||
builder:
|
|
||||||
- 5.0-26
|
|
||||||
otp:
|
|
||||||
- 24.3.4.2-1
|
|
||||||
- 25.1.2-2
|
|
||||||
elixir:
|
|
||||||
- 1.13.4
|
|
||||||
container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu20.04"
|
container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu20.04"
|
||||||
outputs:
|
|
||||||
fast_ct_apps: ${{ steps.find_ct_apps.outputs.fast_ct_apps }}
|
|
||||||
docker_ct_apps: ${{ steps.find_ct_apps.outputs.docker_ct_apps }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: AutoModality/action-clean@v1
|
- uses: AutoModality/action-clean@v1
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
path: source
|
path: source
|
||||||
- name: Find CT Apps
|
|
||||||
working-directory: source
|
|
||||||
id: find_ct_apps
|
|
||||||
run: |
|
|
||||||
fast_ct_apps="$(./scripts/find-apps.sh --ci fast)"
|
|
||||||
docker_ct_apps="$(./scripts/find-apps.sh --ci docker)"
|
|
||||||
echo "fast_ct_apps=$fast_ct_apps" | tee -a $GITHUB_OUTPUT
|
|
||||||
echo "docker_ct_apps=$docker_ct_apps" | tee -a $GITHUB_OUTPUT
|
|
||||||
- name: get_all_deps
|
- name: get_all_deps
|
||||||
working-directory: source
|
working-directory: source
|
||||||
env:
|
env:
|
||||||
|
@ -64,31 +86,14 @@ jobs:
|
||||||
path: source.zip
|
path: source.zip
|
||||||
|
|
||||||
eunit_and_proper:
|
eunit_and_proper:
|
||||||
needs: [prepare]
|
needs:
|
||||||
runs-on: ${{ matrix.runs-on }}
|
- build-matrix
|
||||||
|
- prepare
|
||||||
|
runs-on: ${{ needs.build-matrix.outputs.runs-on }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
profile:
|
include: ${{ fromJson(needs.build-matrix.outputs.prepare) }}
|
||||||
- emqx
|
|
||||||
- emqx-enterprise
|
|
||||||
builder:
|
|
||||||
- 5.0-26
|
|
||||||
otp:
|
|
||||||
- 24.3.4.2-1
|
|
||||||
- 25.1.2-2
|
|
||||||
elixir:
|
|
||||||
- 1.13.4
|
|
||||||
runs-on:
|
|
||||||
- aws-amd64
|
|
||||||
- ubuntu-20.04
|
|
||||||
use-self-hosted:
|
|
||||||
- ${{ github.repository_owner == 'emqx' }}
|
|
||||||
exclude:
|
|
||||||
- runs-on: ubuntu-20.04
|
|
||||||
use-self-hosted: true
|
|
||||||
- runs-on: aws-amd64
|
|
||||||
use-self-hosted: false
|
|
||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
|
@ -123,30 +128,15 @@ jobs:
|
||||||
path: source/_build/test/cover
|
path: source/_build/test/cover
|
||||||
|
|
||||||
ct_docker:
|
ct_docker:
|
||||||
needs: [prepare]
|
needs:
|
||||||
|
- build-matrix
|
||||||
|
- prepare
|
||||||
|
runs-on: ${{ needs.build-matrix.outputs.runs-on }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
app: ${{ fromJson(needs.prepare.outputs.docker_ct_apps) }}
|
include: ${{ fromJson(needs.build-matrix.outputs.docker) }}
|
||||||
runs-on:
|
|
||||||
- aws-amd64
|
|
||||||
- ubuntu-20.04
|
|
||||||
use-self-hosted:
|
|
||||||
- ${{ github.repository_owner == 'emqx' }}
|
|
||||||
builder:
|
|
||||||
- 5.0-26
|
|
||||||
otp:
|
|
||||||
- 24.3.4.2-1
|
|
||||||
- 25.1.2-2
|
|
||||||
elixir:
|
|
||||||
- 1.13.4
|
|
||||||
exclude:
|
|
||||||
- runs-on: ubuntu-20.04
|
|
||||||
use-self-hosted: true
|
|
||||||
- runs-on: aws-amd64
|
|
||||||
use-self-hosted: false
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.runs-on }}
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: bash
|
shell: bash
|
||||||
|
@ -155,7 +145,7 @@ jobs:
|
||||||
- uses: AutoModality/action-clean@v1
|
- uses: AutoModality/action-clean@v1
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: source-${{ matrix.app[1] }}-${{ matrix.otp }}
|
name: source-${{ matrix.profile }}-${{ matrix.otp }}
|
||||||
path: .
|
path: .
|
||||||
- name: unzip source code
|
- name: unzip source code
|
||||||
run: unzip -q source.zip
|
run: unzip -q source.zip
|
||||||
|
@ -168,12 +158,8 @@ jobs:
|
||||||
PGSQL_TAG: 13
|
PGSQL_TAG: 13
|
||||||
REDIS_TAG: 6
|
REDIS_TAG: 6
|
||||||
INFLUXDB_TAG: 2.5.0
|
INFLUXDB_TAG: 2.5.0
|
||||||
WHICH_APP: ${{ matrix.app[0] }}
|
PROFILE: ${{ matrix.profile }}
|
||||||
PROFILE: ${{ matrix.app[1] }}
|
run: ./scripts/ct/run.sh --app ${{ matrix.app }}
|
||||||
run: |
|
|
||||||
echo $PROFILE
|
|
||||||
rm _build/default/lib/rocksdb/_build/cmake/CMakeCache.txt
|
|
||||||
./scripts/ct/run.sh --app $WHICH_APP
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: coverdata
|
name: coverdata
|
||||||
|
@ -181,34 +167,19 @@ jobs:
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: logs-${{ matrix.app[1] }}-${{ matrix.app[2] }}
|
name: logs-${{ matrix.profile }}-${{ matrix.prefix }}
|
||||||
path: source/_build/test/logs
|
path: source/_build/test/logs
|
||||||
|
|
||||||
ct:
|
ct:
|
||||||
needs: [prepare]
|
needs:
|
||||||
|
- build-matrix
|
||||||
|
- prepare
|
||||||
|
runs-on: ${{ needs.build-matrix.outputs.runs-on }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
app: ${{ fromJson(needs.prepare.outputs.fast_ct_apps) }}
|
include: ${{ fromJson(needs.build-matrix.outputs.host) }}
|
||||||
builder:
|
|
||||||
- 5.0-26
|
|
||||||
otp:
|
|
||||||
- 24.3.4.2-1
|
|
||||||
- 25.1.2-2
|
|
||||||
elixir:
|
|
||||||
- 1.13.4
|
|
||||||
runs-on:
|
|
||||||
- aws-amd64
|
|
||||||
- ubuntu-20.04
|
|
||||||
use-self-hosted:
|
|
||||||
- ${{ github.repository_owner == 'emqx' }}
|
|
||||||
exclude:
|
|
||||||
- runs-on: ubuntu-20.04
|
|
||||||
use-self-hosted: true
|
|
||||||
- runs-on: aws-amd64
|
|
||||||
use-self-hosted: false
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.runs-on }}
|
|
||||||
container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu20.04"
|
container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu20.04"
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
|
@ -218,7 +189,7 @@ jobs:
|
||||||
- uses: AutoModality/action-clean@v1
|
- uses: AutoModality/action-clean@v1
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: source-${{ matrix.app[1] }}-${{ matrix.otp }}
|
name: source-${{ matrix.profile }}-${{ matrix.otp }}
|
||||||
path: .
|
path: .
|
||||||
- name: unzip source code
|
- name: unzip source code
|
||||||
run: unzip -q source.zip
|
run: unzip -q source.zip
|
||||||
|
@ -227,10 +198,9 @@ jobs:
|
||||||
- name: run common test
|
- name: run common test
|
||||||
working-directory: source
|
working-directory: source
|
||||||
env:
|
env:
|
||||||
WHICH_APP: ${{ matrix.app[0] }}
|
PROFILE: ${{ matrix.profile }}
|
||||||
PROFILE: ${{ matrix.app[1] }}
|
|
||||||
run: |
|
run: |
|
||||||
make "${WHICH_APP}-ct"
|
make "${{ matrix.app }}-ct"
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: coverdata
|
name: coverdata
|
||||||
|
@ -239,7 +209,7 @@ jobs:
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: logs-${{ matrix.app[1] }}-${{ matrix.app[2] }}
|
name: logs-${{ matrix.profile }}-${{ matrix.prefix }}
|
||||||
path: source/_build/test/logs
|
path: source/_build/test/logs
|
||||||
|
|
||||||
make_cover:
|
make_cover:
|
||||||
|
|
|
@ -8,10 +8,10 @@ cd -P -- "$(dirname -- "$0")/.."
|
||||||
help() {
|
help() {
|
||||||
echo
|
echo
|
||||||
echo "-h|--help: To display this usage info"
|
echo "-h|--help: To display this usage info"
|
||||||
echo "--ci fast|docker: Print apps in json format for github ci mtrix"
|
echo "--ci: Print apps in json format for github ci matrix"
|
||||||
}
|
}
|
||||||
|
|
||||||
CI='novalue'
|
MODE='list'
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-h|--help)
|
-h|--help)
|
||||||
|
@ -19,8 +19,8 @@ while [ "$#" -gt 0 ]; do
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
--ci)
|
--ci)
|
||||||
CI="$2"
|
MODE='ci'
|
||||||
shift 2
|
shift 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "unknown option $1"
|
echo "unknown option $1"
|
||||||
|
@ -45,7 +45,7 @@ CE="$(find_app 'apps')"
|
||||||
EE="$(find_app 'lib-ee')"
|
EE="$(find_app 'lib-ee')"
|
||||||
APPS_ALL="$(echo -e "${CE}\n${EE}")"
|
APPS_ALL="$(echo -e "${CE}\n${EE}")"
|
||||||
|
|
||||||
if [ "$CI" = 'novalue' ]; then
|
if [ "$MODE" = 'list' ]; then
|
||||||
echo "${APPS_ALL}"
|
echo "${APPS_ALL}"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
@ -54,16 +54,22 @@ fi
|
||||||
###### now deal with the github action's matrix.
|
###### now deal with the github action's matrix.
|
||||||
##################################################
|
##################################################
|
||||||
|
|
||||||
dimensions() {
|
format_app_description() {
|
||||||
|
## prefix is for github actions (they don't like slash in variables)
|
||||||
|
local prefix=${1//\//_}
|
||||||
|
echo -n -e "$(
|
||||||
|
cat <<END
|
||||||
|
{"app": "${1}", "profile": "${2}", "runner": "${3}", "prefix": "${prefix}"}
|
||||||
|
END
|
||||||
|
)"
|
||||||
|
}
|
||||||
|
|
||||||
|
describe_app() {
|
||||||
app="$1"
|
app="$1"
|
||||||
|
local runner="host"
|
||||||
|
local profile
|
||||||
if [ -f "${app}/docker-ct" ]; then
|
if [ -f "${app}/docker-ct" ]; then
|
||||||
if [[ "$CI" != 'docker' ]]; then
|
runner="docker"
|
||||||
return
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [[ "$CI" != 'fast' ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
case "${app}" in
|
case "${app}" in
|
||||||
apps/*)
|
apps/*)
|
||||||
|
@ -77,28 +83,20 @@ dimensions() {
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
## poor-man's json formatter
|
format_app_description "$app" "$profile" "$runner"
|
||||||
## apps/<app name>, <profile>, apps_<app name>
|
|
||||||
## third one is for github actions (they don't like slash in variables)
|
|
||||||
echo -n -e "[\"$app\", \"$profile\", \"${app//\//_}\"]"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
matrix() {
|
matrix() {
|
||||||
first_row='yes'
|
local sep='['
|
||||||
for app in ${APPS_ALL}; do
|
for app in ${APPS_ALL}; do
|
||||||
row="$(dimensions "$app")"
|
row="$(describe_app "$app")"
|
||||||
if [ -z "$row" ]; then
|
if [ -z "$row" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if [ "$first_row" = 'yes' ]; then
|
echo -n "${sep}${row}"
|
||||||
first_row='no'
|
sep=', '
|
||||||
echo -n "$row"
|
|
||||||
else
|
|
||||||
echo -n ",${row}"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
echo ']'
|
||||||
}
|
}
|
||||||
|
|
||||||
echo -n '['
|
|
||||||
matrix
|
matrix
|
||||||
echo ']'
|
|
||||||
|
|
Loading…
Reference in New Issue