From 0cfeec253ad2113da49a63cbe466c15a684dcec2 Mon Sep 17 00:00:00 2001 From: Liam Fraser Date: Wed, 25 Jan 2023 16:48:35 +0000 Subject: [PATCH] CI Improvements. Add multi-gcc workflow that tests each ARM GCC available (#1192) --- .github/workflows/cmake.yml | 2 +- .github/workflows/multi-gcc.yml | 154 ++++++++++++++++++ .../scripts/generate_multi_gcc_workflow.py | 71 ++++++++ 3 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/multi-gcc.yml create mode 100755 .github/workflows/scripts/generate_multi_gcc_workflow.py diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index a6521e7ca..ef357caae 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -36,7 +36,7 @@ jobs: # Note the current convention is to use the -S and -B options here to specify source # and build directories, but this is only available with CMake 3.13 and higher. # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPICO_SDK_TESTS_ENABLED=1 - name: Get core count id: core_count diff --git a/.github/workflows/multi-gcc.yml b/.github/workflows/multi-gcc.yml new file mode 100644 index 000000000..54d2880cf --- /dev/null +++ b/.github/workflows/multi-gcc.yml @@ -0,0 +1,154 @@ +name: Multi GCC +on: [workflow_dispatch, push, pull_request] + +jobs: + build: + if: github.repository_owner == 'raspberrypi' + runs-on: [self-hosted, Linux, X64] + + steps: + - name: Clean workspace + run: | + echo "Cleaning up previous run" + rm -rf "${{ github.workspace }}" + mkdir -p "${{ github.workspace }}" + + - name: Checkout repo + uses: actions/checkout@v2 + + - name: Checkout submodules + run: git submodule update --init + + - name: Get core count + id: core_count + run : cat /proc/cpuinfo | grep processor | wc -l + + - name: GCC 6.2.1 Debug + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-6_2-2016q4 -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 6.2.1 Release + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-6_2-2016q4 -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 6.3.1 Debug + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-6-2017-q2-update -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 6.3.1 Release + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-6-2017-q2-update -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 7.2.1 Debug + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-7-2017-q4-major -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 7.2.1 Release + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-7-2017-q4-major -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 7.3.1 Debug + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-7-2018-q2-update -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 7.3.1 Release + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-7-2018-q2-update -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 8.2.1 Debug + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-8-2018-q4-major -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 8.2.1 Release + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-8-2018-q4-major -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 8.3.1 Debug + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-8-2019-q3-update -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 8.3.1 Release + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-8-2019-q3-update -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 9.2.1 Debug + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-9-2019-q4-major -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 9.2.1 Release + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-9-2019-q4-major -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 9.3.1 Debug + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-9-2020-q2-update -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 9.3.1 Release + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-9-2020-q2-update -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 10.2.1 Debug + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-10-2020-q4-major -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 10.2.1 Release + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-10-2020-q4-major -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 10.3.1 Debug + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-10.3-2021.10 -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 10.3.1 Release + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-10.3-2021.10 -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 11.2.1 Debug + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 11.2.1 Release + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 11.3.1 Debug + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 11.3.1 Release + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 12.2.1 Debug + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} + + - name: GCC 12.2.1 Release + if: always() + shell: bash + run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi -DPICO_BOARD=pico_w; make -j ${{steps.core_count.outputs.output}} diff --git a/.github/workflows/scripts/generate_multi_gcc_workflow.py b/.github/workflows/scripts/generate_multi_gcc_workflow.py new file mode 100755 index 000000000..4e9d742a3 --- /dev/null +++ b/.github/workflows/scripts/generate_multi_gcc_workflow.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 + +import os +from collections import OrderedDict +import subprocess +import re + +toolchain_dir = "/opt/arm" +toolchains = os.listdir(toolchain_dir) + +gcc_versions = OrderedDict() + +for toolchain in toolchains: + fullpath = os.path.join(toolchain_dir, toolchain) + gcc_path = os.path.join(fullpath, "bin/arm-none-eabi-gcc") + version = subprocess.run([gcc_path, "--version"], capture_output=True) + stdout = version.stdout.decode('utf-8') + stderr = version.stderr.decode('utf-8') + assert(len(stderr) == 0) + # Version should be on first line + version_line = stdout.split("\n")[0] + m = re.search("(\d+\.\d+\.\d+)", version_line) + assert(m is not None) + version = m.group(1) + + if version in gcc_versions: + raise Exception("Already have version {} in versions current path {}, this path {}".format(version, gcc_versions[version], fullpath)) + + gcc_versions[version] = fullpath + +# Sort by major version +gcc_versions_sorted = OrderedDict(sorted(gcc_versions.items(), key=lambda item: int(item[0].replace(".", "")))) + + +# Create output +output = ''' +name: Multi GCC +on: [workflow_dispatch, push, pull_request] + +jobs: + build: + if: github.repository_owner == 'raspberrypi' + runs-on: [self-hosted, Linux, X64] + + steps: + - name: Clean workspace + run: | + echo "Cleaning up previous run" + rm -rf "${{ github.workspace }}" + mkdir -p "${{ github.workspace }}" + + - name: Checkout repo + uses: actions/checkout@v2 + + - name: Checkout submodules + run: git submodule update --init + + - name: Get core count + id: core_count + run : cat /proc/cpuinfo | grep processor | wc -l +''' + +for gcc_version, toolchain_path in gcc_versions_sorted.items(): + for build_type in ["Debug", "Release"]: + output += "\n" + output += " - name: GCC {} {}\n".format(gcc_version, build_type) + output += " if: always()\n" + output += " shell: bash\n" + output += " run: cd ${{{{github.workspace}}}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE={} -DPICO_TOOLCHAIN_PATH={} -DPICO_BOARD=pico_w; make -j ${{{{steps.core_count.outputs.output}}}}\n".format(build_type, toolchain_path) + +print(output)