|
| 1 | +name: build-and-test-packages-above-differential |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + container: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + runner: |
| 10 | + default: ubuntu-24.04 |
| 11 | + required: false |
| 12 | + type: string |
| 13 | + rosdistro: |
| 14 | + default: humble |
| 15 | + required: false |
| 16 | + type: string |
| 17 | + run-condition: |
| 18 | + default: true |
| 19 | + required: false |
| 20 | + type: boolean |
| 21 | + container-suffix: |
| 22 | + required: false |
| 23 | + default: "" |
| 24 | + type: string |
| 25 | + build-pre-command: |
| 26 | + required: false |
| 27 | + default: "" |
| 28 | + type: string |
| 29 | + secrets: |
| 30 | + codecov-token: |
| 31 | + required: true |
| 32 | + |
| 33 | +env: |
| 34 | + CC: /usr/lib/ccache/gcc |
| 35 | + CXX: /usr/lib/ccache/g++ |
| 36 | + |
| 37 | +jobs: |
| 38 | + build-and-test-packages-above-differential: |
| 39 | + if: ${{ inputs.run-condition }} |
| 40 | + runs-on: ${{ inputs.runner }} |
| 41 | + container: ${{ inputs.container }}${{ inputs.container-suffix }} |
| 42 | + steps: |
| 43 | + - name: Set PR fetch depth |
| 44 | + run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}" |
| 45 | + shell: bash |
| 46 | + |
| 47 | + - name: Checkout PR branch and all PR commits |
| 48 | + uses: actions/checkout@v4 |
| 49 | + with: |
| 50 | + ref: ${{ github.event.pull_request.head.sha }} |
| 51 | + fetch-depth: ${{ env.PR_FETCH_DEPTH }} |
| 52 | + |
| 53 | + - name: Show disk space before the tasks |
| 54 | + run: df -h |
| 55 | + shell: bash |
| 56 | + |
| 57 | + - name: Show machine specs |
| 58 | + run: lscpu && free -h |
| 59 | + shell: bash |
| 60 | + |
| 61 | + - name: Remove exec_depend |
| 62 | + uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1 |
| 63 | + |
| 64 | + - name: Get modified packages |
| 65 | + id: get-modified-packages |
| 66 | + uses: autowarefoundation/autoware-github-actions/get-modified-packages@v1 |
| 67 | + |
| 68 | + - name: Create ccache directory |
| 69 | + run: | |
| 70 | + mkdir -p ${CCACHE_DIR} |
| 71 | + du -sh ${CCACHE_DIR} && ccache -s |
| 72 | + shell: bash |
| 73 | + |
| 74 | + - name: Attempt to restore ccache |
| 75 | + uses: actions/cache/restore@v4 |
| 76 | + with: |
| 77 | + path: | |
| 78 | + /root/.ccache |
| 79 | + key: ccache-main-${{ runner.arch }}-${{ inputs.rosdistro }}-${{ github.event.pull_request.base.sha }} |
| 80 | + restore-keys: | |
| 81 | + ccache-main-${{ runner.arch }}-${{ inputs.rosdistro }}- |
| 82 | +
|
| 83 | + - name: Show ccache stats before build and reset stats |
| 84 | + run: | |
| 85 | + du -sh ${CCACHE_DIR} && ccache -s |
| 86 | + ccache --zero-stats |
| 87 | + shell: bash |
| 88 | + |
| 89 | + - name: Export CUDA state as a variable for adding to cache key |
| 90 | + run: | |
| 91 | + build_type_cuda_state=nocuda |
| 92 | + if [[ "${{ inputs.container-suffix }}" == "-cuda" ]]; then |
| 93 | + build_type_cuda_state=cuda |
| 94 | + fi |
| 95 | + echo "BUILD_TYPE_CUDA_STATE=$build_type_cuda_state" >> "${GITHUB_ENV}" |
| 96 | + echo "::notice::BUILD_TYPE_CUDA_STATE=$build_type_cuda_state" |
| 97 | + shell: bash |
| 98 | + |
| 99 | + - name: Prepare build_depends.repos file (main branch) |
| 100 | + if: ${{ github.event.pull_request.base.ref == 'main' }} |
| 101 | + uses: ./.github/actions/combine-repos-action |
| 102 | + with: |
| 103 | + base_file: build_depends_humble.repos |
| 104 | + overlay_file: build_depends_nightly.repos |
| 105 | + output_file: build_depends.repos |
| 106 | + |
| 107 | + - name: Prepare build_depends.repos file (humble branch) |
| 108 | + if: ${{ github.event.pull_request.base.ref == 'humble' }} |
| 109 | + run: cp build_depends_humble.repos build_depends.repos |
| 110 | + shell: bash |
| 111 | + |
| 112 | + - name: Build |
| 113 | + if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }} |
| 114 | + uses: autowarefoundation/autoware-github-actions/colcon-build@v1 |
| 115 | + with: |
| 116 | + rosdistro: ${{ inputs.rosdistro }} |
| 117 | + target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }} |
| 118 | + build-depends-repos: build_depends.repos |
| 119 | + packages-above-repos: packages_above.repos |
| 120 | + cache-key-element: ${{ env.BUILD_TYPE_CUDA_STATE }} |
| 121 | + build-pre-command: ${{ inputs.build-pre-command }} |
| 122 | + |
| 123 | + - name: Show ccache stats after build |
| 124 | + run: du -sh ${CCACHE_DIR} && ccache -s |
| 125 | + shell: bash |
| 126 | + |
| 127 | + - name: Test |
| 128 | + id: test |
| 129 | + if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }} |
| 130 | + uses: autowarefoundation/autoware-github-actions/colcon-test@v1 |
| 131 | + with: |
| 132 | + rosdistro: ${{ inputs.rosdistro }} |
| 133 | + target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }} |
| 134 | + build-depends-repos: build_depends.repos |
| 135 | + packages-above-repos: packages_above.repos |
| 136 | + |
| 137 | + - name: Upload coverage to CodeCov |
| 138 | + if: ${{ steps.test.outputs.coverage-report-files != '' }} |
| 139 | + uses: codecov/codecov-action@v4 |
| 140 | + with: |
| 141 | + files: ${{ steps.test.outputs.coverage-report-files }} |
| 142 | + fail_ci_if_error: false |
| 143 | + verbose: true |
| 144 | + flags: differential${{ inputs.container-suffix }} |
| 145 | + token: ${{ secrets.codecov-token }} |
| 146 | + |
| 147 | + - name: Show disk space after the tasks |
| 148 | + run: df -h |
| 149 | + shell: bash |
0 commit comments