From 23917f7d8ffda11a85665e4a475013b1596e7da0 Mon Sep 17 00:00:00 2001 From: "Jonas L." Date: Sat, 14 Jun 2025 18:41:59 +0200 Subject: [PATCH] ci: fine grained test release (#3171) ### Description Allow fine grained configuration on which release the test should be run. This will be useful to start testing liquidsoap >=2.0.0 in our ci. --- .github/workflows/_python-lint.yml | 34 ++++++++++++ .github/workflows/_python-test.yml | 46 ++++++++++++++++ .github/workflows/_python.yml | 84 ------------------------------ .github/workflows/analyzer.yml | 26 +++++++-- .github/workflows/api-client.yml | 26 +++++++-- .github/workflows/api.yml | 9 ++-- .github/workflows/playout.yml | 26 +++++++-- .github/workflows/shared.yml | 26 +++++++-- .github/workflows/worker.yml | 26 +++++++-- 9 files changed, 194 insertions(+), 109 deletions(-) create mode 100644 .github/workflows/_python-lint.yml create mode 100644 .github/workflows/_python-test.yml delete mode 100644 .github/workflows/_python.yml diff --git a/.github/workflows/_python-lint.yml b/.github/workflows/_python-lint.yml new file mode 100644 index 000000000..921a2a4e4 --- /dev/null +++ b/.github/workflows/_python-lint.yml @@ -0,0 +1,34 @@ +on: + workflow_call: + inputs: + context: + required: true + type: string + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-lint + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ inputs.context }}-${{ hashFiles(format('{0}/{1}', inputs.context, '**/setup.py')) }} + restore-keys: | + ${{ runner.os }}-pip-${{ inputs.context }} + + - name: Add annotations matchers + run: | + echo "::add-matcher::.github/annotations/pylint.json" + + - name: Lint + run: make lint + working-directory: ${{ inputs.context }} diff --git a/.github/workflows/_python-test.yml b/.github/workflows/_python-test.yml new file mode 100644 index 000000000..c3c25ed84 --- /dev/null +++ b/.github/workflows/_python-test.yml @@ -0,0 +1,46 @@ +on: + workflow_call: + inputs: + context: + required: true + type: string + + release: + required: true + type: string + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-test-${{ inputs.release }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + + container: + image: ghcr.io/libretime/libretime-dev:${{ inputs.release }} + options: --user 1001:1001 + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@v4 + + - uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ inputs.release }}-pip-${{ inputs.context }}-${{ hashFiles(format('{0}/{1}', inputs.context, '**/setup.py')) }} + restore-keys: | + ${{ inputs.release }}-pip-${{ inputs.context }} + + - name: Test + run: make test-coverage + working-directory: ${{ inputs.context }} + + - name: Report coverage + uses: codecov/codecov-action@v5 + with: + files: ${{ inputs.context }}/coverage.xml + flags: ${{ inputs.context }} + name: ${{ inputs.context }} diff --git a/.github/workflows/_python.yml b/.github/workflows/_python.yml deleted file mode 100644 index c8f4aa5b4..000000000 --- a/.github/workflows/_python.yml +++ /dev/null @@ -1,84 +0,0 @@ -on: - workflow_call: - inputs: - context: - required: true - type: string - - lint: - required: false - default: true - type: boolean - - test: - required: false - default: true - type: boolean - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - lint: - if: inputs.lint - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ inputs.context }}-${{ hashFiles(format('{0}/{1}', inputs.context, '**/setup.py')) }} - restore-keys: | - ${{ runner.os }}-pip-${{ inputs.context }} - - - name: Add annotations matchers - run: | - echo "::add-matcher::.github/annotations/pylint.json" - - - name: Lint - run: make lint - working-directory: ${{ inputs.context }} - - test: - if: inputs.test - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - release: - - focal - - bullseye - - jammy - - container: - image: ghcr.io/libretime/libretime-dev:${{ matrix.release }} - options: --user 1001:1001 - defaults: - run: - shell: bash - - steps: - - uses: actions/checkout@v4 - - - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ matrix.release }}-pip-${{ inputs.context }}-${{ hashFiles(format('{0}/{1}', inputs.context, '**/setup.py')) }} - restore-keys: | - ${{ matrix.release }}-pip-${{ inputs.context }} - - - name: Test - run: make test-coverage - working-directory: ${{ inputs.context }} - - - name: Report coverage - uses: codecov/codecov-action@v5 - with: - files: ${{ inputs.context }}/coverage.xml - flags: ${{ inputs.context }} - name: ${{ inputs.context }} diff --git a/.github/workflows/analyzer.yml b/.github/workflows/analyzer.yml index dbc0d0352..9dd4e1376 100644 --- a/.github/workflows/analyzer.yml +++ b/.github/workflows/analyzer.yml @@ -5,7 +5,7 @@ on: push: branches: [main, stable-*] paths: - - .github/workflows/_python.yml + - .github/workflows/_python-*.yml - .github/workflows/analyzer.yml - analyzer/** - shared/** @@ -14,7 +14,7 @@ on: pull_request: branches: [main, stable-*] paths: - - .github/workflows/_python.yml + - .github/workflows/_python-*.yml - .github/workflows/analyzer.yml - analyzer/** - shared/** @@ -24,7 +24,25 @@ on: - cron: 0 1 * * 1 jobs: - python: - uses: ./.github/workflows/_python.yml + lint: + uses: ./.github/workflows/_python-lint.yml with: context: analyzer + + test-focal: + uses: ./.github/workflows/_python-test.yml + with: + context: analyzer + release: focal + + test-bullseye: + uses: ./.github/workflows/_python-test.yml + with: + context: analyzer + release: bullseye + + test-jammy: + uses: ./.github/workflows/_python-test.yml + with: + context: analyzer + release: jammy diff --git a/.github/workflows/api-client.yml b/.github/workflows/api-client.yml index 3ef0d9389..dd35c50b8 100644 --- a/.github/workflows/api-client.yml +++ b/.github/workflows/api-client.yml @@ -5,7 +5,7 @@ on: push: branches: [main, stable-*] paths: - - .github/workflows/_python.yml + - .github/workflows/_python-*.yml - .github/workflows/api-client.yml - api-client/** - shared/** @@ -14,7 +14,7 @@ on: pull_request: branches: [main, stable-*] paths: - - .github/workflows/_python.yml + - .github/workflows/_python-*.yml - .github/workflows/api-client.yml - api-client/** - shared/** @@ -24,7 +24,25 @@ on: - cron: 0 1 * * 1 jobs: - python: - uses: ./.github/workflows/_python.yml + lint: + uses: ./.github/workflows/_python-lint.yml with: context: api-client + + test-focal: + uses: ./.github/workflows/_python-test.yml + with: + context: api-client + release: focal + + test-bullseye: + uses: ./.github/workflows/_python-test.yml + with: + context: api-client + release: bullseye + + test-jammy: + uses: ./.github/workflows/_python-test.yml + with: + context: api-client + release: jammy diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 7381c3296..b8b3dc3d8 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -5,7 +5,7 @@ on: push: branches: [main, stable-*] paths: - - .github/workflows/_python.yml + - .github/workflows/_python-*.yml - .github/workflows/api.yml - api/** - shared/** @@ -14,7 +14,7 @@ on: pull_request: branches: [main, stable-*] paths: - - .github/workflows/_python.yml + - .github/workflows/_python-*.yml - .github/workflows/api.yml - api/** - shared/** @@ -24,11 +24,10 @@ on: - cron: 0 1 * * 1 jobs: - python: - uses: ./.github/workflows/_python.yml + lint: + uses: ./.github/workflows/_python-lint.yml with: context: api - test: false test-with-database: runs-on: ubuntu-latest diff --git a/.github/workflows/playout.yml b/.github/workflows/playout.yml index 98a76b810..6d9c21909 100644 --- a/.github/workflows/playout.yml +++ b/.github/workflows/playout.yml @@ -5,7 +5,7 @@ on: push: branches: [main, stable-*] paths: - - .github/workflows/_python.yml + - .github/workflows/_python-*.yml - .github/workflows/playout.yml - playout/** - api-client/** @@ -15,7 +15,7 @@ on: pull_request: branches: [main, stable-*] paths: - - .github/workflows/_python.yml + - .github/workflows/_python-*.yml - .github/workflows/playout.yml - playout/** - api-client/** @@ -26,7 +26,25 @@ on: - cron: 0 1 * * 1 jobs: - python: - uses: ./.github/workflows/_python.yml + lint: + uses: ./.github/workflows/_python-lint.yml with: context: playout + + test-focal: + uses: ./.github/workflows/_python-test.yml + with: + context: playout + release: focal + + test-bullseye: + uses: ./.github/workflows/_python-test.yml + with: + context: playout + release: bullseye + + test-jammy: + uses: ./.github/workflows/_python-test.yml + with: + context: playout + release: jammy diff --git a/.github/workflows/shared.yml b/.github/workflows/shared.yml index 407823269..0191d7a6d 100644 --- a/.github/workflows/shared.yml +++ b/.github/workflows/shared.yml @@ -5,7 +5,7 @@ on: push: branches: [main, stable-*] paths: - - .github/workflows/_python.yml + - .github/workflows/_python-*.yml - .github/workflows/shared.yml - shared/** - tools/python* @@ -13,7 +13,7 @@ on: pull_request: branches: [main, stable-*] paths: - - .github/workflows/_python.yml + - .github/workflows/_python-*.yml - .github/workflows/shared.yml - shared/** - tools/python* @@ -22,7 +22,25 @@ on: - cron: 0 1 * * 1 jobs: - python: - uses: ./.github/workflows/_python.yml + lint: + uses: ./.github/workflows/_python-lint.yml with: context: shared + + test-focal: + uses: ./.github/workflows/_python-test.yml + with: + context: shared + release: focal + + test-bullseye: + uses: ./.github/workflows/_python-test.yml + with: + context: shared + release: bullseye + + test-jammy: + uses: ./.github/workflows/_python-test.yml + with: + context: shared + release: jammy diff --git a/.github/workflows/worker.yml b/.github/workflows/worker.yml index 27f98a7d8..2f0d8aa73 100644 --- a/.github/workflows/worker.yml +++ b/.github/workflows/worker.yml @@ -5,7 +5,7 @@ on: push: branches: [main, stable-*] paths: - - .github/workflows/_python.yml + - .github/workflows/_python-*.yml - .github/workflows/worker.yml - worker/** - tools/python* @@ -13,7 +13,7 @@ on: pull_request: branches: [main, stable-*] paths: - - .github/workflows/_python.yml + - .github/workflows/_python-*.yml - .github/workflows/worker.yml - worker/** - tools/python* @@ -22,7 +22,25 @@ on: - cron: 0 1 * * 1 jobs: - python: - uses: ./.github/workflows/_python.yml + lint: + uses: ./.github/workflows/_python-lint.yml with: context: worker + + test-focal: + uses: ./.github/workflows/_python-test.yml + with: + context: worker + release: focal + + test-bullseye: + uses: ./.github/workflows/_python-test.yml + with: + context: worker + release: bullseye + + test-jammy: + uses: ./.github/workflows/_python-test.yml + with: + context: worker + release: jammy