ctrace initial development #36
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ctrace | |
| on: | |
| workflow_call: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '.github/workflows/ctrace.yml' | |
| - '.github/matrix_includes_ctrace.json' | |
| - 'CMakeLists.txt' | |
| - 'tools/ctrace/CMakeLists.txt' | |
| - 'tools/ctrace/cmake/**' | |
| - 'tools/ctrace/src/**' | |
| - 'tools/ctrace/test/**' | |
| pull_request: | |
| paths: | |
| - '.github/workflows/ctrace.yml' | |
| - '.github/matrix_includes_ctrace.json' | |
| - 'CMakeLists.txt' | |
| - 'tools/ctrace/CMakeLists.txt' | |
| - 'tools/ctrace/cmake/**' | |
| - 'tools/ctrace/src/**' | |
| - 'tools/ctrace/test/**' | |
| release: | |
| types: [published] | |
| concurrency: | |
| group: ctrace-${{ github.ref }}-${{ github.event_name }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| setup: | |
| uses: ./.github/workflows/shared_setup_env.yml | |
| with: | |
| run_if: ${{ (github.event_name == 'pull_request') || (github.event_name == 'workflow_dispatch') || (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/tools/ctrace/')) || ((github.event.schedule != '') && (!github.event.repository.private)) }} | |
| matrix_prep: | |
| needs: setup | |
| uses: ./.github/workflows/shared_matrix_prep.yml | |
| with: | |
| workflow_name: ctrace | |
| build: | |
| needs: [ setup, matrix_prep ] | |
| runs-on: ${{ matrix.runs_on }} | |
| name: build (${{ matrix.runs_on }}, ${{ matrix.arch }}) | |
| timeout-minutes: 25 | |
| strategy: | |
| fail-fast: true | |
| matrix: ${{ fromJson(needs.matrix_prep.outputs.matrix) }} | |
| steps: | |
| - name: Harden Runner | |
| if: ${{ !github.event.repository.private }} | |
| uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout devtools | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| submodules: true | |
| fetch-depth: 0 | |
| # https://github.com/Open-CMSIS-Pack/devtools-build-action | |
| - name: Build | |
| uses: Open-CMSIS-Pack/devtools-build-action@5b24a2b5145eb406a664269b3704bb983c19242d # arm64 | |
| with: | |
| target: ctrace | |
| arch: ${{ matrix.arch }} | |
| - name: Install strip tools | |
| if: | | |
| github.event_name == 'release' && | |
| matrix.arch == 'arm64' && | |
| startsWith(matrix.runs_on, 'ubuntu') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install binutils-aarch64-linux-gnu | |
| - name: Strip ctrace release binary | |
| if: | | |
| github.event_name == 'release' && | |
| (startsWith(matrix.runs_on, 'macos') || startsWith(matrix.runs_on, 'ubuntu')) | |
| run: | | |
| binary_path="./build/tools/ctrace/${{ matrix.target }}-${{ matrix.arch }}/Release/${{ matrix.binary }}" | |
| echo "Stripping binary at: $binary_path" | |
| if [[ "${{ matrix.arch }}" == "arm64" && "${{ matrix.target }}" == "linux" ]]; then | |
| aarch64-linux-gnu-strip "$binary_path" | |
| else | |
| strip "$binary_path" | |
| fi | |
| - name: Archive ctrace | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: ctrace-${{ matrix.target }}-${{ matrix.arch }} | |
| path: ./build/tools/ctrace/${{ matrix.target }}-${{ matrix.arch }}/Release/${{ matrix.binary }} | |
| retention-days: ${{ needs.setup.outputs.retention_days }} | |
| if-no-files-found: error | |
| release: | |
| if: | | |
| github.event_name == 'release' && | |
| startsWith(github.ref, 'refs/tags/tools/ctrace/') | |
| needs: [ build, test, coverage ] | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 25 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout devtools | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| submodules: true | |
| - name: Download ctrace linux-amd64 | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ctrace-linux-amd64 | |
| path: tools/ctrace/distribution/bin/linux-amd64/ | |
| - name: Download ctrace linux-arm64 | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ctrace-linux-arm64 | |
| path: tools/ctrace/distribution/bin/linux-arm64/ | |
| - name: Download ctrace macos-arm64 | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ctrace-darwin-arm64 | |
| path: tools/ctrace/distribution/bin/darwin-arm64/ | |
| - name: Download ctrace windows-amd64 | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ctrace-windows-amd64 | |
| path: tools/ctrace/distribution/bin/windows-amd64/ | |
| - name: Download ctrace windows-arm64 | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ctrace-windows-arm64 | |
| path: tools/ctrace/distribution/bin/windows-arm64/ | |
| - name: Verify and package distribution | |
| run: tools/ctrace/scripts/package-release.sh | |
| - name: Attach zip archive to release assets | |
| uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de # v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: tools/ctrace/distribution/ctrace.zip | |
| tag: ${{ github.ref }} | |
| overwrite: true | |
| asset_name: ctrace.zip | |
| test: | |
| needs: [ setup, matrix_prep ] | |
| name: test (${{ matrix.runs_on }}, ${{ matrix.arch }}) | |
| runs-on: ${{ matrix.runs_on }} | |
| timeout-minutes: 25 | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.matrix_prep.outputs.matrix) }} | |
| steps: | |
| - name: Harden Runner | |
| if: ${{ !github.event.repository.private }} | |
| uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout devtools | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| submodules: true | |
| # https://github.com/Open-CMSIS-Pack/devtools-build-action | |
| - name: Build CtraceUnitTests | |
| id: build_unit_tests | |
| uses: Open-CMSIS-Pack/devtools-build-action@5b24a2b5145eb406a664269b3704bb983c19242d # arm64 | |
| with: | |
| target: CtraceUnitTests | |
| build_type: Debug | |
| arch: ${{ matrix.arch }} | |
| # https://github.com/Open-CMSIS-Pack/devtools-build-action | |
| - name: Build CtraceIntegTests | |
| id: build_integration_target | |
| uses: Open-CMSIS-Pack/devtools-build-action@5b24a2b5145eb406a664269b3704bb983c19242d # arm64 | |
| with: | |
| target: CtraceIntegTests | |
| build_type: Debug | |
| arch: ${{ matrix.arch }} | |
| - name: Run ctrace unit tests | |
| id: run_unit_tests | |
| if: always() && (matrix.arch != 'arm64') && (steps.build_unit_tests.outcome == 'success') | |
| run: ctest -V -C Debug -R '^CtraceUnitTests$' | |
| working-directory: ./build | |
| - name: Run ctrace integration tests | |
| id: run_integration_tests | |
| if: always() && (matrix.arch != 'arm64') && (steps.build_integration_target.outcome == 'success') | |
| run: ctest -V -C Debug -R '^(CtraceIntegTests|ctrace-)' | |
| working-directory: ./build | |
| - name: Archive unit test results | |
| # Keep the report available when test execution fails. | |
| if: always() && (matrix.arch != 'arm64') && (steps.run_unit_tests.outcome != 'skipped') | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: unit_test_result_ctrace-${{ matrix.target }}-${{ matrix.arch }} | |
| path: ./build/test_reports/ctraceunittests-report-${{ matrix.target }}-${{ matrix.arch }}.xml | |
| retention-days: ${{ needs.setup.outputs.retention_days }} | |
| if-no-files-found: error | |
| - name: Archive integration test results | |
| # Keep the report available when test execution fails. | |
| if: always() && (matrix.arch != 'arm64') && (steps.run_integration_tests.outcome != 'skipped') | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: integ_test_result_ctrace-${{ matrix.target }}-${{ matrix.arch }} | |
| path: ./build/test_reports/ctraceintegtests-report-${{ matrix.target }}-${{ matrix.arch }}.xml | |
| retention-days: ${{ needs.setup.outputs.retention_days }} | |
| if-no-files-found: error | |
| coverage: | |
| if: | | |
| (github.event_name == 'pull_request') || | |
| (github.event_name == 'workflow_dispatch') || | |
| (github.event_name == 'push') || | |
| (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/tools/ctrace/')) || | |
| ((github.event.schedule != '') && (!github.event.repository.private)) | |
| env: | |
| lcov_base: https://github.com/linux-test-project/lcov/releases/download/v1.15 | |
| lcov_installer: lcov-1.15.tar.gz | |
| lcov_sha256: c1cda2fa33bec9aa2c2c73c87226cfe97de0831887176b45ee523c5e30f8053a | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 25 | |
| steps: | |
| - name: Harden Runner | |
| if: ${{ !github.event.repository.private }} | |
| uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout devtools | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| submodules: true | |
| # https://github.com/Open-CMSIS-Pack/devtools-build-action | |
| - name: Build CtraceUnitTests | |
| uses: Open-CMSIS-Pack/devtools-build-action@5b24a2b5145eb406a664269b3704bb983c19242d # arm64 | |
| with: | |
| add_cmake_variables: -DCOVERAGE=ON | |
| arch: amd64 | |
| build_type: Debug | |
| target: CtraceUnitTests | |
| # https://github.com/Open-CMSIS-Pack/devtools-build-action | |
| - name: Build CtraceIntegTests | |
| uses: Open-CMSIS-Pack/devtools-build-action@5b24a2b5145eb406a664269b3704bb983c19242d # arm64 | |
| with: | |
| add_cmake_variables: -DCOVERAGE=ON | |
| arch: amd64 | |
| build_type: Debug | |
| target: CtraceIntegTests | |
| - name: Run ctrace unit tests | |
| run: ctest -V -C Debug -R '^CtraceUnitTests$' | |
| working-directory: ./build | |
| - name: Run ctrace integration tests | |
| run: ctest -V -C Debug -R '^(CtraceIntegTests|ctrace-)' | |
| working-directory: ./build | |
| - name: Get retention days | |
| id: var | |
| run: | | |
| echo "retention_days=$(echo '${{ (!github.event.repository.private && (github.event_name == 'push' || github.event.schedule != '')) && '7' || '1' }}')" >> $GITHUB_OUTPUT | |
| - name: Archive unit test results | |
| if: (github.event_name == 'push') | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: unit_test_result_ctrace-linux-amd64 | |
| path: ./build/test_reports/ctraceunittests-report-linux-amd64.xml | |
| retention-days: ${{ steps.var.outputs.retention_days }} | |
| if-no-files-found: error | |
| - name: Archive integration test results | |
| if: (github.event_name == 'push') | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: integ_test_result_ctrace-linux-amd64 | |
| path: ./build/test_reports/ctraceintegtests-report-linux-amd64.xml | |
| retention-days: ${{ steps.var.outputs.retention_days }} | |
| if-no-files-found: error | |
| - name: Setup lcov1.15 | |
| run: | | |
| wget -q ${{ env.lcov_base }}/${{ env.lcov_installer }} | |
| echo "${{ env.lcov_sha256 }} ${{ env.lcov_installer }}" | sha256sum --check --strict | |
| tar -xvf ${{ env.lcov_installer }} | |
| working-directory: ./build/tools/ctrace | |
| - name: Generate coverage report | |
| run: | | |
| lcov-1.15/bin/lcov --rc lcov_branch_coverage=1 --rc geninfo_no_exception_branch=1 -c --directory . --output-file full_coverage.info | |
| lcov-1.15/bin/lcov --rc lcov_branch_coverage=1 --rc geninfo_no_exception_branch=1 -e full_coverage.info '*/tools/ctrace/src/*' -o coverage_ctrace.info | |
| # Preserve unfiltered branch data for review, but gate on portable source-line coverage. | |
| lcov-1.15/bin/lcov --rc lcov_branch_coverage=0 -e full_coverage.info '*/tools/ctrace/src/*' -o coverage_ctrace_codecov.info | |
| lcov-1.15/bin/genhtml coverage_ctrace.info --output-directory coverage_ctrace --branch-coverage | |
| working-directory: ./build/tools/ctrace | |
| - name: Upload Report to Codecov | |
| if: ${{ !github.event.repository.private }} | |
| uses: Wandalen/wretry.action@e68c23e6309f2871ca8ae4763e7629b9c258e1ea # v3.8.0 | |
| with: | |
| action: codecov/codecov-action@v4 | |
| with: | | |
| files: ./build/tools/ctrace/coverage_ctrace_codecov.info | |
| fail_ci_if_error: true | |
| flags: ctrace-cov | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| verbose: true | |
| attempt_limit: 3 | |
| attempt_delay: 5000 | |
| - name: Archive coverage report | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: coverage-report-ctrace | |
| path: | | |
| ./build/tools/ctrace/coverage_ctrace/ | |
| ./build/tools/ctrace/coverage_ctrace.info | |
| ./build/tools/ctrace/coverage_ctrace_codecov.info | |
| retention-days: ${{ steps.var.outputs.retention_days }} | |
| if-no-files-found: error | |
| test-results-preparation: | |
| name: "Publish Tests Results" | |
| # A dependent reporting job is otherwise skipped after a test failure. | |
| if: ${{ always() }} | |
| needs: [ test ] | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Harden Runner | |
| if: ${{ !github.event.repository.private }} | |
| uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 | |
| with: | |
| egress-policy: audit | |
| - name: Event File | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: Event File ctrace | |
| path: ${{ github.event_path }} |