fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
6.8 KiB221 linesraw
1# Please make sure that the `needs` fields for both `end-success` and `end-failure`
2# are updated when adding new jobs!
3
4name: CI
5on:
6  pull_request:
7  push:
8    branches:
9      - auto
10      - try
11
12env:
13  CARGO_INCREMENTAL: 0
14  CARGO_NET_RETRY: 10
15  CI: 1
16  RUST_BACKTRACE: short
17  RUSTFLAGS: "-D warnings -W unreachable-pub -W bare-trait-objects"
18  RUSTUP_MAX_RETRIES: 10
19
20jobs:
21  changes:
22    runs-on: ubuntu-latest
23    permissions:
24      pull-requests: read
25    outputs:
26      typescript: ${{ steps.filter.outputs.typescript }}
27      proc_macros: ${{ steps.filter.outputs.proc_macros }}
28    steps:
29      - uses: actions/checkout@v3
30      - uses: dorny/paths-filter@4067d885736b84de7c414f582ac45897079b0a78
31        id: filter
32        with:
33          filters: |
34            typescript:
35              - 'editors/code/**'
36            proc_macros:
37              - 'crates/proc-macro-api/**'
38              - 'crates/proc-macro-srv/**'
39              - 'crates/proc-macro-srv-cli/**'
40              - 'crates/proc-macro-test/**'
41
42  rust:
43    needs: changes
44    if: github.repository == 'rust-lang/rust-analyzer'
45    name: Rust
46    runs-on: ${{ matrix.os }}
47    env:
48      CC: deny_c
49      RUST_CHANNEL: "${{ needs.changes.outputs.proc_macros == 'true' && 'nightly' || 'stable' }}"
50      USE_SYSROOT_ABI: "${{ needs.changes.outputs.proc_macros == 'true' && '--features sysroot-abi' || '' }}"
51
52    strategy:
53      fail-fast: false
54      matrix:
55        os: [ubuntu-latest, windows-latest, macos-latest]
56
57    steps:
58      - name: Checkout repository
59        uses: actions/checkout@v3
60        with:
61          ref: ${{ github.event.pull_request.head.sha }}
62
63      - name: Install Rust toolchain
64        run: |
65          rustup update --no-self-update ${{ env.RUST_CHANNEL }}
66          rustup component add --toolchain ${{ env.RUST_CHANNEL }} rustfmt rust-src
67          rustup default ${{ env.RUST_CHANNEL }}
68
69      - name: Cache Dependencies
70        uses: Swatinem/rust-cache@988c164c3d0e93c4dbab36aaf5bbeb77425b2894
71        with:
72          key: ${{ env.RUST_CHANNEL }}
73
74      - name: Bump opt-level
75        if: matrix.os == 'ubuntu-latest'
76        run: sed -i '/\[profile.dev]/a opt-level=1' Cargo.toml
77
78      - name: Compile (tests)
79        run: cargo test --no-run --locked ${{ env.USE_SYSROOT_ABI }}
80
81      # It's faster to `test` before `build` ¯\_(ツ)_/¯
82      - name: Compile (rust-analyzer)
83        if: matrix.os == 'ubuntu-latest'
84        run: cargo build --quiet ${{ env.USE_SYSROOT_ABI }}
85
86      - name: Test
87        run: cargo test ${{ env.USE_SYSROOT_ABI }} -- --nocapture --quiet
88
89      - name: Switch to stable toolchain
90        run: |
91          rustup update --no-self-update stable
92          rustup component add --toolchain stable rust-src
93          rustup default stable
94
95      - name: Run analysis-stats on rust-analyzer
96        if: matrix.os == 'ubuntu-latest'
97        run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats .
98
99      - name: Run analysis-stats on rust std library
100        if: matrix.os == 'ubuntu-latest'
101        env:
102          RUSTC_BOOTSTRAP: 1
103        run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats --with-deps $(rustc --print sysroot)/lib/rustlib/src/rust/library/std
104
105  # Weird targets to catch non-portable code
106  rust-cross:
107    if: github.repository == 'rust-lang/rust-analyzer'
108    name: Rust Cross
109    runs-on: ubuntu-latest
110
111    env:
112      targets: "powerpc-unknown-linux-gnu x86_64-unknown-linux-musl"
113      # The rust-analyzer binary is not expected to compile on WASM, but the IDE
114      # crate should
115      targets_ide: "wasm32-unknown-unknown"
116
117    steps:
118      - name: Checkout repository
119        uses: actions/checkout@v3
120
121      - name: Install Rust toolchain
122        run: |
123          rustup update --no-self-update stable
124          rustup target add ${{ env.targets }} ${{ env.targets_ide }}
125
126      - name: Cache Dependencies
127        uses: Swatinem/rust-cache@988c164c3d0e93c4dbab36aaf5bbeb77425b2894
128
129      - name: Check
130        run: |
131          for target in ${{ env.targets }}; do
132            cargo check --target=$target --all-targets
133          done
134          for target in ${{ env.targets_ide }}; do
135            cargo check -p ide --target=$target --all-targets
136          done
137
138  typescript:
139    needs: changes
140    if: github.repository == 'rust-lang/rust-analyzer'
141    name: TypeScript
142    strategy:
143      fail-fast: false
144      matrix:
145        os: [ubuntu-latest, windows-latest]
146
147    runs-on: ${{ matrix.os }}
148
149    steps:
150      - name: Checkout repository
151        uses: actions/checkout@v3
152        if: needs.changes.outputs.typescript == 'true'
153
154      - name: Install Nodejs
155        uses: actions/setup-node@v3
156        with:
157          node-version: 16
158        if: needs.changes.outputs.typescript == 'true'
159
160      - name: Install xvfb
161        if: matrix.os == 'ubuntu-latest' && needs.changes.outputs.typescript == 'true'
162        run: sudo apt-get install -y xvfb
163
164      - run: npm ci
165        working-directory: ./editors/code
166        if: needs.changes.outputs.typescript == 'true'
167
168      #    - run: npm audit || { sleep 10 && npm audit; } || { sleep 30 && npm audit; }
169      #      if: runner.os == 'Linux'
170      #      working-directory: ./editors/code
171
172      # If this steps fails, your code's type integrity might be wrong at some places at TypeScript level.
173      - run: npm run typecheck
174        working-directory: ./editors/code
175        if: needs.changes.outputs.typescript == 'true'
176
177      # You may fix the code automatically by running `npm run lint:fix` if this steps fails.
178      - run: npm run lint
179        working-directory: ./editors/code
180        if: needs.changes.outputs.typescript == 'true'
181
182      # To fix this steps, please run `npm run format`.
183      - run: npm run format:check
184        working-directory: ./editors/code
185        if: needs.changes.outputs.typescript == 'true'
186
187      - name: Run VS Code tests (Linux)
188        if: matrix.os == 'ubuntu-latest' && needs.changes.outputs.typescript == 'true'
189        env:
190          VSCODE_CLI: 1
191        run: xvfb-run npm test
192        working-directory: ./editors/code
193
194      - name: Run VS Code tests (Windows)
195        if: matrix.os == 'windows-latest' && needs.changes.outputs.typescript == 'true'
196        env:
197          VSCODE_CLI: 1
198        run: npm test
199        working-directory: ./editors/code
200
201      - run: npm run package --scripts-prepend-node-path
202        working-directory: ./editors/code
203        if: needs.changes.outputs.typescript == 'true'
204
205  end-success:
206    name: bors build finished
207    if: github.event.pusher.name == 'bors' && success()
208    runs-on: ubuntu-latest
209    needs: [rust, rust-cross, typescript]
210    steps:
211      - name: Mark the job as successful
212        run: exit 0
213
214  end-failure:
215    name: bors build finished
216    if: github.event.pusher.name == 'bors' && !success()
217    runs-on: ubuntu-latest
218    needs: [rust, rust-cross, typescript]
219    steps:
220      - name: Mark the job as a failure
221        run: exit 1