]> git.lizzy.rs Git - rust.git/blob - .github/workflows/ci.yaml
Auto merge of #11976 - Veykril:rust-lang-test, r=Veykril
[rust.git] / .github / workflows / ci.yaml
1 # Please make sure that the `needs` fields for both `end-success` and `end-failure`
2 # are updated when adding new jobs!
3
4 name: CI
5 on:
6   pull_request:
7   push:
8     branches:
9     - master
10     - staging
11     - trying
12     - auto
13     - try
14
15 env:
16   CARGO_INCREMENTAL: 0
17   CARGO_NET_RETRY: 10
18   CI: 1
19   RUST_BACKTRACE: short
20   RUSTFLAGS: "-D warnings -W unreachable-pub -W rust-2021-compatibility"
21   RUSTUP_MAX_RETRIES: 10
22
23 jobs:
24   rust:
25     if: github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer'
26     name: Rust
27     runs-on: ${{ matrix.os }}
28     env:
29       CC: deny_c
30
31     strategy:
32       fail-fast: false
33       matrix:
34         os: [ubuntu-latest, windows-latest, macos-latest]
35
36     steps:
37     - name: Checkout repository
38       uses: actions/checkout@v2
39       with:
40         ref: ${{ github.event.pull_request.head.sha }}
41         fetch-depth: 20
42
43     # We need to disable the existing toolchain to avoid updating rust-docs
44     # which takes a long time. The fastest way to do this is to rename the
45     # existing folder, as deleting it takes about as much time as not doing
46     # anything and just updating rust-docs.
47     - name: Rename existing rust toolchain (Windows)
48       if: matrix.os == 'windows-latest'
49       run: Rename-Item C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc.old
50
51     - name: Install Rust toolchain
52       uses: actions-rs/toolchain@v1
53       with:
54         toolchain: stable
55         profile: minimal
56         override: true
57         components: rustfmt, rust-src
58
59     - name: Cache Dependencies
60       uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
61
62     - name: Compile
63       run: cargo test --no-run --locked
64
65     - name: Test
66       run: cargo test -- --nocapture --quiet
67
68   # Weird targets to catch non-portable code
69   rust-cross:
70     if: github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer'
71     name: Rust Cross
72     runs-on: ubuntu-latest
73
74     env:
75       targets: "powerpc-unknown-linux-gnu x86_64-unknown-linux-musl"
76       # The rust-analyzer binary is not expected to compile on WASM, but the IDE
77       # crate should
78       targets_ide: "wasm32-unknown-unknown"
79
80     steps:
81     - name: Checkout repository
82       uses: actions/checkout@v2
83
84     - name: Install Rust toolchain
85       uses: actions-rs/toolchain@v1
86       with:
87         toolchain: stable
88         profile: minimal
89         override: true
90
91     - name: Install Rust targets
92       run: rustup target add ${{ env.targets }} ${{ env.targets_ide }}
93
94     - name: Cache Dependencies
95       uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
96
97     - name: Check
98       run: |
99         for target in ${{ env.targets }}; do
100           cargo check --target=$target --all-targets
101         done
102         for target in ${{ env.targets_ide }}; do
103           cargo check -p ide --target=$target --all-targets
104         done
105
106   typescript:
107     if: github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer'
108     name: TypeScript
109     strategy:
110       fail-fast: false
111       matrix:
112         os: [ubuntu-latest, windows-latest]
113
114     runs-on: ${{ matrix.os }}
115
116     steps:
117     - name: Checkout repository
118       uses: actions/checkout@v2
119
120     - name: Install Nodejs
121       uses: actions/setup-node@v1
122       with:
123         node-version: 14.x
124
125     - name: Install xvfb
126       if: matrix.os == 'ubuntu-latest'
127       run: sudo apt-get install -y xvfb
128
129     - run: npm ci
130       working-directory: ./editors/code
131
132 #    - run: npm audit || { sleep 10 && npm audit; } || { sleep 30 && npm audit; }
133 #      if: runner.os == 'Linux'
134 #      working-directory: ./editors/code
135
136     - run: npm run lint
137       working-directory: ./editors/code
138
139     - name: Run VS Code tests (Linux)
140       if: matrix.os == 'ubuntu-latest'
141       env:
142         VSCODE_CLI: 1
143       run: xvfb-run npm test
144       working-directory: ./editors/code
145
146     - name: Run VS Code tests (Windows)
147       if: matrix.os == 'windows-latest'
148       env:
149         VSCODE_CLI: 1
150       run: npm test
151       working-directory: ./editors/code
152
153     - run: npm run pretest
154       working-directory: ./editors/code
155
156     - run: npm run package --scripts-prepend-node-path
157       working-directory: ./editors/code
158
159   end-success:
160     name: bors build finished
161     if: github.event.pusher.name == 'bors' && success()
162     runs-on: ubuntu-latest
163     needs: [rust, rust-cross, typescript]
164     steps:
165       - name: Mark the job as successful
166         run: exit 0
167
168   end-failure:
169     name: bors build finished
170     if: github.event.pusher.name == 'bors' && (failure() || cancelled())
171     runs-on: ubuntu-latest
172     needs: [rust, rust-cross, typescript]
173     steps:
174       - name: Mark the job as a failure
175         run: exit 1