|
| 1 | +name: Reusable Undefined Behavior Sanitizer |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + config_hash: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + |
| 10 | +env: |
| 11 | + FORCE_COLOR: 1 |
| 12 | + |
| 13 | +jobs: |
| 14 | + build-ubsan-reusable: |
| 15 | + name: 'Undefined behavior sanitizer' |
| 16 | + runs-on: ubuntu-24.04 |
| 17 | + timeout-minutes: 60 |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + persist-credentials: false |
| 22 | + - name: Runner image version |
| 23 | + run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV" |
| 24 | + - name: Restore config.cache |
| 25 | + uses: actions/cache@v4 |
| 26 | + with: |
| 27 | + path: config.cache |
| 28 | + key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ inputs.config_hash }} |
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + sudo ./.github/workflows/posix-deps-apt.sh |
| 32 | + # Install clang-20 |
| 33 | + wget https://apt.llvm.org/llvm.sh |
| 34 | + chmod +x llvm.sh |
| 35 | + sudo ./llvm.sh 20 |
| 36 | + - name: UBSAN option setup |
| 37 | + run: | |
| 38 | + echo "UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1" >> "$GITHUB_ENV" |
| 39 | + echo "CC=clang" >> "$GITHUB_ENV" |
| 40 | + echo "CXX=clang++" >> "$GITHUB_ENV" |
| 41 | + - name: Add ccache to PATH |
| 42 | + run: | |
| 43 | + echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV" |
| 44 | + - name: Configure ccache action |
| 45 | + uses: hendrikmuhs/[email protected] |
| 46 | + with: |
| 47 | + save: ${{ github.event_name == 'push' }} |
| 48 | + max-size: "200M" |
| 49 | + - name: Configure CPython |
| 50 | + run: >- |
| 51 | + ./configure |
| 52 | + --config-cache |
| 53 | + --with-undefined-behavior-sanitizer |
| 54 | + --with-pydebug |
| 55 | + - name: Set up UBSAN log after configuration |
| 56 | + run: | |
| 57 | + echo "UBSAN_OPTIONS=${UBSAN_OPTIONS}:log_path=${GITHUB_WORKSPACE}/ubsan_log" >> "$GITHUB_ENV" |
| 58 | + - name: Build CPython |
| 59 | + run: make -j4 |
| 60 | + - name: Display build info |
| 61 | + run: make pythoninfo |
| 62 | + - name: Tests |
| 63 | + run: ./python -m test -j4 |
| 64 | + - name: Display UBSAN logs |
| 65 | + if: always() |
| 66 | + run: find "${GITHUB_WORKSPACE}" -name 'ubsan_log.*' | xargs head -n 1000 |
| 67 | + - name: Archive UBSAN logs |
| 68 | + if: always() |
| 69 | + uses: actions/upload-artifact@v4 |
| 70 | + with: |
| 71 | + name: >- |
| 72 | + ubsan-logs |
| 73 | + path: ubsan_log.* |
| 74 | + if-no-files-found: ignore |
0 commit comments