summaryrefslogtreecommitdiff
path: root/.github/workflows/build-linux-sanitizers.yml
blob: 35d053cd05c56d9293e85bf50e9967e728d0e304 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Build Linux Sanitizers

on:
  workflow_call:
    inputs:
      hamlib_branch:
        description: "Hamlib version baked into the CI image"
        required: false
        type: string
        default: "4.7.2"
      sanitizer:
        description: "Sanitizer mode: asan-ubsan or tsan"
        required: true
        type: string
      image_tag:
        description: "Immutable GHCR image tag; empty resolves the current validated generation"
        required: false
        type: string
        default: ""
      recache:
        description: "Force ccache to recompile"
        required: false
        type: boolean
        default: false
      save_ccache:
        description: "Save compiled objects for trusted builds"
        required: false
        type: boolean
        default: false
      run_tests:
        description: "Run sanitizer tests after compiling production and test targets"
        required: false
        type: boolean
        default: true
      advisory:
        description: "Allow sanitizer failures without failing the caller"
        required: false
        type: boolean
        default: false
      allow_stale_image:
        description: "Allow a previously promoted image when a dependency refresh changed the recipe"
        required: false
        type: boolean
        default: false

permissions:
  contents: read
  packages: read

jobs:
  resolve-image:
    runs-on: ubuntu-24.04
    timeout-minutes: 10
    outputs:
      image_tag: ${{ steps.resolve.outputs.image_tag }}
    steps:
      - uses: actions/checkout@v7
      - id: resolve
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          REQUESTED_TAG: ${{ inputs.image_tag }}
          RESOLVE_TSAN: ${{ inputs.sanitizer == 'tsan' }}
        shell: bash
        run: |
          if [ -n "$REQUESTED_TAG" ]; then
            IMAGE_TAG="$REQUESTED_TAG" .github/scripts/validate-ci-inputs.sh
            echo "image_tag=$REQUESTED_TAG" >> "$GITHUB_OUTPUT"
          elif [ "$RESOLVE_TSAN" = true ]; then
            RESOLVE_TSAN=true .github/scripts/resolve-linux-ci-image-tag.py
          else
            .github/scripts/resolve-linux-ci-image-tag.py
          fi

  build:
    needs: resolve-image
    name: ${{ inputs.sanitizer == 'tsan' && 'Linux x86_64 TSan' || 'Linux x86_64 ASan + UBSan' }}
    runs-on: ubuntu-24.04
    timeout-minutes: ${{ inputs.sanitizer == 'tsan' && 180 || 60 }}
    continue-on-error: ${{ inputs.advisory }}
    container:
      image: ${{ inputs.sanitizer == 'tsan' && format('ghcr.io/wsjtx/wsjtx-internal/linux-tsan-noble:{0}', needs.resolve-image.outputs.image_tag) || format('ghcr.io/wsjtx/wsjtx-internal/linux-noble:{0}', needs.resolve-image.outputs.image_tag) }}
      options: --shm-size=1g
      credentials:
        username: ${{ github.actor }}
        password: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@v7
      - name: Validate workflow inputs
        env:
          HAMLIB_BRANCH: ${{ inputs.hamlib_branch }}
          IMAGE_TAG: ${{ needs.resolve-image.outputs.image_tag }}
        run: .github/scripts/validate-ci-inputs.sh
      - uses: ./.github/actions/build-linux-sanitizers
        with:
          hamlib_branch: ${{ inputs.hamlib_branch }}
          sanitizer: ${{ inputs.sanitizer }}
          recache: ${{ inputs.recache }}
          save_ccache: ${{ inputs.save_ccache }}
          run_tests: ${{ inputs.run_tests }}
          allow_stale_image: ${{ inputs.allow_stale_image }}