aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/linux.yml
blob: 033f9795a237dfed1644211da626c7b27314937a (plain) (blame)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
name: Linux
on:
  workflow_call:
    inputs:
      profile:
        required: false
        default: "release"
        type: string
      wpt-args:
        default: ""
        required: false
        type: string
      wpt-sync-from-upstream:
        required: false
        default: false
        type: boolean
      wpt:
        required: false
        type: boolean
      number-of-wpt-chunks:
        default: 20
        required: false
        type: number
      unit-tests:
        required: false
        default: false
        type: boolean
      build-libservo:
        required: false
        default: false
        type: boolean
      upload:
        required: false
        default: false
        type: boolean
      github-release-id:
        required: false
        type: string
      force-github-hosted-runner:
        required: false
        type: boolean
        default: false
      bencher:
        required: false
        default: false
        type: boolean
  workflow_dispatch:
    inputs:
      profile:
        required: false
        default: "release"
        type: choice
        options: ["release", "debug", "production"]
      wpt-args:
        default: ""
        required: false
        type: string
      wpt-sync-from-upstream:
        default: false
        required: false
        type: boolean
      wpt:
        required: false
        type: boolean
      number-of-wpt-chunks:
        default: 20
        required: false
        type: number
      unit-tests:
        required: false
        default: false
        type: boolean
      build-libservo:
        required: false
        default: false
        type: boolean
      upload:
        required: false
        default: false
        type: boolean
      force-github-hosted-runner:
        required: false
        type: boolean
        default: false
      bencher:
        required: false
        default: false
        type: boolean

env:
  RUST_BACKTRACE: 1
  SHELL: /bin/bash

