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