From 2dc5a4e943298944ba403fc9beefcc96847cc2eb Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 16 Jun 2022 01:38:43 +0200 Subject: [PATCH] ci: generate all matrices in a single step/job Signed-off-by: Unai Martinez-Corral --- ...job_matrix.py => generate_job_matrices.py} | 10 +++--- .github/workflows/Automerge.yml | 33 +++++++++++++++---- .github/workflows/sphinx-tuttest.yml | 24 ++------------ 3 files changed, 33 insertions(+), 34 deletions(-) rename .github/scripts/{generate_job_matrix.py => generate_job_matrices.py} (93%) diff --git a/.github/scripts/generate_job_matrix.py b/.github/scripts/generate_job_matrices.py similarity index 93% rename from .github/scripts/generate_job_matrix.py rename to .github/scripts/generate_job_matrices.py index 0763db4..5af44c5 100755 --- a/.github/scripts/generate_job_matrix.py +++ b/.github/scripts/generate_job_matrices.py @@ -117,9 +117,7 @@ def get_jobs( return jobs -distribution = environ['F4PGA_EXAMPLES_DISTRIBUTION'] -jobs = get_jobs(distribution, False) + get_jobs(distribution, True) - -print(f'::set-output name=matrix::{jobs!s}') - -print(str(jobs)) +for distribution in ['debian', 'ubuntu', 'fedora', 'centos']: + jobs = get_jobs(distribution, False) + get_jobs(distribution, True) + print(f'::set-output name={distribution}::{jobs!s}') + print(f"{distribution}: {jobs!s}") diff --git a/.github/workflows/Automerge.yml b/.github/workflows/Automerge.yml index 39fd680..ad2e596 100644 --- a/.github/workflows/Automerge.yml +++ b/.github/workflows/Automerge.yml @@ -14,23 +14,43 @@ on: jobs: - Debian: + Matrices: if: ${{ !(github.event_name != 'pull_request' && github.actor == 'dependabot[bot]') }} + runs-on: ubuntu-latest + outputs: + debian: ${{ steps.generate.outputs.debian }} + ubuntu: ${{ steps.generate.outputs.ubuntu }} + fedora: ${{ steps.generate.outputs.fedora }} + centos: ${{ steps.generate.outputs.centos }} + steps: + - uses: actions/checkout@v3 + - id: generate + run: ./.github/scripts/generate_job_matrices.py '${{ github.repository }}' + + + Debian: + needs: Matrices uses: ./.github/workflows/sphinx-tuttest.yml with: - distribution: debian + matrix: ${{ needs.Matrices.outputs.debian }} Ubuntu: - if: ${{ !(github.event_name != 'pull_request' && github.actor == 'dependabot[bot]') }} + needs: Matrices uses: ./.github/workflows/sphinx-tuttest.yml with: - distribution: ubuntu + matrix: ${{ needs.Matrices.outputs.ubuntu }} Fedora: - if: ${{ !(github.event_name != 'pull_request' && github.actor == 'dependabot[bot]') }} + needs: Matrices uses: ./.github/workflows/sphinx-tuttest.yml with: - distribution: fedora + matrix: ${{ needs.Matrices.outputs.fedora }} + + Centos: + needs: Matrices + uses: ./.github/workflows/sphinx-tuttest.yml + with: + matrix: ${{ needs.Matrices.outputs.centos }} Automerge: @@ -38,6 +58,7 @@ jobs: - Debian - Ubuntu - Fedora + - Centos if: github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' runs-on: ubuntu-latest name: Automerge dependabot PRs diff --git a/.github/workflows/sphinx-tuttest.yml b/.github/workflows/sphinx-tuttest.yml index fe42a19..0bb28bd 100644 --- a/.github/workflows/sphinx-tuttest.yml +++ b/.github/workflows/sphinx-tuttest.yml @@ -3,7 +3,7 @@ name: doc-test on: workflow_call: inputs: - distribution: + matrix: description: 'Distribution to execute tests on' required: true type: string @@ -11,31 +11,11 @@ on: jobs: - Matrix: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.generate.outputs.matrix }} - surelog-matrix: ${{ steps.generate-surelog.outputs.matrix }} - - steps: - - - name: Setup repository - uses: actions/checkout@v3 - - - name: Generate examples matrix - id: generate - run: >- - F4PGA_EXAMPLES_DISTRIBUTION='${{ inputs.distribution }}' - ./.github/scripts/generate_job_matrix.py - '${{ github.repository }}' - - Test: - needs: Matrix strategy: fail-fast: false matrix: - include: ${{ fromJson(needs.Matrix.outputs.matrix) }} + include: ${{ fromJson(inputs.matrix) }} runs-on: ${{ matrix.runs-on }} name: ${{ matrix.os-version }} | ${{ matrix.name }} | ${{ matrix.fpga-fam }} | ${{ matrix.example }}