]> git.lizzy.rs Git - rust.git/blob - .github/workflows/ci.yaml
f977c88bee70a3743bee3551cbda3579b9577ba7
[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     - name: Cache cargo directories
65       uses: actions/cache@v2
66       with:
67         path: |
68           ~/.cargo/registry
69           ~/.cargo/git
70         key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
71
72     - name: Cache cargo target dir
73       uses: actions/cache@v2
74       with:
75         path: target
76         key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
77
78     - name: Compile
79       run: cargo test --no-run --locked
80
81     - name: Test
82       run: cargo test
83
84     - name: Prepare cache
85       run: cargo xtask pre-cache
86
87     - name: Prepare cache 2
88       if: matrix.os == 'windows-latest'
89       run: Remove-Item ./target/debug/xtask.exe, ./target/debug/deps/xtask.exe
90
91   # Weird targets to catch non-portable code
92   rust-cross:
93     name: Rust Cross
94     runs-on: ubuntu-latest
95
96     env:
97       targets: "powerpc-unknown-linux-gnu x86_64-unknown-linux-musl"
98
99     steps:
100     - name: Checkout repository
101       uses: actions/checkout@v2
102
103     - name: Install Rust toolchain
104       uses: actions-rs/toolchain@v1
105       with:
106         toolchain: stable
107         profile: minimal
108         override: true
109
110     - name: Install Rust targets
111       run: rustup target add ${{ env.targets }}
112
113     - name: Cache cargo directories
114       uses: actions/cache@v2
115       with:
116         path: |
117           ~/.cargo/registry
118           ~/.cargo/git
119         key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
120
121     - name: Check
122       run: |
123         for target in ${{ env.targets }}; do
124           cargo check --target=$target --all-targets
125         done
126
127   typescript:
128     name: TypeScript
129     strategy:
130       fail-fast: false
131       matrix:
132         os: [ubuntu-latest, windows-latest, macos-latest]
133
134     runs-on: ${{ matrix.os }}
135
136     steps:
137     - name: Checkout repository
138       uses: actions/checkout@v2
139
140     - name: Install Nodejs
141       uses: actions/setup-node@v1
142       with:
143         node-version: 12.x
144
145     - run: npm ci
146       working-directory: ./editors/code
147
148 #    - run: npm audit || { sleep 10 && npm audit; } || { sleep 30 && npm audit; }
149 #      if: runner.os == 'Linux'
150 #      working-directory: ./editors/code
151
152     - run: npm run lint
153       working-directory: ./editors/code
154
155     - name: Run vscode tests
156       uses: GabrielBB/xvfb-action@v1.2
157       env:
158         VSCODE_CLI: 1
159       with:
160         run: npm --prefix ./editors/code test
161         # working-directory: ./editors/code  # does not work: https://github.com/GabrielBB/xvfb-action/issues/8
162
163     - run: npm run package --scripts-prepend-node-path
164       working-directory: ./editors/code