ci: optimize runners usage

- always use github runners for lightweight jobs
- prefer self-hosted runners in private forks
- prefer self-hosted runners for workflows with large matrix
This commit is contained in:
Ivan Dyachkov 2023-11-02 14:00:04 +01:00
parent 8e7edaf745
commit 4495054714
20 changed files with 34 additions and 107 deletions

View File

@ -16,7 +16,7 @@ env:
jobs:
sanity-checks:
runs-on: ${{ fromJSON(github.repository_owner == 'emqx' && '["self-hosted","ephemeral","linux","x64"]' || '["ubuntu-22.04"]') }}
runs-on: ubuntu-22.04
container: "ghcr.io/emqx/emqx-builder/5.2-3:1.14.5-25.3.2-2-ubuntu22.04"
outputs:
ct-matrix: ${{ steps.matrix.outputs.ct-matrix }}
@ -24,8 +24,6 @@ jobs:
ct-docker: ${{ steps.matrix.outputs.ct-docker }}
version-emqx: ${{ steps.matrix.outputs.version-emqx }}
version-emqx-enterprise: ${{ steps.matrix.outputs.version-emqx-enterprise }}
runner_labels: ${{ github.repository_owner == 'emqx' && '["self-hosted","ephemeral","linux","x64"]' || '["ubuntu-22.04"]' }}
xl_runner_labels: ${{ github.repository_owner == 'emqx' && '["self-hosted","ephemeral-xl","linux","x64"]' || '["ubuntu-22.04"]' }}
builder: "ghcr.io/emqx/emqx-builder/5.2-3:1.14.5-25.3.2-2-ubuntu22.04"
builder_vsn: "5.2-3"
otp_vsn: "25.3.2-2"
@ -116,7 +114,7 @@ jobs:
echo "version-emqx-enterprise=$(./pkg-vsn.sh emqx-enterprise)" | tee -a $GITHUB_OUTPUT
compile:
runs-on: ${{ fromJSON(needs.sanity-checks.outputs.xl_runner_labels) }}
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral-xl","linux","x64"]') }}
container: ${{ needs.sanity-checks.outputs.builder }}
needs:
- sanity-checks
@ -154,7 +152,6 @@ jobs:
- compile
uses: ./.github/workflows/run_emqx_app_tests.yaml
with:
runner_labels: ${{ needs.sanity-checks.outputs.xl_runner_labels }}
builder: ${{ needs.sanity-checks.outputs.builder }}
before_ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
after_ref: ${{ github.sha }}
@ -165,7 +162,6 @@ jobs:
- compile
uses: ./.github/workflows/run_test_cases.yaml
with:
runner_labels: ${{ needs.sanity-checks.outputs.runner_labels }}
builder: ${{ needs.sanity-checks.outputs.builder }}
ct-matrix: ${{ needs.sanity-checks.outputs.ct-matrix }}
ct-host: ${{ needs.sanity-checks.outputs.ct-host }}
@ -177,7 +173,6 @@ jobs:
- compile
uses: ./.github/workflows/static_checks.yaml
with:
runner_labels: ${{ needs.sanity-checks.outputs.runner_labels }}
builder: ${{ needs.sanity-checks.outputs.builder }}
ct-matrix: ${{ needs.sanity-checks.outputs.ct-matrix }}
@ -186,7 +181,6 @@ jobs:
- sanity-checks
uses: ./.github/workflows/build_slim_packages.yaml
with:
runner_labels: ${{ needs.sanity-checks.outputs.runner_labels }}
builder: ${{ needs.sanity-checks.outputs.builder }}
builder_vsn: ${{ needs.sanity-checks.outputs.builder_vsn }}
otp_vsn: ${{ needs.sanity-checks.outputs.otp_vsn }}
@ -197,7 +191,6 @@ jobs:
- sanity-checks
uses: ./.github/workflows/build_docker_for_test.yaml
with:
runner_labels: ${{ needs.sanity-checks.outputs.runner_labels }}
otp_vsn: ${{ needs.sanity-checks.outputs.otp_vsn }}
elixir_vsn: ${{ needs.sanity-checks.outputs.elixir_vsn }}
version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
@ -208,8 +201,6 @@ jobs:
- sanity-checks
- build_slim_packages
uses: ./.github/workflows/spellcheck.yaml
with:
runner_labels: ${{ needs.sanity-checks.outputs.runner_labels }}
run_conf_tests:
needs:
@ -217,7 +208,6 @@ jobs:
- compile
uses: ./.github/workflows/run_conf_tests.yaml
with:
runner_labels: ${{ needs.sanity-checks.outputs.runner_labels }}
builder: ${{ needs.sanity-checks.outputs.builder }}
check_deps_integrity:
@ -225,7 +215,6 @@ jobs:
- sanity-checks
uses: ./.github/workflows/check_deps_integrity.yaml
with:
runner_labels: ${{ needs.sanity-checks.outputs.runner_labels }}
builder: ${{ needs.sanity-checks.outputs.builder }}
run_jmeter_tests:
@ -234,7 +223,6 @@ jobs:
- build_docker_for_test
uses: ./.github/workflows/run_jmeter_tests.yaml
with:
runner_labels: ${{ needs.sanity-checks.outputs.runner_labels }}
version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
run_docker_tests:
@ -243,7 +231,6 @@ jobs:
- build_docker_for_test
uses: ./.github/workflows/run_docker_tests.yaml
with:
runner_labels: ${{ needs.sanity-checks.outputs.runner_labels }}
version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
version-emqx-enterprise: ${{ needs.sanity-checks.outputs.version-emqx-enterprise }}
@ -253,6 +240,5 @@ jobs:
- build_docker_for_test
uses: ./.github/workflows/run_helm_tests.yaml
with:
runner_labels: ${{ needs.sanity-checks.outputs.runner_labels }}
version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
version-emqx-enterprise: ${{ needs.sanity-checks.outputs.version-emqx-enterprise }}

