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