]> git.lizzy.rs Git - rust.git/blob - .github/workflows/ci.yaml
Merge #8432
[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"
16   RUSTUP_MAX_RETRIES: 10
17
18 jobs:
19   rust:
20     name: Rust
21     runs-on: ${{ matrix.os }}
22     env:
23       CC: deny_c
24
25     strategy:
26       fail-fast: false
27       matrix:
28         os: [ubuntu-latest, windows-latest, macos-latest]
29
30     steps:
31     - name: Checkout repository
32       uses: actions/checkout@v2
33       with:
34         ref: ${{ github.event.pull_request.head.sha }}
35         fetch-depth: 20
36
37     # We need to disable the existing toolchain to avoid updating rust-docs
38     # which takes a long time. The fastest way to do this is to rename the
39     # existing folder, as deleting it takes about as much time as not doing
40     # anything and just updating rust-docs.
41     - name: Rename existing rust toolchain (Windows)
42       if: matrix.os == 'windows-latest'
43       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
44
45     # Work around https://github.com/actions/cache/issues/403 by using GNU tar
46     # instead of BSD tar.
47     - name: Install GNU tar
48       if: matrix.os == 'macos-latest'
49       run: |
50         brew install gnu-tar
51         echo PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV
52
53     - name: Install Rust toolchain
54       uses: actions-rs/toolchain@v1
55       with:
56         toolchain: stable
57         profile: minimal
58         override: true
59         components: rustfmt, rust-src
60
61     - name: Cache cargo directories
62       uses: actions/cache@v2
63       with:
64         path: |
65           ~/.cargo/registry
66           ~/.cargo/git
67         key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
68
69     - name: Cache cargo target dir
70       uses: actions/cache@v2
71       with:
72         path: target
73         key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
74
75     - name: Compile
76       run: cargo test --no-run --locked
77
78     - name: Test
79       run: cargo test -- --nocapture
80
81     - name: Prepare cache
82       run: cargo xtask pre-cache
83
84   # Weird targets to catch non-portable code
85   rust-cross:
86     name: Rust Cross
87     runs-on: ubuntu-latest
88
89     env:
90       targets: "powerpc-unknown-linux-gnu x86_64-unknown-linux-musl"
91
92     steps:
93     - name: Checkout repository
94       uses: actions/checkout@v2
95
96     - name: Install Rust toolchain
97       uses: actions-rs/toolchain@v1
98       with:
99         toolchain: stable
100         profile: minimal
101         override: true
102
103     - name: Install Rust targets
104       run: rustup target add ${{ env.targets }}
105
106     - name: Cache cargo directories
107       uses: actions/cache@v2
108       with:
109         path: |
110           ~/.cargo/registry
111           ~/.cargo/git
112         key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
113
114     - name: Check
115       run: |
116         for target in ${{ env.targets }}; do
117           cargo check --target=$target --all-targets
118         done
119
120   typescript:
121     name: TypeScript
122     strategy:
123       fail-fast: false
124       matrix:
125         os: [ubuntu-latest, windows-latest]
126
127     runs-on: ${{ matrix.os }}
128
129     steps:
130     - name: Checkout repository
131       uses: actions/checkout@v2
132
133     - name: Install Nodejs
134       uses: actions/setup-node@v1
135       with:
136         node-version: 12.x
137
138     - run: npm ci
139       working-directory: ./editors/code
140
141 #    - run: npm audit || { sleep 10 && npm audit; } || { sleep 30 && npm audit; }
142 #      if: runner.os == 'Linux'
143 #      working-directory: ./editors/code
144
145     - run: npm run lint
146       working-directory: ./editors/code
147
148     - name: Run vscode tests
149       uses: GabrielBB/xvfb-action@v1.2
150       env:
151         VSCODE_CLI: 1
152       with:
153         run: npm --prefix ./editors/code test
154         # working-directory: ./editors/code  # does not work: https://github.com/GabrielBB/xvfb-action/issues/8
155
156     - run: npm run package --scripts-prepend-node-path
157       working-directory: ./editors/code