View File

@ -19,7 +19,7 @@ env:
jobs:
prepare:
runs-on: ${{ fromJSON(github.repository_owner == 'emqx' && '["self-hosted","ephemeral","linux","x64"]' || '["ubuntu-22.04"]') }}
runs-on: ubuntu-22.04
container: 'ghcr.io/emqx/emqx-builder/5.2-3:1.14.5-25.3.2-2-ubuntu22.04'
outputs:
profile: ${{ steps.parse-git-ref.outputs.profile }}
@ -29,7 +29,6 @@ jobs:
ct-matrix: ${{ steps.matrix.outputs.ct-matrix }}
ct-host: ${{ steps.matrix.outputs.ct-host }}
ct-docker: ${{ steps.matrix.outputs.ct-docker }}
runner_labels: ${{ github.repository_owner == 'emqx' && '["self-hosted","ephemeral","linux","x64"]' || '["ubuntu-22.04"]' }}
builder: 'ghcr.io/emqx/emqx-builder/5.2-3:1.14.5-25.3.2-2-ubuntu22.04'
builder_vsn: '5.2-3'
otp_vsn: '25.3.2-2'
@ -108,7 +107,6 @@ jobs:
otp_vsn: ${{ needs.prepare.outputs.otp_vsn }}
elixir_vsn: ${{ needs.prepare.outputs.elixir_vsn }}
builder_vsn: ${{ needs.prepare.outputs.builder_vsn }}
runner_labels: ${{ needs.prepare.outputs.runner_labels }}
secrets: inherit
build_slim_packages:
@ -117,7 +115,6 @@ jobs:
- prepare
uses: ./.github/workflows/build_slim_packages.yaml
with:
runner_labels: ${{ needs.prepare.outputs.runner_labels }}
builder: ${{ needs.prepare.outputs.builder }}
builder_vsn: ${{ needs.prepare.outputs.builder_vsn }}
otp_vsn: ${{ needs.prepare.outputs.otp_vsn }}
@ -125,7 +122,7 @@ jobs:
compile:
if: needs.prepare.outputs.release != 'true'
runs-on: ${{ fromJSON(needs.prepare.outputs.runner_labels) }}
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
container: ${{ needs.prepare.outputs.builder }}
needs:
- prepare
@ -162,7 +159,6 @@ jobs:
- compile
uses: ./.github/workflows/run_emqx_app_tests.yaml
with:
runner_labels: ${{ needs.prepare.outputs.runner_labels }}
builder: ${{ needs.prepare.outputs.builder }}
before_ref: ${{ github.event.before }}
after_ref: ${{ github.sha }}
@ -174,7 +170,6 @@ jobs:
- compile
uses: ./.github/workflows/run_test_cases.yaml
with:
runner_labels: ${{ needs.prepare.outputs.runner_labels }}
builder: ${{ needs.prepare.outputs.builder }}
ct-matrix: ${{ needs.prepare.outputs.ct-matrix }}
ct-host: ${{ needs.prepare.outputs.ct-host }}
@ -187,7 +182,6 @@ jobs:
- compile
uses: ./.github/workflows/run_conf_tests.yaml
with:
runner_labels: ${{ needs.prepare.outputs.runner_labels }}
builder: ${{ needs.prepare.outputs.builder }}
static_checks:
@ -197,6 +191,5 @@ jobs:
- compile
uses: ./.github/workflows/static_checks.yaml
with:
runner_labels: ${{ needs.prepare.outputs.runner_labels }}
builder: ${{ needs.prepare.outputs.builder }}
ct-matrix: ${{ needs.prepare.outputs.ct-matrix }}

