diff --git a/.github/workflows/build-test-run-reusable-workflow.yaml b/.github/workflows/build-test-run-reusable-workflow.yaml new file mode 100644 index 00000000..8ca9039d --- /dev/null +++ b/.github/workflows/build-test-run-reusable-workflow.yaml @@ -0,0 +1,112 @@ +on: + workflow_call: + inputs: + runner: + description: 'The runner to use for the job. Must be a runner-name available from GitHub actions.' + required: true + type: string + host-platform: + description: 'The host platform to use for the job. Must be the same type as the runnner. Options: [ubuntu | windows]' + required: true + type: string + target-platform: + description: 'The target platform to use for the job. Options: [host | zynq]' + required: true + type: string + +jobs: + build: + runs-on: ${{ inputs.runner }} + name : Build (Target ${{ inputs.target-platform }} - Host ${{ inputs.host-platform }}) + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: jwlawson/actions-setup-cmake@v1.14 + with: + cmake-version: "3.30.x" + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - run: | + python -u Scripts/BuildAndInstallExternalLibs.py --TargetPlatform ${{ inputs.target-platform }} + python -u Scripts/BuildAndInstallCoDeLib.py --TargetPlatform ${{ inputs.target-platform }} + python -u Scripts/BuildBenchmark.py --TargetPlatform ${{ inputs.target-platform }} + - name: 'Upload CoDeLib build artifacts' + uses: actions/upload-artifact@v4 + with: + name: CoDeLibBuildArtifacts-target-${{ inputs.target-platform }}-host-${{ inputs.host-platform }} + path: CoDeLib/Build + retention-days: 1 + - name: 'Upload benchmark build artifacts' + uses: actions/upload-artifact@v4 + with: + name: BenchmarkBuildArtifacts-target-${{ inputs.target-platform }}-host-${{ inputs.host-platform }} + path: Benchmark/Build + retention-days: 1 + + test: + if: ${{ inputs.target-platform == 'host' }} + runs-on: ${{ inputs.runner }} + name : Test (Target ${{ inputs.target-platform }} - Host ${{ inputs.host-platform }}) + needs: build + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - uses: actions/download-artifact@v4 + with: + name: CoDeLibBuildArtifacts-target-${{ inputs.target-platform }}-host-${{ inputs.host-platform }} + path: CoDeLib/Build + - run: | + python -u Scripts/RunTest.py + - name: 'Upload test results' + uses: actions/upload-artifact@v4 + with: + name: TestResults-target-${{ inputs.target-platform }}-host-${{ inputs.host-platform }}.txt + path: TestResults.txt + retention-days: 1 + + benchmark: + if: ${{ inputs.target-platform == 'host' }} + runs-on: ${{ inputs.runner }} + name : Benchmark (Target ${{ inputs.target-platform }} - Host ${{ inputs.host-platform }}) + needs: build + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - uses: actions/download-artifact@v4 + with: + name: BenchmarkBuildArtifacts-target-${{ inputs.target-platform }}-host-${{ inputs.host-platform }} + path: Benchmark/Build + - run: | + python -u Scripts/RunBenchmark.py + - name: 'Upload benchmark results' + uses: actions/upload-artifact@v4 + with: + name: BenchmarkResults-target-${{ inputs.target-platform }}-host-${{ inputs.host-platform }} + path: BenchmarkResults.txt + retention-days: 1 + + comment_benchmark_results: + if: ${{ github.branch != 'main' }} + runs-on: ${{ inputs.runner }} + name: Comment Benchmark Results (Target ${{ inputs.target-platform }} - Host ${{ inputs.host-platform }}) + needs: benchmark + timeout-minutes: 15 + permissions: + pull-requests: write + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + name: BenchmarkResults-target-${{ inputs.target-platform }}-host-${{ inputs.host-platform }} + - uses: thollander/actions-comment-pull-request@v2 + with: + filePath: BenchmarkResults.txt diff --git a/.github/workflows/pull-request-benchmark-workflow.yaml b/.github/workflows/pull-request-benchmark-workflow.yaml index eb099725..632bd542 100644 --- a/.github/workflows/pull-request-benchmark-workflow.yaml +++ b/.github/workflows/pull-request-benchmark-workflow.yaml @@ -11,96 +11,76 @@ on: - "**.hpp" jobs: - build_benchmark_test_ubuntu: + +#======================================== +# Checks +#======================================== + + check_formatting: runs-on: ubuntu-22.04 + name: Check Formatting timeout-minutes: 15 - permissions: - pull-requests: write steps: - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: jwlawson/actions-setup-cmake@v1.14 - with: - cmake-version: "3.30.x" - uses: actions/setup-python@v5 with: python-version: '3.11' - run: | python -u Scripts/CheckFormattingAll_c_h_cpp_hpp.py - python -u Scripts/BuildAndInstallExternalLibs.py - python -u Scripts/BuildAndInstallCoDeLib.py - python -u Scripts/RunTest.py - python -u Scripts/BuildBenchmark.py - python -u Scripts/RunBenchmark.py - - uses: thollander/actions-comment-pull-request@v2 - with: - filePath: BenchmarkResults.txt - build_benchmark_test_windows: - runs-on: windows-2022 - timeout-minutes: 15 +#======================================== +# Target Ubuntu - Host Ubuntu +#======================================== + + target_ubuntu_host_ubuntu: + needs: check_formatting permissions: pull-requests: write - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: jwlawson/actions-setup-cmake@v1.14 - with: - cmake-version: "3.30.x" - - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - run: | - python -u Scripts/CheckFormattingAll_c_h_cpp_hpp.py - python -u Scripts/BuildAndInstallExternalLibs.py - python -u Scripts/BuildAndInstallCoDeLib.py - python -u Scripts/RunTest.py - python -u Scripts/BuildBenchmark.py - python -u Scripts/RunBenchmark.py - - uses: thollander/actions-comment-pull-request@v2 - with: - filePath: BenchmarkResults.txt + uses: ./.github/workflows/build-test-run-reusable-workflow.yaml + with: + runner: 'ubuntu-22.04' + host-platform: 'ubuntu' + target-platform: 'host' + +#======================================== +# Target Windows - Host Windows +#======================================== + + target_windows_host_windows: + needs: check_formatting + permissions: + pull-requests: write + uses: ./.github/workflows/build-test-run-reusable-workflow.yaml + with: + runner: 'windows-2022' + host-platform: 'windows' + target-platform: 'host' - # build_linux_for_zynq_on_ubuntu: - # runs-on: ubuntu-22.04 - # timeout-minutes: 15 +#======================================== +# Target Zynq - Host Ubuntu +#======================================== + + # build_target_zynq_host_ubuntu: + # needs: check_formatting # permissions: # pull-requests: write - # steps: - # - uses: actions/checkout@v4 - # with: - # submodules: recursive - # - uses: jwlawson/actions-setup-cmake@v1.14 - # with: - # cmake-version: "3.30.x" - # - uses: actions/setup-python@v5 - # with: - # python-version: '3.11' - # - run: | - # python -u Scripts/CheckFormattingAll_c_h_cpp_hpp.py - # python -u Scripts/BuildAndInstallExternalLibs.py --TargetPlatform zynq - # python -u Scripts/BuildAndInstallCoDeLib.py --TargetPlatform zynq - # python -u Scripts/BuildBenchmark.py --TargetPlatform zynq + # uses: ./.github/workflows/build-test-run-reusable-workflow.yaml + # with: + # runner: 'ubuntu-22.04' + # host-platform: 'ubuntu' + # target-platform: 'zynq' - build_linux_for_zynq_on_windows: - runs-on: windows-2022 - timeout-minutes: 15 + +#======================================== +# Target Zynq - Host Windows +#======================================== + + build_target_zynq_host_windows: + needs: check_formatting permissions: pull-requests: write - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: jwlawson/actions-setup-cmake@v1.14 - with: - cmake-version: "3.30.x" - - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - run: | - python -u Scripts/CheckFormattingAll_c_h_cpp_hpp.py - python -u Scripts/BuildAndInstallExternalLibs.py --TargetPlatform zynq - python -u Scripts/BuildAndInstallCoDeLib.py --TargetPlatform zynq - python -u Scripts/BuildBenchmark.py --TargetPlatform zynq + uses: ./.github/workflows/build-test-run-reusable-workflow.yaml + with: + runner: 'windows-2022' + host-platform: 'windows' + target-platform: 'zynq' diff --git a/.github/workflows/push-to-main-workflow.yml b/.github/workflows/push-to-main-workflow.yml index 57cf33c3..c66a3634 100644 --- a/.github/workflows/push-to-main-workflow.yml +++ b/.github/workflows/push-to-main-workflow.yml @@ -4,26 +4,76 @@ on: branches: - main jobs: - build_run_targets: + +#======================================== +# Checks +#======================================== + + check_formatting: runs-on: ubuntu-22.04 + name: Check Formatting timeout-minutes: 15 - permissions: - pull-requests: write steps: - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: jwlawson/actions-setup-cmake@v1.14 - with: - cmake-version: "3.30.x" - uses: actions/setup-python@v5 with: python-version: '3.11' - - run: | python -u Scripts/CheckFormattingAll_c_h_cpp_hpp.py - python -u Scripts/BuildAndInstallExternalLibs.py - python -u Scripts/BuildAndInstallCoDeLib.py - python -u Scripts/RunTest.py - python -u Scripts/BuildBenchmark.py - python -u Scripts/RunBenchmark.py + +#======================================== +# Target Ubuntu - Host Ubuntu +#======================================== + + target_ubuntu_host_ubuntu: + needs: check_formatting + permissions: + pull-requests: write + uses: ./.github/workflows/build-test-run-reusable-workflow.yaml + with: + runner: 'ubuntu-22.04' + host-platform: 'ubuntu' + target-platform: 'host' + +#======================================== +# Target Windows - Host Windows +#======================================== + + target_windows_host_windows: + needs: check_formatting + permissions: + pull-requests: write + uses: ./.github/workflows/build-test-run-reusable-workflow.yaml + with: + runner: 'windows-2022' + host-platform: 'windows' + target-platform: 'host' + +#======================================== +# Target Zynq - Host Ubuntu +#======================================== + + # build_target_zynq_host_ubuntu: + # needs: check_formatting + # permissions: + # pull-requests: write + # uses: ./.github/workflows/build-test-run-reusable-workflow.yaml + # with: + # runner: 'ubuntu-22.04' + # host-platform: 'ubuntu' + # target-platform: 'zynq' + + +#======================================== +# Target Zynq - Host Windows +#======================================== + + build_target_zynq_host_windows: + needs: check_formatting + permissions: + pull-requests: write + uses: ./.github/workflows/build-test-run-reusable-workflow.yaml + with: + runner: 'windows-2022' + host-platform: 'windows' + target-platform: 'zynq' diff --git a/Scripts/RunBenchmark.py b/Scripts/RunBenchmark.py index 818b7874..f9fdd230 100644 --- a/Scripts/RunBenchmark.py +++ b/Scripts/RunBenchmark.py @@ -1,4 +1,5 @@ import os +import stat from pathlib import Path import subprocess import re @@ -120,6 +121,13 @@ def RunBenchmark( print(BenchmarkHeader, end="") BenchmarkExecutablePath = Path(BuildDirectory / BenchmarkName) + if targetPlatform == EnvironmentConfig.Platform.WINDOWS: + BenchmarkExecutablePath = BenchmarkExecutablePath.with_suffix(".exe") + + BenchmarkExecutablePath.chmod( + BenchmarkExecutablePath.stat().st_mode | stat.S_IEXEC + ) + BenchmarkCommand = str(BenchmarkExecutablePath) + " " + BenchmarkOptions print("Command: {}".format(BenchmarkCommand)) diff --git a/Scripts/RunTest.py b/Scripts/RunTest.py index 95c89bbb..34a14921 100644 --- a/Scripts/RunTest.py +++ b/Scripts/RunTest.py @@ -1,4 +1,5 @@ import os +import stat from pathlib import Path import subprocess import EnvironmentConfig @@ -107,6 +108,11 @@ def RunTests( print(testHeader, end="") TestExecutablePath = Path(CoDeLibBuildPath / "Test" / testName) + if targetPlatform == EnvironmentConfig.Platform.WINDOWS: + TestExecutablePath = TestExecutablePath.with_suffix(".exe") + + TestExecutablePath.chmod(TestExecutablePath.stat().st_mode | stat.S_IEXEC) + TestOptions = '"' + str(BenchmarkTestFilesPath) + '/"' TestCommand = str(TestExecutablePath) + " " + TestOptions