summary refs log tree commit diff
path: root/src/tools/miri/.github/workflows/ci.yml
blob: 138a69974e14472d36c499d5e0a5883597876d26 (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
name: CI

on:
  push:
    # Run in PRs and for bors, but not on master.
    branches:
      - 'auto'
      - 'try'
  pull_request:
    branches:
      - 'master'
  schedule:
    - cron: '6 6 * * *' # At 6:06 UTC every day.

env:
  CARGO_UNSTABLE_SPARSE_REGISTRY: 'true'

jobs:
  build:
    runs-on: ${{ matrix.os }}
    env:
      RUST_BACKTRACE: 1
      HOST_TARGET: ${{ matrix.host_target }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            host_target: x86_64-unknown-linux-gnu
          - os: macos-latest
            host_target: x86_64-apple-darwin
          - os: windows-latest
            host_target: i686-pc-windows-msvc
    steps:
      - uses: actions/checkout@v3

      - name: Set the tag GC interval to 1 on linux
        if: runner.os == 'Linux'
        run: echo "MIRIFLAGS=-Zmiri-tag-gc=1" >> $GITHUB_ENV

      # Cache the global cargo directory, but NOT the local `target` directory which
      # we cannot reuse anyway when the nightly changes (and it grows quite large
      # over time).
      - name: Add cache for cargo
        id: cache
        uses: actions/cache@v3
        with:
          path: |
            # Taken from <https://doc.rust-lang.org/nightly/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci>.
            ~/.cargo/bin
            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            ~/.cargo/git/db
            # contains package information of crates installed via `cargo install`.
            ~/.cargo/.crates.toml
            ~/.cargo/.crates2.json
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: ${{ runner.os }}-cargo

      - name: Install rustup-toolchain-install-master
        if: ${{ steps.cache.outputs.cache-hit != 'true' }}
        shell: bash
        run: |
          cargo install -f rustup-toolchain-install-master

      - name: Install "master" toolchain
        shell: bash
        run: |
          if [[ ${{ github.event_name }} == 'schedule' ]]; then
            echo "Building against latest rustc git version"
            git ls-remote https://github.com/rust-lang/rust/ HEAD | cut -f 1 > rust-version
          fi
          ./miri toolchain --host ${{ matrix.host_target }}

      - name: Show Rust version
        run: |
          rustup show
          rustc -Vv
          cargo -V

      - name: Test
        run: bash ./ci.sh

  style:
    name: style checks
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      # This is exactly duplicated from above. GHA is pretty terrible when it comes
      # to avoiding code duplication.

      # Cache the global cargo directory, but NOT the local `target` directory which
      # we cannot reuse anyway when the nightly changes (and it grows quite large
      # over time).
      - name: Add cache for cargo
        id: cache
        uses: actions/cache@v3
        with:
          path: |
            # Taken from <https://doc.rust-lang.org/nightly/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci>.
            ~/.cargo/bin
            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            ~/.cargo/git/db
            # contains package information of crates installed via `cargo install`.
            ~/.cargo/.crates.toml
            ~/.cargo/.crates2.json
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: ${{ runner.os }}-cargo

      - name: Install rustup-toolchain-install-master
        if: ${{ steps.cache.outputs.cache-hit != 'true' }}
        shell: bash
        run: |
          cargo install -f rustup-toolchain-install-master

      - name: Install "master" toolchain
        shell: bash
        run: |
          ./miri toolchain

      - name: Show Rust version
        run: |
          rustup show
          rustc -Vv
          cargo -V

      - name: rustfmt
        run: ./miri fmt --check
      - name: clippy
        run: ./miri clippy -- -D warnings
      - name: rustdoc
        run: RUSTDOCFLAGS="-Dwarnings" cargo doc --document-private-items

  # These jobs doesn't actually test anything, but they're only used to tell
  # bors the build completed, as there is no practical way to detect when a
  # workflow is successful listening to webhooks only.
  #
  # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
  # (`fmt` is deliberately not listed, we want bors to ignore it.)
  end-success:
    name: bors build finished
    runs-on: ubuntu-latest
    needs: [build, style]
    if: github.event.pusher.name == 'bors' && success()
    steps:
      - name: mark the job as a success
        run: exit 0
  end-failure:
    name: bors build finished
    runs-on: ubuntu-latest
    needs: [build, style]
    if: github.event.pusher.name == 'bors' && (failure() || cancelled())
    steps:
      - name: mark the job as a failure
        run: exit 1

  # Send a Zulip notification when a cron job fails
  cron-fail-notify:
    name: cronjob failure notification
    runs-on: ubuntu-latest
    needs: [build, style]
    if: github.event_name == 'schedule' && (failure() || cancelled())
    steps:
      - name: Install zulip-send
        run: pip3 install zulip
      - name: Send Zulip notification
        shell: bash
        env:
          ZULIP_BOT_EMAIL: ${{ secrets.ZULIP_BOT_EMAIL }}
          ZULIP_API_TOKEN: ${{ secrets.ZULIP_API_TOKEN }}
        run: |
          ~/.local/bin/zulip-send --stream miri --subject "Cron Job Failure (miri, $(date -u +%Y-%m))" \
            --message 'Dear @*T-miri*,

          It would appear that the Miri cron job build failed. Would you mind investigating this issue?

          Thanks in advance!
          Sincerely,
          The Miri Cronjobs Bot' \
            --user $ZULIP_BOT_EMAIL --api-key $ZULIP_API_TOKEN --site https://rust-lang.zulipchat.com