View File

@ -28,9 +28,6 @@ on:
builder_vsn:
required: true
type: string
runner_labels:
required: true
type: string
secrets:
DOCKER_HUB_USER:
required: true
@ -70,14 +67,10 @@ on:
required: false
type: string
default: '5.2-3'
runner_labels:
required: false
type: string
default: '["self-hosted","ephemeral","linux","x64"]'
jobs:
docker:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
strategy:
fail-fast: false

View File

@ -7,9 +7,6 @@ concurrency:
on:
workflow_call:
inputs:
runner_labels:
required: true
type: string
otp_vsn:
required: true
type: string
@ -25,7 +22,7 @@ on:
jobs:
docker:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
env:
EMQX_NAME: ${{ matrix.profile }}
PKG_VSN: ${{ startsWith(matrix.profile, 'emqx-enterprise') && inputs.version-emqx-enterprise || inputs.version-emqx }}

View File

@ -153,7 +153,7 @@ jobs:
retention-days: 7
linux:
runs-on: ['self-hosted', 'ephemeral', 'linux', "${{ matrix.arch }}"]
runs-on: [self-hosted, ephemeral, linux, "${{ matrix.arch }}"]
# always run in builder container because the host might have the wrong OTP version etc.
# otherwise buildx.sh does not run docker if arch and os matches the target arch and os.
container:
@ -201,8 +201,6 @@ jobs:
shell: bash
steps:
- uses: AutoModality/action-clean@v1
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.ref }}

View File

@ -12,7 +12,7 @@ on:
jobs:
linux:
if: github.repository_owner == 'emqx'
runs-on: ['self-hosted', 'ephemeral', 'linux', "${{ matrix.arch }}"]
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
container:
image: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}"
@ -21,7 +21,6 @@ jobs:
matrix:
profile:
- ['emqx', 'master']
- ['emqx-enterprise', 'release-52']
- ['emqx-enterprise', 'release-53']
otp:
- 25.3.2-2
@ -101,7 +100,6 @@ jobs:
otp:
- 25.3.2-2
os:
- macos-13
- macos-12-arm64
steps:

View File

@ -7,9 +7,6 @@ concurrency:
on:
workflow_call:
inputs:
runner_labels:
required: true
type: string
builder:
required: true
type: string
@ -27,10 +24,6 @@ on:
inputs:
ref:
required: false
runner_labels:
required: false
type: string
default: '["self-hosted","ephemeral", "linux", "x64"]'
builder:
required: false
type: string
@ -50,7 +43,7 @@ on:
jobs:
linux:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
env:
EMQX_NAME: ${{ matrix.profile[0] }}

View File

@ -3,16 +3,13 @@ name: Check integrity of rebar and mix dependencies
on:
workflow_call:
inputs:
runner_labels:
required: true
type: string
builder:
required: true
type: string
jobs:
check_deps_integrity:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
container: ${{ inputs.builder }}
steps:
- uses: actions/checkout@v3

View File

@ -11,7 +11,7 @@ on:
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
timeout-minutes: 360
permissions:
actions: read

View File

@ -11,7 +11,7 @@ on:
jobs:
rerun-failed-jobs:
if: github.repository_owner == 'emqx'
runs-on: ['self-hosted', 'linux', 'x64', 'ephemeral']
runs-on: ubuntu-22.04
permissions:
checks: read
actions: write

View File

@ -7,16 +7,13 @@ concurrency:
on:
workflow_call:
inputs:
runner_labels:
required: true
type: string
builder:
required: true
type: string
jobs:
run_conf_tests:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
container: ${{ inputs.builder }}
env:
PROFILE: ${{ matrix.profile }}

View File

@ -7,9 +7,6 @@ concurrency:
on:
workflow_call:
inputs:
runner_labels:
required: true
type: string
version-emqx:
required: true
type: string
@ -19,7 +16,7 @@ on:
jobs:
basic-tests:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
defaults:
run:
shell: bash
@ -63,7 +60,7 @@ jobs:
docker compose rm -fs
paho-mqtt-testing:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
defaults:
run:
shell: bash

View File

