]> git.lizzy.rs Git - rust.git/blob - .github/workflows/ci.yaml
Auto merge of #13441 - Veykril:sysroot-logging, 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       - auto
10       - try
11
12 env:
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
20 jobs:
21   rust:
22     if: github.repository == 'rust-lang/rust-analyzer'
23     name: Rust
24     runs-on: ${{ matrix.os }}
25     env:
26       CC: deny_c
27
28     strategy:
29       fail-fast: false
30       matrix:
31         os: [ubuntu-latest, windows-latest, macos-latest]
32
33     steps:
34       - name: Checkout repository
35         uses: actions/checkout@v3
36         with:
37           ref: ${{ github.event.pull_request.head.sha }}
38           fetch-depth: 20
39
40       - name: Install Rust toolchain
41         run: |
42           rustup update --no-self-update stable
43           rustup component add rustfmt rust-src
44
45       - name: Cache Dependencies
46         uses: Swatinem/rust-cache@76686c56f2b581d1bb5bda44b51f7e24bd9b8b8e
47
48       - name: Bump opt-level
49         if: matrix.os == 'ubuntu-latest'
50         run: sed -i '/\[profile.dev]/a opt-level=1' Cargo.toml
51
52       - name: Compile (tests)
53         run: cargo test --no-run --locked
54
55       # It's faster to `test` before `build` ¯\_(ツ)_/¯
56       - name: Compile (rust-analyzer)
57         if: matrix.os == 'ubuntu-latest'
58         run: cargo build --quiet
59
60       - name: Test
61         run: cargo test -- --nocapture --quiet
62
63       - name: Run analysis-stats on rust-analyzer
64         if: matrix.os == 'ubuntu-latest'
65         run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats .
66
67       - name: Run analysis-stats on rust std library
68         if: matrix.os == 'ubuntu-latest'
69         run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats --with-deps $(rustc --print sysroot)/lib/rustlib/src/rust/library/std
70
71   # Weird targets to catch non-portable code
72   rust-cross:
73     if: github.repository == 'rust-lang/rust-analyzer'
74     name: Rust Cross
75     runs-on: ubuntu-latest
76
77     env:
78       targets: "powerpc-unknown-linux-gnu x86_64-unknown-linux-musl"
79       # The rust-analyzer binary is not expected to compile on WASM, but the IDE
80       # crate should
81       targets_ide: "wasm32-unknown-unknown"
82
83     steps:
84       - name: Checkout repository
85         uses: actions/checkout@v3
86
87       - name: Install Rust toolchain
88         run: |
89           rustup update --no-self-update stable
90           rustup target add ${{ env.targets }} ${{ env.targets_ide }}
91
92       - name: Cache Dependencies
93         uses: Swatinem/rust-cache@76686c56f2b581d1bb5bda44b51f7e24bd9b8b8e
94
95       - name: Check
96         run: |
97           for target in ${{ env.targets }}; do
98             cargo check --target=$target --all-targets
99           done
100           for target in ${{ env.targets_ide }}; do
101             cargo check -p ide --target=$target --all-targets
102           done
103
104   typescript:
105     if: github.repository == 'rust-lang/rust-analyzer'
106     name: TypeScript
107     strategy:
108       fail-fast: false
109       matrix:
110         os: [ubuntu-latest, windows-latest]
111
112     runs-on: ${{ matrix.os }}
113
114     steps:
115       - name: Checkout repository
116         uses: actions/checkout@v3
117
118       - name: Install Nodejs
119         uses: actions/setup-node@v3
120         with:
121           node-version: 16
122
123       - name: Install xvfb
124         if: matrix.os == 'ubuntu-latest'
125         run: sudo apt-get install -y xvfb
126
127       - run: npm ci
128         working-directory: ./editors/code
129
130       #    - run: npm audit || { sleep 10 && npm audit; } || { sleep 30 && npm audit; }
131       #      if: runner.os == 'Linux'
132       #      working-directory: ./editors/code
133
134       - run: npm run lint
135         working-directory: ./editors/code
136
137       - name: Run VS Code tests (Linux)
138         if: matrix.os == 'ubuntu-latest'
139         env:
140           VSCODE_CLI: 1
141         run: xvfb-run npm test
142         working-directory: ./editors/code
143
144       - name: Run VS Code tests (Windows)
145         if: matrix.os == 'windows-latest'
146         env:
147           VSCODE_CLI: 1
148         run: npm test
149         working-directory: ./editors/code
150
151       - run: npm run pretest
152         working-directory: ./editors/code
153
154       - run: npm run package --scripts-prepend-node-path
155         working-directory: ./editors/code
156
157   end-success:
158     name: bors build finished
159     if: github.event.pusher.name == 'bors' && success()
160     runs-on: ubuntu-latest
161     needs: [rust, rust-cross, typescript]
162     steps:
163       - name: Mark the job as successful
164         run: exit 0
165
166   end-failure:
167     name: bors build finished
168     if: github.event.pusher.name == 'bors' && (failure() || cancelled())
169     runs-on: ubuntu-latest
170     needs: [rust, rust-cross, typescript]
171     steps:
172       - name: Mark the job as a failure
173         run: exit 1