From 0199ab0661afba5fb2c0049029c89a1bf0706a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Ga=C5=82at?= Date: Mon, 11 Dec 2023 16:00:27 +0000 Subject: [PATCH] GHA: merge build and run workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit speed up GHA Signed-off-by: Robert Gałat --- ...mon-build.yml => common-build_and_run.yml} | 138 +++++++++++++++++- .github/workflows/common_run_dut_ut.yml | 130 ----------------- .github/workflows/on-commit.yml | 8 +- .github/workflows/on-pr.yml | 8 +- .github/workflows/tag-action.yml | 2 +- .github/workflows/verify-new-ncs.yml | 10 +- 6 files changed, 139 insertions(+), 157 deletions(-) rename .github/workflows/{common-build.yml => common-build_and_run.yml} (62%) delete mode 100644 .github/workflows/common_run_dut_ut.yml diff --git a/.github/workflows/common-build.yml b/.github/workflows/common-build_and_run.yml similarity index 62% rename from .github/workflows/common-build.yml rename to .github/workflows/common-build_and_run.yml index b0e80ccc58..fe8008adb6 100644 --- a/.github/workflows/common-build.yml +++ b/.github/workflows/common-build_and_run.yml @@ -12,15 +12,19 @@ on: required: false type: string default: '["nrf52840dk_nrf52840", "nrf5340dk_nrf5340_cpuapp"]' + run_tests: + description: 'run tests on HW after building' + type: bool + default: true jobs: build_samples: strategy: matrix: platform: ${{ fromJson(inputs.supported_platforms) }} - subset: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] + subset: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] env: - MAX_SUBSETS: 12 + MAX_SUBSETS: 13 runs-on: ubuntu-latest container: @@ -86,9 +90,9 @@ jobs: strategy: matrix: platform: ${{ fromJson(inputs.supported_platforms) }} - subset: [1, 2, 3, 4] + subset: [1, 2, 3, 4, 5, 6, 7] env: - MAX_SUBSETS: 4 + MAX_SUBSETS: 7 runs-on: ubuntu-latest container: @@ -155,9 +159,9 @@ jobs: strategy: matrix: platform: ${{ fromJson(inputs.supported_platforms) }} - subset: [1, 2, 3, 4, 5] + subset: [1, 2, 3, 4, 5, 6, 7, 8] env: - MAX_SUBSETS: 5 + MAX_SUBSETS: 8 runs-on: ubuntu-latest container: @@ -212,3 +216,125 @@ jobs: path: | twister-out subsets + + run_dut_ut: + needs: [build_tests] + if: ${{ fromJson(inputs.run_tests) }} + continue-on-error: true + runs-on: test-node + container: + image: ghcr.io/nrfconnect/sdk-sidewalk:main + options: --cpus 2 --privileged + volumes: + - /home/tester/hw_settings:/hw_settings + - /dev:/dev + - /run/udev:/run/udev + defaults: + run: + shell: nrfutil toolchain-manager launch --install-dir /root/ncs bash -- {0} + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + path: sidewalk + + - name: check hw_settings + run: | + ls -lah /hw_settings + + - name: Install Python dependencies + run: | + python3 -m pip install -r sidewalk/scripts/ci/requirements.txt + + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: tests-dut-artifacts + + - name: Run Tests + run: | + source /workdir/zephyr/zephyr-env.sh + connected_DKs=`grep "connected: true" /hw_settings/hardware_map.yaml | wc -l` + python3 sidewalk/scripts/ci/combine_twister_reports.py subsets/**/twister.json twister-out/twister.json + python3 sidewalk/scripts/ci/combine_twister_reports.py subsets/**/testplan.json twister-out/testplan.json + west twister -j $connected_DKs --no-clean -vvv --inline-logs --test-only --hardware-map /hw_settings/hardware_map.yaml --device-testing -T sidewalk/tests --retry-failed 2 --west-flash="--recover,--erase" + + - name: Upload test results + uses: actions/upload-artifact@v3 + if: always() + with: + name: tests-dut_result + path: | + twister-out/twister.xml + twister-out/**/handler.log + twister-out/**/device.log + + build_and_run_ut_x86: + runs-on: ubuntu-latest + container: + image: ghcr.io/nrfconnect/sdk-sidewalk:main + options: --cpus 2 + defaults: + run: + shell: nrfutil toolchain-manager launch --install-dir /root/ncs bash -- {0} + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install Python dependencies + run: | + python3 -m pip install -r scripts/ci/requirements.txt + + - name: change_nrf_revision + if: ${{ inputs.change_nrf_revision }} + run: | + python3 scripts/ci/replace_nrf_revision_in_west.py internal_west.yml + + - name: Reconfigure west + run: | + source /workdir/zephyr/zephyr-env.sh + cp -r ../sdk-sidewalk /workdir/internal_sidewalk + cd /workdir + west config manifest.path internal_sidewalk && \ + west config manifest.file internal_west.yml && \ + west update --narrow -o=--depth=1 && \ + ln -s internal_sidewalk sidewalk + + - name: Build test artifacts + run: | + source /workdir/zephyr/zephyr-env.sh + west twister --platform native_posix --platform unit_testing --coverage --enable-ubsan --enable-lsan --enable-asan --testsuite-root /workdir/sidewalk/tests/ --inline-logs --overflow-as-errors -vvv + + - name: Fix coverage report + run: | + lcov -q --remove "twister-out/coverage.info" '/**/twister-out/*' '/**/mbedtls/*' '/**/test/cmock/*' '/**/zephyr/*' -o "coverage.info" + + - name: Upload test results + uses: actions/upload-artifact@v3 + if: always() + with: + name: tests-x86_result + path: | + twister-out/twister.xml + twister-out/**/handler.log + twister-out/**/device.log + + - name: Upload Coverage report + run: | + echo "# Coverage" >> summary + echo "" >> summary + echo "## Summary" >> summary + echo "" >> summary + echo "\`\`\`" >> summary + lcov --summary coverage.info --rc lcov_branch_coverage=1 >> summary + echo "\`\`\`" >> summary + echo "## File coverage" >> summary + echp "">> summary + echo "\`\`\`" >> summary + lcov --list coverage.info --rc lcov_branch_coverage=1 >> summary + echo "\`\`\`" >> summary + cat summary >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/common_run_dut_ut.yml b/.github/workflows/common_run_dut_ut.yml deleted file mode 100644 index ff646820e4..0000000000 --- a/.github/workflows/common_run_dut_ut.yml +++ /dev/null @@ -1,130 +0,0 @@ -name: Build Sidewalk samples and tests -on: - workflow_call: - inputs: - change_nrf_revision: - description: 'change revision of nrf in west.yml to `main`' - required: false - type: boolean - default: false - -jobs: - run_dut_ut: - continue-on-error: true - runs-on: test-node - container: - image: ghcr.io/nrfconnect/sdk-sidewalk:main - options: --cpus 2 --privileged - volumes: - - /home/tester/hw_settings:/hw_settings - - /dev:/dev - - /run/udev:/run/udev - defaults: - run: - shell: nrfutil toolchain-manager launch --install-dir /root/ncs bash -- {0} - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - path: sidewalk - - - name: check hw_settings - run: | - ls -lah /hw_settings - - - name: Install Python dependencies - run: | - python3 -m pip install -r sidewalk/scripts/ci/requirements.txt - - - name: Download build artifacts - uses: actions/download-artifact@v3 - with: - name: tests-dut-artifacts - - - name: Run Tests - run: | - source /workdir/zephyr/zephyr-env.sh - connected_DKs=`grep "connected: true" /hw_settings/hardware_map.yaml | wc -l` - python3 sidewalk/scripts/ci/combine_twister_reports.py subsets/**/twister.json twister-out/twister.json - python3 sidewalk/scripts/ci/combine_twister_reports.py subsets/**/testplan.json twister-out/testplan.json - west twister -j $connected_DKs --no-clean -vvv --inline-logs --test-only --hardware-map /hw_settings/hardware_map.yaml --device-testing -T sidewalk/tests --retry-failed 2 --west-flash="--recover,--erase" - - - name: Upload test results - uses: actions/upload-artifact@v3 - if: always() - with: - name: tests-dut_result - path: | - twister-out/twister.xml - twister-out/**/handler.log - twister-out/**/device.log - - build_and_run_ut_x86: - runs-on: ubuntu-latest - container: - image: ghcr.io/nrfconnect/sdk-sidewalk:main - options: --cpus 2 - defaults: - run: - shell: nrfutil toolchain-manager launch --install-dir /root/ncs bash -- {0} - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Install Python dependencies - run: | - python3 -m pip install -r scripts/ci/requirements.txt - - - name: change_nrf_revision - if: ${{ inputs.change_nrf_revision }} - run: | - python3 scripts/ci/replace_nrf_revision_in_west.py internal_west.yml - - - name: Reconfigure west - run: | - source /workdir/zephyr/zephyr-env.sh - cp -r ../sdk-sidewalk /workdir/internal_sidewalk - cd /workdir - west config manifest.path internal_sidewalk && \ - west config manifest.file internal_west.yml && \ - west update --narrow -o=--depth=1 && \ - ln -s internal_sidewalk sidewalk - - - name: Build test artifacts for - run: | - source /workdir/zephyr/zephyr-env.sh - west twister --platform native_posix --platform unit_testing --coverage --enable-ubsan --enable-lsan --enable-asan --testsuite-root /workdir/sidewalk/tests/ --inline-logs --overflow-as-errors -vvv - - - name: Fix coverage report - run: | - lcov -q --remove "twister-out/coverage.info" '/**/twister-out/*' '/**/mbedtls/*' '/**/test/cmock/*' '/**/zephyr/*' -o "coverage.info" - - - name: Upload test results - uses: actions/upload-artifact@v3 - if: always() - with: - name: tests-x86_result - path: | - twister-out/twister.xml - twister-out/**/handler.log - twister-out/**/device.log - - - name: Upload Coverage report - run: | - echo "# Coverage" >> summary - echo "" >> summary - echo "## Summary" >> summary - echo "" >> summary - echo "\`\`\`" >> summary - lcov --summary coverage.info --rc lcov_branch_coverage=1 >> summary - echo "\`\`\`" >> summary - echo "## File coverage" >> summary - echp "">> summary - echo "\`\`\`" >> summary - lcov --list coverage.info --rc lcov_branch_coverage=1 >> summary - echo "\`\`\`" >> summary - cat summary >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/on-commit.yml b/.github/workflows/on-commit.yml index 82d62e7e39..1262bdecce 100644 --- a/.github/workflows/on-commit.yml +++ b/.github/workflows/on-commit.yml @@ -71,12 +71,8 @@ jobs: build_samples_and_tests: needs: [validate_code_compliance, validate_compliance_with_zephyr] - uses: ./.github/workflows/common-build.yml - - run_dut_unit_tests: - needs: [build_samples_and_tests] - uses: ./.github/workflows/common_run_dut_ut.yml + uses: ./.github/workflows/common-build_and_run.yml publish_test_results: - needs: [run_dut_unit_tests] + needs: [build_samples_and_tests] uses: ./.github/workflows/publish_test_results.yml diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index 8cd355872b..d120c889e0 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -70,12 +70,8 @@ jobs: build_samples_and_tests: needs: [validate_code_compliance, validate_compliance_with_zephyr] - uses: ./.github/workflows/common-build.yml - - run_dut_unit_tests: - needs: [build_samples_and_tests] - uses: ./.github/workflows/common_run_dut_ut.yml + uses: ./.github/workflows/common-build_and_run.yml publish_test_results: - needs: [run_dut_unit_tests] + needs: [build_samples_and_tests] uses: ./.github/workflows/publish_test_results.yml diff --git a/.github/workflows/tag-action.yml b/.github/workflows/tag-action.yml index 93f679081d..db262a82e4 100644 --- a/.github/workflows/tag-action.yml +++ b/.github/workflows/tag-action.yml @@ -7,7 +7,7 @@ on: jobs: build_samples_and_tests: - uses: ./.github/workflows/common-build.yml + uses: ./.github/workflows/common-build_and_run.yml build_documentation: runs-on: ubuntu-latest diff --git a/.github/workflows/verify-new-ncs.yml b/.github/workflows/verify-new-ncs.yml index b6bb326ded..03273ab71a 100644 --- a/.github/workflows/verify-new-ncs.yml +++ b/.github/workflows/verify-new-ncs.yml @@ -6,16 +6,10 @@ on: jobs: build_samples_and_tests: - uses: ./.github/workflows/common-build.yml + uses: ./.github/workflows/common-build_and_run.yml with: change_nrf_revision: true - run_dut_unit_tests: - with: - change_nrf_revision: true - needs: [build_samples_and_tests] - uses: ./.github/workflows/common_run_dut_ut.yml - publish_test_results: - needs: [run_dut_unit_tests] + needs: [build_samples_and_tests] uses: ./.github/workflows/publish_test_results.yml