]> git.lizzy.rs Git - rust.git/blob - .github/workflows/ci.yaml
Merge #5089 #5161 #5184 #5185 #5186
[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
16   RUSTUP_MAX_RETRIES: 10
17
18 jobs:
19   rust-audit:
20     name: Audit Rust vulnerabilities
21     runs-on: ubuntu-latest
22     steps:
23     - name: Checkout repository
24       uses: actions/checkout@v2
25
26     - uses: actions-rs/install@v0.1
27       with:
28         crate: cargo-audit
29         use-tool-cache: true
30
31     - run: cargo audit
32
33   rust:
34     name: Rust
35     runs-on: ${{ matrix.os }}
36     env:
37      CC: deny_c
38
39     strategy:
40       fail-fast: false
41       matrix:
42         os: [ubuntu-latest, windows-latest, macos-latest]
43
44     steps:
45     - name: Checkout repository
46       uses: actions/checkout@v2
47
48     # We need to disable the existing toolchain to avoid updating rust-docs
49     # which takes a long time. The fastest way to do this is to rename the
50     # existing folder, as deleting it takes about as much time as not doing
51     # anything and just updating rust-docs.
52     - name: Rename existing rust toolchain (Windows)
53       if: matrix.os == 'windows-latest'
54       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
55
56     - name: Install Rust toolchain
57       uses: actions-rs/toolchain@v1
58       with:
59         toolchain: stable
60         profile: minimal
61         override: true
62         components: rustfmt, rust-src
63
64     - if: matrix.os == 'ubuntu-latest'
65       run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/
66
67     - name: Cache cargo registry
68       uses: actions/cache@v1
69       with:
70         path: ~/.cargo/registry
71         key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
72
73     - name: Cache cargo index
74       uses: actions/cache@v1
75       with:
76         path: ~/.cargo/git
77         key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
78
79     - name: Cache cargo target dir
80       uses: actions/cache@v1
81       with:
82         path: target
83         key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
84
85     - name: Compile
86       run: cargo test --no-run
87
88     - name: Test
89       run: cargo test
90
91     - name: Prepare cache
92       run: cargo xtask pre-cache
93
94     - name: Prepare cache 2
95       if: matrix.os == 'windows-latest'
96       run: Remove-Item ./target/debug/xtask.exe, ./target/debug/deps/xtask.exe
97
98   typescript:
99     name: TypeScript
100     strategy:
101       fail-fast: false
102       matrix:
103         os: [ubuntu-latest, windows-latest, macos-latest]
104
105     runs-on: ${{ matrix.os }}
106     
107     steps:
108     - name: Checkout repository
109       uses: actions/checkout@v2
110
111     - name: Install Nodejs
112       uses: actions/setup-node@v1
113       with:
114         node-version: 12.x
115
116     - run: npm ci
117       working-directory: ./editors/code
118
119 #    - run: npm audit || { sleep 10 && npm audit; } || { sleep 30 && npm audit; }
120 #      if: runner.os == 'Linux'
121 #      working-directory: ./editors/code
122
123     - run: npm run lint
124       working-directory: ./editors/code
125
126     - name: Run vscode tests
127       uses: GabrielBB/xvfb-action@v1.2
128       env:
129         VSCODE_CLI: 1
130       with:
131         run: npm --prefix ./editors/code test
132         # working-directory: ./editors/code  # does not work: https://github.com/GabrielBB/xvfb-action/issues/8
133
134     - run: npm run package --scripts-prepend-node-path
135       working-directory: ./editors/code