summaryrefslogtreecommitdiffstats
path: root/src/ci/github-actions/ci.yml
blob: 10de2e8d5eaa89f71d8f68874fed5db6696211c1 (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
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
######################################################
#   WARNING! Action needed when changing this file   #
######################################################

# Due to GitHub Actions limitations, we can't use YAML Anchors directly in the
# CI configuration stored on the repository. To work around that this file is
# expanded by a tool in the repository, and the expansion is committed as well.
#
# After you make any change to the file you'll need to run this command:
#
#   ./x.py run src/tools/expand-yaml-anchors
#
# ...and commit the file it updated in addition to this one. If you forget this
# step CI will fail.

---

###############################
#   YAML Anchors Definition   #
###############################

# This key contains most of the YAML anchors that will be used later in the
# document. YAML anchors allows us to greatly reduce duplication inside the CI
# configuration by reusing parts of the configuration.
#
# YAML anchors work by defining an anchor with `&anchor-name` and reusing its
# content in another place with `*anchor-name`. The special `<<` map key merges
# the content of the map with the content of the anchor (or list of anchors).
#
# The expand-yaml-anchors tool will automatically remove this block from the
# output YAML file.
x--expand-yaml-anchors--remove:

  - &shared-ci-variables
    CI_JOB_NAME: ${{ matrix.name }}

  - &public-variables
    SCCACHE_BUCKET: rust-lang-ci-sccache2
    TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
    CACHE_DOMAIN: ci-caches.rust-lang.org

  - &prod-variables
    SCCACHE_BUCKET: rust-lang-ci-sccache2
    DEPLOY_BUCKET: rust-lang-ci2
    TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
    TOOLSTATE_ISSUES_API_URL: https://api.github.com/repos/rust-lang/rust/issues
    TOOLSTATE_PUBLISH: 1
    # AWS_SECRET_ACCESS_KEYs are stored in GitHub's secrets storage, named
    # AWS_SECRET_ACCESS_KEY_<keyid>. Including the key id in the name allows to
    # rotate them in a single branch while keeping the old key in another
    # branch, which wouldn't be possible if the key was named with the kind
    # (caches, artifacts...).
    CACHES_AWS_ACCESS_KEY_ID: AKIA46X5W6CZI5DHEBFL
    ARTIFACTS_AWS_ACCESS_KEY_ID: AKIA46X5W6CZN24CBO55
    CACHE_DOMAIN: ci-caches.rust-lang.org

  - &dummy-variables
    SCCACHE_BUCKET: rust-lang-gha-caches
    DEPLOY_BUCKET: rust-lang-gha
    TOOLSTATE_REPO: https://github.com/pietroalbini/rust-toolstate
    TOOLSTATE_ISSUES_API_URL: https://api.github.com/repos/pietroalbini/rust-toolstate/issues
    TOOLSTATE_PUBLISH: 1
    # AWS_SECRET_ACCESS_KEYs are stored in GitHub's secrets storage, named
    # AWS_SECRET_ACCESS_KEY_<keyid>. Including the key id in the name allows to
    # rotate them in a single branch while keeping the old key in another
    # branch, which wouldn't be possible if the key was named with the kind
    # (caches, artifacts...).
    CACHES_AWS_ACCESS_KEY_ID: AKIA46X5W6CZOMUQATD5
    ARTIFACTS_AWS_ACCESS_KEY_ID: AKIA46X5W6CZH5AYXDVF
    CACHE_DOMAIN: ci-caches-gha.rust-lang.org

  - &base-job
    env: {}

  - &job-linux-xl
    os: ubuntu-20.04-xl
    <<: *base-job

  - &job-macos-xl
    os: macos-latest  # We don't have an XL builder for this
    <<: *base-job

  - &job-windows-xl
    os: windows-latest-xl
    <<: *base-job

  - &job-aarch64-linux
    os: [self-hosted, ARM64, linux]

  - &step
    if: success() && !env.SKIP_JOB

  - &base-ci-job
    timeout-minutes: 600
    runs-on: "${{ matrix.os }}"
    env: *shared-ci-variables
    steps:
      - name: disable git crlf conversion
        run: git config --global core.autocrlf false

      - name: checkout the source code
        uses: actions/checkout@v3
        with:
          fetch-depth: 2

      # Rust Log Analyzer can't currently detect the PR number of a GitHub
      # Actions build on its own, so a hint in the log message is needed to
      # point it in the right direction.
      - name: configure the PR in which the error message will be posted
        run: echo "[CI_PR_NUMBER=$num]"
        env:
          num: ${{ github.event.number }}
        if: success() && !env.SKIP_JOB && github.event_name == 'pull_request'

      - name: add extra environment variables
        run: src/ci/scripts/setup-environment.sh
        env:
          # Since it's not possible to merge `${{ matrix.env }}` with the other
          # variables in `job.<name>.env`, the variables defined in the matrix
          # are passed to the `setup-environment.sh` script encoded in JSON,
          # which then uses log commands to actually set them.
          EXTRA_VARIABLES: ${{ toJson(matrix.env) }}
        <<: *step

      - name: decide whether to skip this job
        run: src/ci/scripts/should-skip-this.sh
        <<: *step

      - name: ensure the channel matches the target branch
        run: src/ci/scripts/verify-channel.sh
        <<: *step

      - name: configure GitHub Actions to kill the build when outdated
        uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
        with:
          github_token: "${{ secrets.github_token }}"
        if: success() && !env.SKIP_JOB && github.ref != 'refs/heads/try' && github.ref != 'refs/heads/try-perf'
        <<: *step

      - name: collect CPU statistics
        run: src/ci/scripts/collect-cpu-stats.sh
        <<: *step

      - name: show the current environment
        run: src/ci/scripts/dump-environment.sh
        <<: *step

      - name: install awscli
        run: src/ci/scripts/install-awscli.sh
        <<: *step

      - name: install sccache
        run: src/ci/scripts/install-sccache.sh
        <<: *step

      - name: select Xcode
        run: src/ci/scripts/select-xcode.sh
        <<: *step

      - name: install clang
        run: src/ci/scripts/install-clang.sh
        <<: *step

      - name: install WIX
        run: src/ci/scripts/install-wix.sh
        <<: *step

      - name: disable git crlf conversion
        run: src/ci/scripts/disable-git-crlf-conversion.sh
        <<: *step

      - name: checkout submodules
        run: src/ci/scripts/checkout-submodules.sh
        <<: *step

      - name: install MSYS2
        run: src/ci/scripts/install-msys2.sh
        <<: *step

      - name: install MinGW
        run: src/ci/scripts/install-mingw.sh
        <<: *step

      - name: install ninja
        run: src/ci/scripts/install-ninja.sh
        <<: *step

      - name: enable ipv6 on Docker
        run: src/ci/scripts/enable-docker-ipv6.sh
        <<: *step

      # Disable automatic line ending conversion (again). On Windows, when we're
      # installing dependencies, something switches the git configuration directory or
      # re-enables autocrlf. We've not tracked down the exact cause -- and there may
      # be multiple -- but this should ensure submodules are checked out with the
      # appropriate line endings.
      - name: disable git crlf conversion
        run: src/ci/scripts/disable-git-crlf-conversion.sh
        <<: *step

      - name: ensure line endings are correct
        run: src/ci/scripts/verify-line-endings.sh
        <<: *step

      - name: ensure backported commits are in upstream branches
        run: src/ci/scripts/verify-backported-commits.sh
        <<: *step

      - name: ensure the stable version number is correct
        run: src/ci/scripts/verify-stable-version-number.sh
        <<: *step

      - name: run the build
        run: src/ci/scripts/run-build-from-ci.sh
        env:
          AWS_ACCESS_KEY_ID: ${{ env.CACHES_AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}
          TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}
        <<: *step

      - name: upload artifacts to S3
        run: src/ci/scripts/upload-artifacts.sh
        env:
          AWS_ACCESS_KEY_ID: ${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}
        # Adding a condition on DEPLOY=1 or DEPLOY_ALT=1 is not needed as all deploy
        # builders *should* have the AWS credentials available. Still, explicitly
        # adding the condition is helpful as this way CI will not silently skip
        # deploying artifacts from a dist builder if the variables are misconfigured,
        # erroring about invalid credentials instead.
        if: success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')
        <<: *step

  # These snippets are used by the try-success, try-failure, auto-success and auto-failure jobs.
  # Check out their documentation for more information on why they're needed.

  - &base-outcome-job
    name: bors build finished
    runs-on: ubuntu-latest

  - &base-success-job
    steps:
      - name: mark the job as a success
        run: exit 0
        shell: bash
    <<: *base-outcome-job

  - &base-failure-job
    steps:
      - name: mark the job as a failure
        run: exit 1
        shell: bash
    <<: *base-outcome-job

###########################
#   Builders definition   #
###########################

name: CI
on:
  push:
    branches:
      - auto
      - try
      - try-perf
      - master
  pull_request:
    branches:
      - "**"

permissions:
  contents: read

defaults:
  run:
    # On Linux, macOS, and Windows, use the system-provided bash as the default
    # shell. (This should only make a difference on Windows, where the default
    # shell is PowerShell.)
    shell: bash

jobs:
  pr:
    permissions:
      actions: write # for rust-lang/simpleinfra/github-actions/cancel-outdated-builds
    <<: *base-ci-job
    name: PR
    env:
      <<: [*shared-ci-variables, *public-variables]
    if: github.event_name == 'pull_request'
    strategy:
      matrix:
        include:
          - name: mingw-check
            <<: *job-linux-xl

          - name: x86_64-gnu-llvm-13
            <<: *job-linux-xl

          - name: x86_64-gnu-tools
            env:
              CI_ONLY_WHEN_SUBMODULES_CHANGED: 1
            <<: *job-linux-xl

  auto:
    permissions:
      actions: write # for rust-lang/simpleinfra/github-actions/cancel-outdated-builds
    <<: *base-ci-job
    name: auto
    env:
      <<: [*shared-ci-variables, *prod-variables]
    if: github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'
    strategy:
      matrix:
        include:
          #############################
          #   Linux/Docker builders   #
          #############################

          - name: aarch64-gnu
            <<: *job-aarch64-linux

          - name: arm-android
            <<: *job-linux-xl

          - name: armhf-gnu
            <<: *job-linux-xl

          - name: dist-aarch64-linux
            <<: *job-linux-xl

          - name: dist-android
            <<: *job-linux-xl

          - name: dist-arm-linux
            <<: *job-linux-xl

          - name: dist-armhf-linux
            <<: *job-linux-xl

          - name: dist-armv7-linux
            <<: *job-linux-xl

          - name: dist-i586-gnu-i586-i686-musl
            <<: *job-linux-xl

          - name: dist-i686-linux
            <<: *job-linux-xl

          - name: dist-mips-linux
            <<: *job-linux-xl

          - name: dist-mips64-linux
            <<: *job-linux-xl

          - name: dist-mips64el-linux
            <<: *job-linux-xl

          - name: dist-mipsel-linux
            <<: *job-linux-xl

          - name: dist-powerpc-linux
            <<: *job-linux-xl

          - name: dist-powerpc64-linux
            <<: *job-linux-xl

          - name: dist-powerpc64le-linux
            <<: *job-linux-xl

          - name: dist-riscv64-linux
            <<: *job-linux-xl

          - name: dist-s390x-linux
            <<: *job-linux-xl

          - name: dist-various-1
            <<: *job-linux-xl

          - name: dist-various-2
            <<: *job-linux-xl

          - name: dist-x86_64-freebsd
            <<: *job-linux-xl

          - name: dist-x86_64-illumos
            <<: *job-linux-xl

          - &dist-x86_64-linux
            name: dist-x86_64-linux
            <<: *job-linux-xl

          - name: dist-x86_64-linux-alt
            env:
              IMAGE: dist-x86_64-linux
            <<: *job-linux-xl

          - name: dist-x86_64-musl
            <<: *job-linux-xl

          - name: dist-x86_64-netbsd
            <<: *job-linux-xl

          - name: i686-gnu
            <<: *job-linux-xl

          - name: i686-gnu-nopt
            <<: *job-linux-xl

          - name: mingw-check
            <<: *job-linux-xl

          - name: test-various
            <<: *job-linux-xl

          - name: wasm32
            <<: *job-linux-xl

          - name: x86_64-gnu
            <<: *job-linux-xl

          # This job ensures commits landing on nightly still pass the full
          # test suite on the stable channel. There are some UI tests that
          # depend on the channel being built (for example if they include the
          # channel name on the output), and this builder prevents landing
          # changes that would result in broken builds after a promotion.
          - name: x86_64-gnu-stable
            env:
              IMAGE: x86_64-gnu
              RUST_CI_OVERRIDE_RELEASE_CHANNEL: stable
              # Only run this job on the nightly channel. Running this on beta
              # could cause failures when `dev: 1` in `stage0.txt`, and running
              # this on stable is useless.
              CI_ONLY_WHEN_CHANNEL: nightly
            <<: *job-linux-xl

          - name: x86_64-gnu-aux
            <<: *job-linux-xl

          - name: x86_64-gnu-debug
            <<: *job-linux-xl

          - name: x86_64-gnu-distcheck
            <<: *job-linux-xl

          - name: x86_64-gnu-llvm-13
            env:
              RUST_BACKTRACE: 1
            <<: *job-linux-xl

          - name: x86_64-gnu-llvm-13-stage1
            env:
              RUST_BACKTRACE: 1
            <<: *job-linux-xl

          - name: x86_64-gnu-nopt
            <<: *job-linux-xl

          - name: x86_64-gnu-tools
            env:
              DEPLOY_TOOLSTATES_JSON: toolstates-linux.json
            <<: *job-linux-xl

          ####################
          #  macOS Builders  #
          ####################

          - name: dist-x86_64-apple
            env:
              SCRIPT: ./x.py dist bootstrap --include-default-paths --host=x86_64-apple-darwin --target=x86_64-apple-darwin
              RUST_CONFIGURE_ARGS: --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false
              RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
              MACOSX_DEPLOYMENT_TARGET: 10.7
              SELECT_XCODE: /Applications/Xcode_13.4.1.app
              NO_LLVM_ASSERTIONS: 1
              NO_DEBUG_ASSERTIONS: 1
              NO_OVERFLOW_CHECKS: 1
              DIST_REQUIRE_ALL_TOOLS: 1
            <<: *job-macos-xl

          - name: dist-apple-various
            env:
              SCRIPT: ./x.py dist bootstrap --include-default-paths --host='' --target=aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim
              RUST_CONFIGURE_ARGS: --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false
              RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
              MACOSX_DEPLOYMENT_TARGET: 10.7
              SELECT_XCODE: /Applications/Xcode_13.4.1.app
              NO_LLVM_ASSERTIONS: 1
              NO_DEBUG_ASSERTIONS: 1
              NO_OVERFLOW_CHECKS: 1
            <<: *job-macos-xl

          - name: dist-x86_64-apple-alt
            env:
              SCRIPT: ./x.py dist bootstrap --include-default-paths
              RUST_CONFIGURE_ARGS: --enable-extended --enable-profiler --set rust.jemalloc --set llvm.ninja=false
              RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
              MACOSX_DEPLOYMENT_TARGET: 10.7
              SELECT_XCODE: /Applications/Xcode_13.4.1.app
              NO_LLVM_ASSERTIONS: 1
              NO_DEBUG_ASSERTIONS: 1
              NO_OVERFLOW_CHECKS: 1
            <<: *job-macos-xl

          - name: x86_64-apple-1
            env: &env-x86_64-apple-tests
              SCRIPT: ./x.py --stage 2 test --exclude src/test/ui --exclude src/test/rustdoc --exclude src/test/run-make-fulldeps
              RUST_CONFIGURE_ARGS: --build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false
              RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
              MACOSX_DEPLOYMENT_TARGET: 10.8
              MACOSX_STD_DEPLOYMENT_TARGET: 10.7
              NO_LLVM_ASSERTIONS: 1
              NO_DEBUG_ASSERTIONS: 1
              NO_OVERFLOW_CHECKS: 1
            <<: *job-macos-xl

          - name: x86_64-apple-2
            env:
              SCRIPT: ./x.py --stage 2 test src/test/ui src/test/rustdoc src/test/run-make-fulldeps
              <<: *env-x86_64-apple-tests
            <<: *job-macos-xl

          # This target only needs to support 11.0 and up as nothing else supports the hardware
          - name: dist-aarch64-apple
            env:
              SCRIPT: ./x.py dist bootstrap --include-default-paths --stage 2
              RUST_CONFIGURE_ARGS: >-
                --build=x86_64-apple-darwin
                --host=aarch64-apple-darwin
                --target=aarch64-apple-darwin
                --enable-full-tools
                --enable-sanitizers
                --enable-profiler
                --disable-docs
                --set rust.jemalloc
                --set llvm.ninja=false
              RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
              SELECT_XCODE: /Applications/Xcode_13.4.1.app
              USE_XCODE_CLANG: 1
              MACOSX_DEPLOYMENT_TARGET: 11.0
              MACOSX_STD_DEPLOYMENT_TARGET: 11.0
              NO_LLVM_ASSERTIONS: 1
              NO_DEBUG_ASSERTIONS: 1
              NO_OVERFLOW_CHECKS: 1
              DIST_REQUIRE_ALL_TOOLS: 1
              # Corresponds to 16K page size
              #
              # Shouldn't be needed if jemalloc-sys is updated to
              # handle this platform like iOS or if we build on
              # aarch64-apple-darwin itself.
              #
              # https://github.com/gnzlbg/jemallocator/blob/c27a859e98e3cb790dc269773d9da71a1e918458/jemalloc-sys/build.rs#L237
              JEMALLOC_SYS_WITH_LG_PAGE: 14
            <<: *job-macos-xl

          ######################
          #  Windows Builders  #
          ######################

          - name: x86_64-msvc-1
            env:
              RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-profiler
              SCRIPT: make ci-subset-1
            <<: *job-windows-xl

          - name: x86_64-msvc-2
            env:
              RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-profiler
              SCRIPT: make ci-subset-2
            <<: *job-windows-xl

          - name: i686-msvc-1
            env:
              RUST_CONFIGURE_ARGS: --build=i686-pc-windows-msvc
              SCRIPT: make ci-subset-1
            <<: *job-windows-xl

          - name: i686-msvc-2
            env:
              RUST_CONFIGURE_ARGS: --build=i686-pc-windows-msvc
              SCRIPT: make ci-subset-2
            <<: *job-windows-xl

          - name: x86_64-msvc-cargo
            env:
              SCRIPT: python x.py --stage 2 test src/tools/cargotest src/tools/cargo
              RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-lld
            <<: *job-windows-xl

          - name: x86_64-msvc-tools
            env:
              SCRIPT: src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh x.py /tmp/toolstate/toolstates.json windows
              RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --save-toolstates=/tmp/toolstate/toolstates.json
              DEPLOY_TOOLSTATES_JSON: toolstates-windows.json
            <<: *job-windows-xl

          # 32/64-bit MinGW builds.
          #
          # We are using MinGW with POSIX threads since LLVM requires
          # C++'s std::thread which is disabled in libstdc++ with win32 threads.
          # FIXME: Libc++ doesn't have this limitation so we can avoid
          # winpthreads if we switch to it.
          #
          # Instead of relying on the MinGW version installed on CI we download
          # and install one ourselves so we won't be surprised by changes to CI's
          # build image.
          #
          # Finally, note that the downloads below are all in the `rust-lang-ci` S3
          # bucket, but they clearly didn't originate there! The downloads originally
          # came from the mingw-w64 SourceForge download site. Unfortunately
          # SourceForge is notoriously flaky, so we mirror it on our own infrastructure.

          - name: i686-mingw-1
            env:
              RUST_CONFIGURE_ARGS: >-
                --build=i686-pc-windows-gnu
                --set llvm.allow-old-toolchain
              SCRIPT: make ci-mingw-subset-1
              # We are intentionally allowing an old toolchain on this builder (and that's
              # incompatible with LLVM downloads today).
              NO_DOWNLOAD_CI_LLVM: 1
              CUSTOM_MINGW: 1
            <<: *job-windows-xl

          - name: i686-mingw-2
            env:
              RUST_CONFIGURE_ARGS: >-
                --build=i686-pc-windows-gnu
                --set llvm.allow-old-toolchain
              SCRIPT: make ci-mingw-subset-2
              # We are intentionally allowing an old toolchain on this builder (and that's
              # incompatible with LLVM downloads today).
              NO_DOWNLOAD_CI_LLVM: 1
              CUSTOM_MINGW: 1
            <<: *job-windows-xl

          - name: x86_64-mingw-1
            env:
              SCRIPT: make ci-mingw-subset-1
              RUST_CONFIGURE_ARGS: >-
                --build=x86_64-pc-windows-gnu
                --enable-profiler
                --set llvm.allow-old-toolchain
              # We are intentionally allowing an old toolchain on this builder (and that's
              # incompatible with LLVM downloads today).
              NO_DOWNLOAD_CI_LLVM: 1
              CUSTOM_MINGW: 1
            <<: *job-windows-xl

          - name: x86_64-mingw-2
            env:
              SCRIPT: make ci-mingw-subset-2
              RUST_CONFIGURE_ARGS: >-
                --build=x86_64-pc-windows-gnu
                --enable-profiler
                --set llvm.allow-old-toolchain
              # We are intentionally allowing an old toolchain on this builder (and that's
              # incompatible with LLVM downloads today).
              NO_DOWNLOAD_CI_LLVM: 1
              CUSTOM_MINGW: 1
            <<: *job-windows-xl

          - name: dist-x86_64-msvc
            env:
              RUST_CONFIGURE_ARGS: >-
                --build=x86_64-pc-windows-msvc
                --host=x86_64-pc-windows-msvc
                --target=x86_64-pc-windows-msvc
                --enable-full-tools
                --enable-profiler
              SCRIPT: PGO_HOST=x86_64-pc-windows-msvc src/ci/pgo.sh python x.py dist bootstrap --include-default-paths
              DIST_REQUIRE_ALL_TOOLS: 1
            <<: *job-windows-xl

          - name: dist-i686-msvc
            env:
              RUST_CONFIGURE_ARGS: >-
                --build=i686-pc-windows-msvc
                --host=i686-pc-windows-msvc
                --target=i686-pc-windows-msvc,i586-pc-windows-msvc
                --enable-full-tools
                --enable-profiler
              SCRIPT: python x.py dist bootstrap --include-default-paths
              DIST_REQUIRE_ALL_TOOLS: 1
            <<: *job-windows-xl

          - name: dist-aarch64-msvc
            env:
              RUST_CONFIGURE_ARGS: >-
                --build=x86_64-pc-windows-msvc
                --host=aarch64-pc-windows-msvc
                --enable-full-tools
                --enable-profiler
              SCRIPT: python x.py dist bootstrap --include-default-paths
              DIST_REQUIRE_ALL_TOOLS: 1
              # Hack around this SDK version, because it doesn't work with clang.
              # See https://github.com/rust-lang/rust/issues/88796
              WINDOWS_SDK_20348_HACK: 1
            <<: *job-windows-xl

          - name: dist-i686-mingw
            env:
              RUST_CONFIGURE_ARGS: >-
                --build=i686-pc-windows-gnu
                --enable-full-tools
                --enable-profiler
                --set llvm.allow-old-toolchain
              # We are intentionally allowing an old toolchain on this builder (and that's
              # incompatible with LLVM downloads today).
              NO_DOWNLOAD_CI_LLVM: 1
              SCRIPT: python x.py dist bootstrap --include-default-paths
              CUSTOM_MINGW: 1
              DIST_REQUIRE_ALL_TOOLS: 1
            <<: *job-windows-xl

          - name: dist-x86_64-mingw
            env:
              SCRIPT: python x.py dist bootstrap --include-default-paths
              RUST_CONFIGURE_ARGS: >-
                --build=x86_64-pc-windows-gnu
                --enable-full-tools
                --enable-profiler
                --set llvm.allow-old-toolchain
              # We are intentionally allowing an old toolchain on this builder (and that's
              # incompatible with LLVM downloads today).
              NO_DOWNLOAD_CI_LLVM: 1
              CUSTOM_MINGW: 1
              DIST_REQUIRE_ALL_TOOLS: 1
            <<: *job-windows-xl

          - name: dist-x86_64-msvc-alt
            env:
              RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-extended --enable-profiler
              SCRIPT: python x.py dist bootstrap --include-default-paths
            <<: *job-windows-xl

  try:
    permissions:
      actions: write # for rust-lang/simpleinfra/github-actions/cancel-outdated-builds
    <<: *base-ci-job
    name: try
    env:
      <<: [*shared-ci-variables, *prod-variables]
    if: github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'
    strategy:
      matrix:
        include:
          - &dist-x86_64-linux
            name: dist-x86_64-linux
            <<: *job-linux-xl

  master:
    name: master
    runs-on: ubuntu-latest
    env:
      <<: [*prod-variables]
    if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'rust-lang-ci/rust'
    steps:
      - name: checkout the source code
        uses: actions/checkout@v3
        with:
          fetch-depth: 2

      - name: publish toolstate
        run: src/ci/publish_toolstate.sh
        shell: bash
        env:
          TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}
        <<: *step

  # These jobs don't actually test anything, but they're used to tell bors the
  # build completed, as there is no practical way to detect when a workflow is
  # successful listening to webhooks only.
  try-success:
    needs: [try]
    if: "success() && github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'"
    <<: *base-success-job
  try-failure:
    needs: [try]
    if: "!success() && github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'"
    <<: *base-failure-job
  auto-success:
    needs: [auto]
    if: "success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
    <<: *base-success-job
  auto-failure:
    needs: [auto]
    if: "!success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
    <<: *base-failure-job