|
| 1 | +name: Internal Build And Run EdsLib Validation Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - dev |
| 7 | + - main |
| 8 | + pull_request: |
| 9 | + types: |
| 10 | + - opened |
| 11 | + - reopened |
| 12 | + - synchronize |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +# Force bash to apply pipefail option so pipeline failures aren't masked |
| 16 | +defaults: |
| 17 | + run: |
| 18 | + shell: bash |
| 19 | + |
| 20 | +env: |
| 21 | + UPSTREAM_OSAL_REPO: nasa/osal |
| 22 | + UPSTREAM_OSAL_REF: main |
| 23 | + |
| 24 | +jobs: |
| 25 | + prepare-dependencies: |
| 26 | + name: Prepare Dependencies |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: Cache EdsLib Source |
| 30 | + uses: actions/cache@v3 |
| 31 | + id: cache-edslib |
| 32 | + with: |
| 33 | + path: ${{ github.workspace }}/source |
| 34 | + key: edslib-source-${{ github.sha }} |
| 35 | + |
| 36 | + - name: Cache OSAL Dependency |
| 37 | + uses: actions/cache@v3 |
| 38 | + id: cache-osal |
| 39 | + with: |
| 40 | + path: ${{ github.workspace }}/osal-staging |
| 41 | + key: edslib-dep-${{ env.UPSTREAM_OSAL_REPO }}@${{ env.UPSTREAM_OSAL_REF }} |
| 42 | + |
| 43 | + - name: Checkout EdsLib |
| 44 | + if: steps.cache-edslib.outputs.cache-hit != 'True' |
| 45 | + uses: actions/checkout@v4 |
| 46 | + with: |
| 47 | + path: source |
| 48 | + |
| 49 | + - name: Set up OSAL |
| 50 | + if: steps.cache-osal.outputs.cache-hit != 'True' |
| 51 | + uses: ./source/.github/actions/setup-osal |
| 52 | + with: |
| 53 | + staging-dir: ${GITHUB_WORKSPACE}/osal-staging |
| 54 | + upstream-repo: ${{ env.UPSTREAM_OSAL_REPO }} |
| 55 | + upstream-ref: ${{ env.UPSTREAM_OSAL_REF }} |
| 56 | + |
| 57 | + build-and-test: |
| 58 | + name: Build EdsLib and Execute Tests |
| 59 | + needs: [prepare-dependencies] |
| 60 | + runs-on: ubuntu-latest |
| 61 | + |
| 62 | + strategy: |
| 63 | + fail-fast: false |
| 64 | + matrix: |
| 65 | + buildtype: [Debug, Release] |
| 66 | + |
| 67 | + env: |
| 68 | + MATRIX_ID: matrix-${{ matrix.buildtype }} |
| 69 | + |
| 70 | + steps: |
| 71 | + |
| 72 | + - name: Install Build Dependencies |
| 73 | + run: sudo apt-get install liblua5.4-dev libpython3-dev libjson-c-dev pkg-config lcov xsltproc -y |
| 74 | + |
| 75 | + # Note - caches were updated in "prepare-dependencies" job so all three of these should be a hit |
| 76 | + - name: Retrieve Cached EdsLib Source |
| 77 | + uses: actions/cache@v3 |
| 78 | + id: restore-source |
| 79 | + with: |
| 80 | + path: ${{ github.workspace }}/source |
| 81 | + key: edslib-source-${{ github.sha }} |
| 82 | + |
| 83 | + - name: Retrieve Cached OSAL Dependency |
| 84 | + id: restore-osal |
| 85 | + uses: actions/cache@v3 |
| 86 | + with: |
| 87 | + path: ${{ github.workspace }}/osal-staging |
| 88 | + key: edslib-dep-${{ env.UPSTREAM_OSAL_REPO }}@${{ env.UPSTREAM_OSAL_REF }} |
| 89 | + |
| 90 | + # The files extracted from the cache only have owner permissions, |
| 91 | + # so in order to make this work it needs to adjust this. |
| 92 | + - name: Import OSAL |
| 93 | + run: | |
| 94 | + sudo find ${GITHUB_WORKSPACE}/osal-staging -type d -print0 | xargs -0 chmod go+rx |
| 95 | + sudo find ${GITHUB_WORKSPACE}/osal-staging -type f -print0 | xargs -0 chmod go+r |
| 96 | + sudo find ${GITHUB_WORKSPACE}/osal-staging -type f -path '*/bin/*' -print0 | xargs -0 chmod go+x |
| 97 | + sudo cp -rv -t / ${GITHUB_WORKSPACE}/osal-staging/* |
| 98 | +
|
| 99 | + - name: Refresh Dynamic Linker Cache |
| 100 | + run: sudo ldconfig |
| 101 | + |
| 102 | + - name: Set up EdsLib Build |
| 103 | + run: cmake |
| 104 | + -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} |
| 105 | + -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE |
| 106 | + -DENABLE_UNIT_TESTS=TRUE |
| 107 | + -DCMAKE_PREFIX_PATH=/usr/local/lib/cmake |
| 108 | + -S source -B ${{ env.MATRIX_ID }} |
| 109 | + |
| 110 | + - name: Build BPLib |
| 111 | + working-directory: ${{ env.MATRIX_ID }} |
| 112 | + run: make all |
| 113 | + |
| 114 | + - name: Check for Tests |
| 115 | + run: if [ -e '${{ env.MATRIX_ID }}/CTestTestfile.cmake' ]; then echo 'RUN_TESTS=True' >> $GITHUB_ENV; fi |
| 116 | + |
| 117 | + - name: Run Tests |
| 118 | + working-directory: ${{ env.MATRIX_ID }} |
| 119 | + if: env.RUN_TESTS == 'True' |
| 120 | + run: ctest --output-on-failure 2>&1 | tee ctest.log |
| 121 | + |
| 122 | + - name: Check Coverage |
| 123 | + if: env.MATRIX_ID == 'matrix-Debug' |
| 124 | + uses: ./source/.github/actions/check-coverage |
| 125 | + with: |
| 126 | + binary-dir: ${{ env.MATRIX_ID }} |
| 127 | + |
| 128 | + - name: Assemble Results |
| 129 | + run: | |
| 130 | + if [ -s '${{ env.MATRIX_ID }}/ctest.log' ]; then |
| 131 | + echo '<h2>CTest Execution</h2>' >> $GITHUB_STEP_SUMMARY |
| 132 | + echo '<pre>' >> $GITHUB_STEP_SUMMARY |
| 133 | + cat '${{ env.MATRIX_ID }}/ctest.log' >> $GITHUB_STEP_SUMMARY |
| 134 | + echo '</pre>' >> $GITHUB_STEP_SUMMARY |
| 135 | + fi |
| 136 | + if [ -s '${{ env.MATRIX_ID }}/lcov-summary.xml' ]; then |
| 137 | + cat '${{ env.MATRIX_ID }}/lcov-summary.xml' >> $GITHUB_STEP_SUMMARY |
| 138 | + fi |
0 commit comments