@ -10,9 +10,6 @@ concurrency:
on:
workflow_call:
inputs:
runner_labels:
required: true
type: string
builder:
required: true
type: string
@ -28,7 +25,7 @@ env:
jobs:
run_emqx_app_tests:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
container: ${{ inputs.builder }}
defaults:

View File

@ -7,9 +7,6 @@ concurrency:
on:
workflow_call:
inputs:
runner_labels:
required: true
type: string
version-emqx:
required: true
type: string
@ -19,7 +16,7 @@ on:
jobs:
helm_test:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
defaults:
run:
shell: bash

View File

@ -3,16 +3,13 @@ name: JMeter integration tests
on:
workflow_call:
inputs:
runner_labels:
required: true
type: string
version-emqx:
required: true
type: string
jobs:
jmeter_artifact:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
steps:
- name: Cache Jmeter
id: cache-jmeter
@ -42,7 +39,7 @@ jobs:
retention-days: 3
advanced_feat:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
strategy:
fail-fast: false
@ -94,7 +91,7 @@ jobs:
retention-days: 3
pgsql_authn_authz:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
strategy:
fail-fast: false
@ -161,7 +158,7 @@ jobs:
retention-days: 3
mysql_authn_authz:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
strategy:
fail-fast: false
@ -221,7 +218,7 @@ jobs:
retention-days: 3
JWT_authn:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
strategy:
fail-fast: false
@ -273,7 +270,7 @@ jobs:
retention-days: 3
built_in_database_authn_authz:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
strategy:
fail-fast: false

View File

@ -7,16 +7,13 @@ concurrency:
on:
workflow_call:
inputs:
runner:
required: true
type: string
builder:
required: true
type: string
jobs:
relup_test_plan:
runs-on: ["${{ inputs.runner }}", 'linux', 'x64', 'ephemeral']
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
container: ${{ inputs.builder }}
outputs:
CUR_EE_VSN: ${{ steps.find-versions.outputs.CUR_EE_VSN }}
@ -60,7 +57,7 @@ jobs:
needs:
- relup_test_plan
if: needs.relup_test_plan.outputs.OLD_VERSIONS != '[]'
runs-on: ["${{ inputs.runner }}", 'linux', 'x64', 'ephemeral']
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
strategy:
fail-fast: false
matrix:

View File

@ -7,9 +7,6 @@ concurrency:
on:
workflow_call:
inputs:
runner_labels:
required: true
type: string
builder:
required: true
type: string
@ -28,7 +25,7 @@ env:
jobs:
eunit_and_proper:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
name: "eunit_and_proper (${{ matrix.profile }})"
strategy:
fail-fast: false
@ -71,7 +68,7 @@ jobs:
retention-days: 7
ct_docker:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
name: "${{ matrix.app }}-${{ matrix.suitegroup }} (${{ matrix.profile }})"
strategy:
fail-fast: false
@ -124,7 +121,7 @@ jobs:
retention-days: 7
ct:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
name: "${{ matrix.app }}-${{ matrix.suitegroup }} (${{ matrix.profile }})"
strategy:
fail-fast: false
@ -175,7 +172,7 @@ jobs:
- eunit_and_proper
- ct
- ct_docker
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
steps:
@ -186,7 +183,7 @@ jobs:
- eunit_and_proper
- ct
- ct_docker
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
container: ${{ inputs.builder }}
strategy:
fail-fast: false
@ -226,7 +223,7 @@ jobs:
# do this in a separate job
upload_coverdata:
needs: make_cover
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ubuntu-22.04
steps:
- name: Coveralls Finished
env:

View File

@ -6,10 +6,6 @@ concurrency:
on:
workflow_call:
inputs:
runner_labels:
required: true
type: string
jobs:
spellcheck:
@ -18,7 +14,7 @@ jobs:
profile:
- emqx
- emqx-enterprise
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
steps:
- uses: actions/download-artifact@v3
with:

View File

@ -11,7 +11,7 @@ on:
jobs:
stale:
if: github.repository_owner == 'emqx'
runs-on: ['self-hosted', 'linux', 'x64', 'ephemeral']
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
permissions:
issues: write
pull-requests: none

View File

@ -7,9 +7,6 @@ concurrency:
on:
workflow_call:
inputs:
runner_labels:
required: true
type: string
builder:
required: true
type: string
@ -22,7 +19,7 @@ env:
jobs:
static_checks:
runs-on: ${{ fromJSON(inputs.runner_labels) }}
runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
name: "static_checks (${{ matrix.profile }})"
strategy:
fail-fast: false