From abce11aeedb949e6213f749f9527ef354eb51eb9 Mon Sep 17 00:00:00 2001 From: Walker Date: Fri, 17 Apr 2026 10:08:34 -0500 Subject: [PATCH 1/2] Test cFS/workflows#122 --- .github/workflows/mcdc.yml | 212 +++++++++++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 .github/workflows/mcdc.yml diff --git a/.github/workflows/mcdc.yml b/.github/workflows/mcdc.yml new file mode 100644 index 000000000..252d9d711 --- /dev/null +++ b/.github/workflows/mcdc.yml @@ -0,0 +1,212 @@ +name: MCDC Analysis + +on: + push: + branches: + - dev + - main + pull_request: + types: + - opened + - reopened + - synchronize + workflow_dispatch: + +# Force bash to apply pipefail option so pipeline failures aren't masked +defaults: + run: + shell: bash + +env: + SIMULATION: native + TESTS_RAN: false + +jobs: + # Checks for duplicate actions. Skips push actions if there is a matching or + # duplicate pull-request action. + checks-for-duplicates: + runs-on: cfs-self-hosted + # Map a step output to a job output + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: synced-actions/skip-duplicate-actions@master + with: + concurrent_skipping: 'same_content' + skip_after_successful_duplicate: 'true' + do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]' + + mcdc: + needs: checks-for-duplicates + if: ${{ needs.checks-for-duplicates.outputs.should_skip != 'true' || contains(github.ref, 'dev') || contains(github.ref, 'main') }} + name: Build and Run MCDC + runs-on: ubuntu-22.04 + container: ghcr.io/core-flight-system/mcdc:latest + + steps: + - name: Checkout MCDC Script + uses: actions/checkout@v4 + with: + repository: arielswalker/workflows + path: workflows + ref: test-cfs/workflows122 + + - name: Checkout OSAL + uses: actions/checkout@v4 + with: + path: source + + - name: Modify osal to include coverage flags + run: | + sed -i 's/target_compile_options.*)/target_compile_options(ut_coverage_compile INTERFACE -pg -O0 -fprofile-arcs -ftest-coverage -fcondition-coverage -fprofile-abs-path)/' source/src/bsp/generic-linux/CMakeLists.txt + sed -i 's/set(UT_COVERAGE_COMPILE_FLAGS.*)/set(UT_COVERAGE_COMPILE_FLAGS -pg --coverage -O0 -fcondition-coverage -fprofile-abs-path)/' source/src/bsp/generic-linux/build_options.cmake + sed -i 's/set(UT_COVERAGE_LINK_FLAGS.*)/set(UT_COVERAGE_LINK_FLAGS -pg --coverage -O0 -fcondition-coverage -fprofile-abs-path)/' source/src/bsp/generic-linux/build_options.cmake + + - name: Set up build + run: cmake + -DCMAKE_BUILD_TYPE=Debug + -DENABLE_UNIT_TESTS=TRUE + -DOSAL_OMIT_DEPRECATED=FALSE + -DOSAL_VALIDATE_API=FALSE + -DOSAL_INSTALL_LIBRARIES=FALSE + -DOSAL_CONFIG_DEBUG_PERMISSIVE_MODE=TRUE + -DOSAL_SYSTEM_BSPTYPE=generic-linux + -DCMAKE_PREFIX_PATH=/usr/lib/cmake + -DCMAKE_INSTALL_PREFIX=/usr + -S source + -B build + + - name: Build OSAL + working-directory: build + run: make VERBOSE=1 + + - name: Execute Tests + working-directory: build + run: | + echo "BASE_DIR=build/unit-test-coverage" >> $GITHUB_ENV + (ctest --output-on-failure -j4 2>&1 || true) | tee ../test_results.txt + echo "TESTS_RAN=true" >> $GITHUB_ENV + + - name: Grab test modules + if: ${{ env.TESTS_RAN == 'true' }} + run: | + echo "MODULES=$(grep -oP 'Test\s+#\d+: \K[\w\-\_]+(?= )' test_results.txt | tr '\n' ' ' | sed 's/ $//')" >> $GITHUB_ENV + grep -oP 'Test #\d+: \K[\w\-\_]+' test_results.txt | tr '\n' ' ' | sed 's/ $//' >> modules.txt + + - name: Run mcdc analysis + if: ${{ env.TESTS_RAN == 'true' }} + run: bash workflows/.github/scripts/mcdc-analyze.sh + + - name: Save PR number + if: github.event_name == 'pull_request_target' && always() + env: + PR_NUMBER: ${{ github.event.number }} + run: echo $PR_NUMBER > pr_number + + - name: Archive unit test results + # Upload if success or failure which supports skipping, unlike always() + if: ${{ env.TESTS_RAN == 'true' }} + uses: actions/upload-artifact@v4 + with: + name: Unit test results + path: | + test_results.txt + + - name: Archive mcdc results + # Upload if success or failure which supports skipping, unlike always() + if: ${{ env.TESTS_RAN == 'true' }} + uses: actions/upload-artifact@v4 + with: + name: MCDC results + path: | + **/*.gcov.json.gz + mcdc_results.txt + pr_number + modules.txt + + comment-mcdc: + needs: mcdc + if: github.event_name == 'pull_request_target' && always() + name: Comment MCDC Comparision on PR + runs-on: ubuntu-22.04 + + steps: + - name: Checkout MCDC Script + uses: actions/checkout@v4 + with: + repository: arielswalker/workflows + path: workflows + ref: test-cfs/workflows122 + + - name: Download latest main branch artifact + continue-on-error: true + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + workflow: mcdc-internal.yml + search_artifacts: true + branch: dev + name: MCDC results + path: main-branch-results + + - uses: actions/download-artifact@v3 + with: + name: MCDC results + + - name: Compare main and PR artifacts + run: | + if [ -f "main-branch-results/mcdc_results.txt" ]; then + echo "Main branch artifact found. Running comparison." + bash mcdc/.github/scripts/mcdc-compare.sh main-branch-results/mcdc_results.txt mcdc_results.txt main-branch-results/modules.txt + else + echo "Main branch artifact not found. Skipping comparison step." + fi + + - name: Output summary to workflow + run: | + if [ -f "mcdc_comment.txt" ] && [ -s "mcdc_comment.txt" ]; then + echo "### MC/DC Results (Comparison with dev branch)" >> $GITHUB_STEP_SUMMARY + echo '```plaintext' >> $GITHUB_STEP_SUMMARY + cat mcdc_comment.txt >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + + if [ -f "uncovered.json" ] && [ -s "uncovered.json" ]; then + echo "
" >> $GITHUB_STEP_SUMMARY + echo "Click to view uncovered branches (uncovered.json)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo '```json' >> $GITHUB_STEP_SUMMARY + cat uncovered.json >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "
" >> $GITHUB_STEP_SUMMARY + fi + + elif [ -f "mcdc_results.txt" ] && [ -s "mcdc_results.txt" ]; then + echo "### MC/DC Results (Current PR)" >> $GITHUB_STEP_SUMMARY + echo '```plaintext' >> $GITHUB_STEP_SUMMARY + cat mcdc_results.txt >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + + # Show uncovered branches from the regular analysis if available + if [ -f "uncovered.json" ] && [ -s "uncovered.json" ]; then + echo "
" >> $GITHUB_STEP_SUMMARY + echo "Click to view uncovered branches (uncovered.json)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo '```json' >> $GITHUB_STEP_SUMMARY + cat uncovered.json >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "
" >> $GITHUB_STEP_SUMMARY + fi + else + echo "No MCDC results found." >> $GITHUB_STEP_SUMMARY + fi + + - name: Archive mcdc comparison + # Upload if success or failure which supports skipping, unlike always() + if: success() || failure() + uses: actions/upload-artifact@v3 + with: + name: MCDC main branch comparison + path: | + mcdc_comment.txt + mcdc_compare.txt \ No newline at end of file From f5e8a6db9105ed825edb9c595e3b0b0141e42486 Mon Sep 17 00:00:00 2001 From: Walker Date: Fri, 17 Apr 2026 10:12:26 -0500 Subject: [PATCH 2/2] Test --- .github/workflows/add-to-project.yml | 14 ++++++ .github/workflows/mcdc.yml | 68 ++++++++++++---------------- 2 files changed, 44 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/add-to-project.yml diff --git a/.github/workflows/add-to-project.yml b/.github/workflows/add-to-project.yml new file mode 100644 index 000000000..49787f038 --- /dev/null +++ b/.github/workflows/add-to-project.yml @@ -0,0 +1,14 @@ +name: Add Issue or PR to Project + +on: + issues: + types: [opened] + # Testing - changed pull_request_target to pull_request + pull_request: + types: [opened, ready_for_review, converted_to_draft] + +jobs: + add-to-project: + name: Add issue or pull request to project + uses: arielswalker/cFS/.github/workflows/add-to-project-reusable.yml@test-cfs/workflows122 + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/mcdc.yml b/.github/workflows/mcdc.yml index 252d9d711..b43c40f4e 100644 --- a/.github/workflows/mcdc.yml +++ b/.github/workflows/mcdc.yml @@ -25,13 +25,13 @@ jobs: # Checks for duplicate actions. Skips push actions if there is a matching or # duplicate pull-request action. checks-for-duplicates: - runs-on: cfs-self-hosted + runs-on: ubuntu-22.04 # Map a step output to a job output outputs: should_skip: ${{ steps.skip_check.outputs.should_skip }} steps: - id: skip_check - uses: synced-actions/skip-duplicate-actions@master + uses: fkirc/skip-duplicate-actions@master with: concurrent_skipping: 'same_content' skip_after_successful_duplicate: 'true' @@ -48,8 +48,8 @@ jobs: - name: Checkout MCDC Script uses: actions/checkout@v4 with: - repository: arielswalker/workflows - path: workflows + repository: arielswalker/cFS + path: mcdc ref: test-cfs/workflows122 - name: Checkout OSAL @@ -96,10 +96,10 @@ jobs: - name: Run mcdc analysis if: ${{ env.TESTS_RAN == 'true' }} - run: bash workflows/.github/scripts/mcdc-analyze.sh + run: bash mcdc/.github/scripts/mcdc-analyze.sh - name: Save PR number - if: github.event_name == 'pull_request_target' && always() + if: github.event_name == 'pull_request' && always() env: PR_NUMBER: ${{ github.event.number }} run: echo $PR_NUMBER > pr_number @@ -125,22 +125,22 @@ jobs: pr_number modules.txt - comment-mcdc: + summary-mcdc: needs: mcdc - if: github.event_name == 'pull_request_target' && always() - name: Comment MCDC Comparision on PR + if: github.event_name == 'pull_request' && always() + name: Generate MCDC Comparison Summary runs-on: ubuntu-22.04 steps: - name: Checkout MCDC Script uses: actions/checkout@v4 with: - repository: arielswalker/workflows - path: workflows + repository: arielswalker/cFS + path: mcdc ref: test-cfs/workflows122 - name: Download latest main branch artifact - continue-on-error: true + continue-on-error: true uses: dawidd6/action-download-artifact@v2 with: github_token: ${{ secrets.GITHUB_TOKEN }} @@ -150,7 +150,7 @@ jobs: name: MCDC results path: main-branch-results - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: MCDC results @@ -165,46 +165,38 @@ jobs: - name: Output summary to workflow run: | - if [ -f "mcdc_comment.txt" ] && [ -s "mcdc_comment.txt" ]; then + if [ -s "mcdc_comment.txt" ]; then echo "### MC/DC Results (Comparison with dev branch)" >> $GITHUB_STEP_SUMMARY echo '```plaintext' >> $GITHUB_STEP_SUMMARY cat mcdc_comment.txt >> $GITHUB_STEP_SUMMARY echo '```' >> $GITHUB_STEP_SUMMARY - - if [ -f "uncovered.json" ] && [ -s "uncovered.json" ]; then - echo "
" >> $GITHUB_STEP_SUMMARY - echo "Click to view uncovered branches (uncovered.json)" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo '```json' >> $GITHUB_STEP_SUMMARY - cat uncovered.json >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY - echo "
" >> $GITHUB_STEP_SUMMARY - fi - - elif [ -f "mcdc_results.txt" ] && [ -s "mcdc_results.txt" ]; then + elif [ -s "mcdc_results.txt" ]; then echo "### MC/DC Results (Current PR)" >> $GITHUB_STEP_SUMMARY echo '```plaintext' >> $GITHUB_STEP_SUMMARY cat mcdc_results.txt >> $GITHUB_STEP_SUMMARY echo '```' >> $GITHUB_STEP_SUMMARY - - # Show uncovered branches from the regular analysis if available - if [ -f "uncovered.json" ] && [ -s "uncovered.json" ]; then - echo "
" >> $GITHUB_STEP_SUMMARY - echo "Click to view uncovered branches (uncovered.json)" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo '```json' >> $GITHUB_STEP_SUMMARY - cat uncovered.json >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY - echo "
" >> $GITHUB_STEP_SUMMARY - fi else echo "No MCDC results found." >> $GITHUB_STEP_SUMMARY fi + # Output uncovered branches if the file exists and is not empty + if [ -s "uncovered.json" ]; then + echo "" >> $GITHUB_STEP_SUMMARY + echo "
" >> $GITHUB_STEP_SUMMARY + echo "Click to view uncovered branches (uncovered.json)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo '```json' >> $GITHUB_STEP_SUMMARY + cat uncovered.json >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "
" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + fi + - name: Archive mcdc comparison # Upload if success or failure which supports skipping, unlike always() if: success() || failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: MCDC main branch comparison path: |