From 7edd4035569affe78beec1698326bda3a2b94bac Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 16 Jun 2022 00:54:46 +0200 Subject: [PATCH 1/4] ci/sphinx-tuttest: s/SymbiFlow/F4PGA/ Signed-off-by: Unai Martinez-Corral --- .github/workflows/sphinx-tuttest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sphinx-tuttest.yml b/.github/workflows/sphinx-tuttest.yml index ecf319b..612066d 100644 --- a/.github/workflows/sphinx-tuttest.yml +++ b/.github/workflows/sphinx-tuttest.yml @@ -63,7 +63,7 @@ jobs: wget https://github.com/antmicro/tuttest/releases/download/v0.2-beta/tuttest -O /usr/bin/tuttest chmod a+rx /usr/bin/tuttest - - name: Install SymbiFlow toolchain + - name: Install F4PGA toolchain run: bash .github/scripts/install-toolchain.sh ${{matrix.fpga-fam}} ${{matrix.os}} - name: Build examples From 7d47070d992c132a480811efffbf7539d63c9990 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 16 Jun 2022 01:01:05 +0200 Subject: [PATCH 2/4] ci/sphinx-tuttest: reduce duplication Signed-off-by: Unai Martinez-Corral --- .github/scripts/generate_job_matrix.py | 142 ++++++++++++++----------- .github/workflows/Automerge.yml | 21 +++- .github/workflows/sphinx-tuttest.yml | 76 +++---------- 3 files changed, 114 insertions(+), 125 deletions(-) diff --git a/.github/scripts/generate_job_matrix.py b/.github/scripts/generate_job_matrix.py index 7e496a0..0763db4 100755 --- a/.github/scripts/generate_job_matrix.py +++ b/.github/scripts/generate_job_matrix.py @@ -16,10 +16,10 @@ # # SPDX-License-Identifier: Apache-2.0 +from os import environ from sys import argv as sys_argv isFork = len(sys_argv)>1 and sys_argv[1] != 'chipsalliance/f4pga-examples' -usesSurelog = len(sys_argv)>2 and sys_argv[2] == 'Surelog' runs_on = ( 'ubuntu-latest' @@ -27,76 +27,98 @@ runs_on = ( ['self-hosted', 'Linux', 'X64'] ) -examples = [ - "pulse_width_led", - "hello-a", - "hello-b", - "hello-c", - "hello-d", - "hello-e", - "hello-f", - "hello-g", - "hello-h", - "hello-i", - "hello-j", -] -# Skip tests that are currently unsupported -if not usesSurelog: +def get_jobs( + distribution: str = 'debian', + usesSurelog: bool = False +): examples = [ - "litex", - "picosoc", - "litex_linux", - "button_controller", - "timer", - "hello-k", - "hello-l" - ] + examples - -jobs = [] - -osvers = [ - ("ubuntu", "focal"), - ("debian", "buster"), - ("debian", "bullseye"), - ("debian", "sid"), - ("fedora", "35"), - ("fedora", "36"), -] - -if not isFork: - examples = [ - "counter", - ] + examples + "pulse_width_led", + "hello-a", + "hello-b", + "hello-c", + "hello-d", + "hello-e", + "hello-f", + "hello-g", + "hello-h", + "hello-i", + "hello-j", + ] # Skip tests that are currently unsupported if not usesSurelog: - examples = [ - "litex_sata", - ] + examples + examples.extend([ + "litex", + "picosoc", + "litex_linux", + "button_controller", + "timer", + "hello-k", + "hello-l" + ]) - osvers += [ - ("ubuntu", "xenial"), - ("ubuntu", "bionic"), - ("centos", "7"), - ] + jobs = [] + osvers = [] -for osver in osvers: - jobs += [{ + if distribution == "debian": + osvers.extend([ + ("debian", "buster"), + ("debian", "bullseye"), + ("debian", "sid") + ]) + elif distribution == "ubuntu": + osvers.extend([ + ("ubuntu", "focal") + ]) + elif distribution == "fedora": + osvers.extend([ + ("fedora", "35"), + ("fedora", "36") + ]) + + if not isFork: + examples.extend(["counter"]) + + # Skip tests that are currently unsupported + if not usesSurelog: + examples.extend(["litex_sata"]) + + if distribution == "ubuntu": + osvers.extend([ + ("ubuntu", "xenial"), + ("ubuntu", "bionic"), + ]) + elif distribution == "centos": + osvers.extend([ + ("centos", "7") + ]) + + for osver in osvers: + jobs.extend([{ + 'name': "Surelog" if usesSurelog else "Default", + 'runs-on': runs_on, + 'fpga-fam': "xc7", + 'os': osver[0], + 'os-version': osver[1], + 'example': example, + 'surelog': "-parse -DSYNTHESIS" if usesSurelog else "" + } for example in examples]) + + jobs.extend([{ + 'name': "Surelog" if usesSurelog else "Default", 'runs-on': runs_on, - 'fpga-fam': "xc7", + 'fpga-fam': "eos-s3", 'os': osver[0], 'os-version': osver[1], - 'example': example - } for example in examples] + 'example': "counter", + 'surelog': "-parse -DSYNTHESIS" if usesSurelog else "" + } for osver in osvers]) -jobs += [{ - 'runs-on': runs_on, - 'fpga-fam': "eos-s3", - 'os': osver[0], - 'os-version': osver[1], - 'example': "counter" -} for osver in osvers] + return jobs + +distribution = environ['F4PGA_EXAMPLES_DISTRIBUTION'] +jobs = get_jobs(distribution, False) + get_jobs(distribution, True) print(f'::set-output name=matrix::{jobs!s}') diff --git a/.github/workflows/Automerge.yml b/.github/workflows/Automerge.yml index 7e0bb99..39fd680 100644 --- a/.github/workflows/Automerge.yml +++ b/.github/workflows/Automerge.yml @@ -14,13 +14,30 @@ on: jobs: - Pipeline: + Debian: if: ${{ !(github.event_name != 'pull_request' && github.actor == 'dependabot[bot]') }} uses: ./.github/workflows/sphinx-tuttest.yml + with: + distribution: debian + + Ubuntu: + if: ${{ !(github.event_name != 'pull_request' && github.actor == 'dependabot[bot]') }} + uses: ./.github/workflows/sphinx-tuttest.yml + with: + distribution: ubuntu + + Fedora: + if: ${{ !(github.event_name != 'pull_request' && github.actor == 'dependabot[bot]') }} + uses: ./.github/workflows/sphinx-tuttest.yml + with: + distribution: fedora Automerge: - needs: Pipeline + needs: + - Debian + - Ubuntu + - Fedora 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 612066d..fe42a19 100644 --- a/.github/workflows/sphinx-tuttest.yml +++ b/.github/workflows/sphinx-tuttest.yml @@ -2,6 +2,11 @@ name: doc-test on: workflow_call: + inputs: + distribution: + description: 'Distribution to execute tests on' + required: true + type: string jobs: @@ -19,11 +24,10 @@ jobs: - name: Generate examples matrix id: generate - run: ./.github/scripts/generate_job_matrix.py '${{ github.repository }}' - - - name: Generate examples matrix - id: generate-surelog - run: ./.github/scripts/generate_job_matrix.py '${{ github.repository }}' Surelog + run: >- + F4PGA_EXAMPLES_DISTRIBUTION='${{ inputs.distribution }}' + ./.github/scripts/generate_job_matrix.py + '${{ github.repository }}' Test: @@ -33,13 +37,13 @@ jobs: matrix: include: ${{ fromJson(needs.Matrix.outputs.matrix) }} runs-on: ${{ matrix.runs-on }} - name: ${{ matrix.fpga-fam }} | ${{ matrix.os }} ${{ matrix.os-version }} | ${{ matrix.example }} + name: ${{ matrix.os-version }} | ${{ matrix.name }} | ${{ matrix.fpga-fam }} | ${{ matrix.example }} env: LANG: "en_US.UTF-8" DEBIAN_FRONTEND: "noninteractive" GHA_PREEMPTIBLE: "false" - SURELOG_CMD: "" + SURELOG_CMD: ${{ matrix.surelog }} container: ${{matrix.os}}:${{matrix.os-version}} @@ -71,64 +75,10 @@ jobs: - uses: actions/upload-artifact@v3 with: - name: f4pga-examples-bitstreams + name: f4pga-examples-bitstreams-${{ matrix.name }} path: '**/*.bit' - uses: actions/upload-artifact@v3 with: - name: f4pga-examples-plots - path: '**/plot_*.svg' - - - Test-Surelog: - needs: Matrix - strategy: - fail-fast: false - matrix: - include: ${{ fromJson(needs.Matrix.outputs.surelog-matrix) }} - runs-on: ${{ matrix.runs-on }} - name: Surelog frontend - ${{ matrix.fpga-fam }} | ${{ matrix.os }} ${{ matrix.os-version }} | ${{ matrix.example }} - - env: - LANG: "en_US.UTF-8" - DEBIAN_FRONTEND: "noninteractive" - GHA_PREEMPTIBLE: "false" - SURELOG_CMD: "-parse -DSYNTHESIS" - - container: ${{matrix.os}}:${{matrix.os-version}} - - steps: - - - name: Setup repository - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Install utils - run: | - case ${{ matrix.os }} in - ubuntu|debian) apt -qqy update && apt -qqy install git wget locales && locale-gen $LANG ;; - centos) yum -y install git wget ;; - fedora) dnf install -y git wget ;; - esac - - - name: Install tuttest - run: | - wget https://github.com/antmicro/tuttest/releases/download/v0.2-beta/tuttest -O /usr/bin/tuttest - chmod a+rx /usr/bin/tuttest - - - name: Install F4PGA toolchain - run: bash .github/scripts/install-toolchain.sh ${{matrix.fpga-fam}} ${{matrix.os}} - - - name: Build examples - run: bash .github/scripts/build-examples.sh ${{matrix.fpga-fam}} ${{matrix.example}} - - - uses: actions/upload-artifact@v3 - with: - name: f4pga-examples-bitstreams-systemverilog-plugin - path: '**/*.bit' - - - uses: actions/upload-artifact@v3 - with: - name: f4pga-examples-plots-systemverilog-plugin + name: f4pga-examples-plots-${{ matrix.name }} path: '**/plot_*.svg' From 2dc5a4e943298944ba403fc9beefcc96847cc2eb Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 16 Jun 2022 01:38:43 +0200 Subject: [PATCH 3/4] 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 }} From 6bd7ab9f7868c33977283fb8c95accac9764b37d Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 16 Jun 2022 02:16:38 +0200 Subject: [PATCH 4/4] ci/scripts/build-examples: remove duplicated cases Signed-off-by: Unai Martinez-Corral --- .github/scripts/build-examples.sh | 33 ------------------------------- 1 file changed, 33 deletions(-) diff --git a/.github/scripts/build-examples.sh b/.github/scripts/build-examples.sh index 41cc3c0..98eee1e 100755 --- a/.github/scripts/build-examples.sh +++ b/.github/scripts/build-examples.sh @@ -124,39 +124,6 @@ if [ "$fpga_family" = "xc7" ]; then "hello-k") snippets="${activate_env} projf-makefiles/hello/hello-arty/K/README.rst:hello-arty-k" ;; - "hello-l") - snippets="${activate_env} projf-makefiles/hello/hello-arty/L/README.rst:hello-arty-l" - ;; - "hello-b") - snippets="${activate_env} projf-makefiles/hello/hello-arty/B/README.rst:hello-arty-b" - ;; - "hello-c") - snippets="${activate_env} projf-makefiles/hello/hello-arty/C/README.rst:hello-arty-c" - ;; - "hello-d") - snippets="${activate_env} projf-makefiles/hello/hello-arty/D/README.rst:hello-arty-d" - ;; - "hello-e") - snippets="${activate_env} projf-makefiles/hello/hello-arty/E/README.rst:hello-arty-e" - ;; - "hello-f") - snippets="${activate_env} projf-makefiles/hello/hello-arty/F/README.rst:hello-arty-f" - ;; - "hello-g") - snippets="${activate_env} projf-makefiles/hello/hello-arty/G/README.rst:hello-arty-g" - ;; - "hello-h") - snippets="${activate_env} projf-makefiles/hello/hello-arty/H/README.rst:hello-arty-h" - ;; - "hello-i") - snippets="${activate_env} projf-makefiles/hello/hello-arty/I/README.rst:hello-arty-i" - ;; - "hello-j") - snippets="${activate_env} projf-makefiles/hello/hello-arty/J/README.rst:hello-arty-j" - ;; - "hello-k") - snippets="${activate_env} projf-makefiles/hello/hello-arty/K/README.rst:hello-arty-k" - ;; "hello-l") snippets="${activate_env} projf-makefiles/hello/hello-arty/L/README.rst:hello-arty-l" ;;