jobs:
  # Runs the underlying job (“workload”) on a self-hosted runner if available,
  # with the help of a `runner-select` job and a `runner-timeout` job.
  runner-select:
    uses: ./.github/workflows/self-hosted-runner-select.yml
    secrets: inherit
    with:
      # Before updating the GH action runner image for the nightly job, ensure
      # that the system has a glibc version that is compatible with the one
      # used by the wpt.fyi runners.
      github-hosted-runner-label: ubuntu-22.04
      self-hosted-image-name: servo-ubuntu2204
      force-github-hosted-runner: ${{ inputs.upload || inputs.force-github-hosted-runner }}
  runner-timeout:
    needs:
      - runner-select
    uses: ./.github/workflows/self-hosted-runner-timeout.yml
    secrets: inherit
    with:
      unique-id: ${{ needs.runner-select.outputs.unique-id }}
      is-self-hosted: ${{ fromJSON(needs.runner-select.outputs.is-self-hosted) }}

  build:
    needs:
      - runner-select
    name: Linux Build [${{ needs.runner-select.outputs.unique-id }}]
    runs-on: ${{ needs.runner-select.outputs.selected-runner-label }}
    steps:
      - uses: actions/checkout@v4
        if: ${{ runner.environment != 'self-hosted' && github.event_name != 'pull_request_target' }}
      # This is necessary to checkout the pull request if this run was triggered via a
      # `pull_request_target` event.
      - uses: actions/checkout@v4
        if: ${{ runner.environment != 'self-hosted' && github.event_name == 'pull_request_target' }}
        with:
          ref: ${{ github.event.pull_request.head.sha }}

      # Faster checkout for self-hosted runner that uses prebaked repo.
      - if: ${{ runner.environment == 'self-hosted' && github.event_name != 'pull_request_target' }}
        run: git fetch --depth=1 origin $GITHUB_SHA
      - if: ${{ runner.environment == 'self-hosted' && github.event_name == 'pull_request_target' }}
        run: git fetch --depth=1 origin ${{ github.event.pull_request.head.sha }}
      - if: ${{ runner.environment == 'self-hosted' }}
        # Same as `git switch --detach FETCH_HEAD`, but fixes up dirty working
        # trees, in case the runner image was baked with a dirty working tree.
        run: |
          git switch --detach
          git reset --hard FETCH_HEAD
      - name: Free Disk Space (Ubuntu)
        uses: jlumbroso/free-disk-space@main
        if: ${{ runner.environment != 'self-hosted' }}
        with:
          tool-cache: false
          large-packages: false
          swap-storage: false
      - name: Set LIBCLANG_PATH env # needed for bindgen in mozangle
        if: ${{ runner.environment != 'self-hosted' }}
        run: echo "LIBCLANG_PATH=/usr/lib/llvm-14/lib" >> $GITHUB_ENV
      - name: Setup Python
        if: ${{ runner.environment != 'self-hosted' }}
        uses: ./.github/actions/setup-python
      - name: Bootstrap dependencies
        if: ${{ runner.environment != 'self-hosted' }}
        run: |
          sudo apt update
          ./mach bootstrap --skip-lints

      # Always install crown, even on self-hosted runners, because it is tightly
      # coupled to the rustc version, and we may have the wrong version if the
      # commit we are building uses a different rustc version.
      - name: Install crown
        run: cargo install --path support/crown

      - name: Build (${{ inputs.profile }})
        run: |
          ./mach build --use-crown --locked --${{ inputs.profile }}
          cp -r target/cargo-timings target/cargo-timings-linux
      - name: Smoketest
        run: xvfb-run ./mach smoketest --${{ inputs.profile  }}
      - name: Script tests
        run: ./mach test-scripts
      - name: Unit tests
        if: ${{ inputs.unit-tests }}
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 20
          max_attempts: 2 # https://github.com/servo/servo/issues/30683
          command: ./mach test-unit --${{ inputs.profile }}
      - name: Build libservo with examples
        if: ${{ inputs.build-libservo }}
        continue-on-error: true
        run: cargo build -p libservo --all-targets
      - name: Archive build timing
        uses: actions/upload-artifact@v4
        with:
          name: cargo-timings-linux-${{ inputs.profile }}
          # Using a wildcard here ensures that the archive includes the path.
          path: target/cargo-timings-*
      - name: Build mach package
        run: ./mach package --${{ inputs.profile }}
      - name: Upload artifact for mach package
        uses: actions/upload-artifact@v4
        with:
          name: linux-${{ inputs.profile }}
          path: target/${{ inputs.profile }}/servo-tech-demo.tar.gz
      - name: Upload nightly
        if: ${{ inputs.upload }}
        run: |
          ./mach upload-nightly linux \
            --secret-from-environment \
            --github-release-id ${{ inputs.github-release-id }}
        env:
          S3_UPLOAD_CREDENTIALS: ${{ secrets.S3_UPLOAD_CREDENTIALS }}
          NIGHTLY_REPO_TOKEN: ${{ secrets.NIGHTLY_REPO_TOKEN }}
          NIGHTLY_REPO: ${{ github.repository_owner }}/servo-nightly-builds
      - name: Build package for target
        run: tar -czf target.tar.gz target/${{ inputs.profile }}/servo resources
      - name: Upload artifact for target
        uses: actions/upload-artifact@v4
        with:
          name: ${{ inputs.profile }}-binary-linux
          path: target.tar.gz

  wpt-2020:
    if: ${{ inputs.wpt }}
    name: Linux WPT
    needs: ["build"]
    uses: ./.github/workflows/linux-wpt.yml
    with:
      wpt-args: ${{ inputs.wpt-args }}
      profile: ${{ inputs.profile }}
      wpt-sync-from-upstream: ${{ inputs.wpt-sync-from-upstream }}
      number-of-wpt-chunks: ${{ inputs. number-of-wpt-chunks }}
    secrets: inherit

  bencher:
    needs: ["build"]
    if: ${{ inputs.bencher && inputs.profile != 'debug' && github.event_name != 'workflow_dispatch' && github.event_name != 'merge_group' }}
    uses: ./.github/workflows/bencher.yml
    with:
      target: 'linux'
      profile: ${{ inputs.profile }}
      compressed-file-path: ${{ inputs.profile }}-binary-linux/target.tar.gz
      binary-path: target/${{ inputs.profile }}/servo
      file-size: true
      # We only evaluate speedometer and dromaeo score in release
      speedometer: ${{ inputs.profile == 'release' }}
      dromaeo: ${{ inputs.profile == 'release' }}
    secrets: inherit