Repace the CI script with one I'm more familiar with.

This commit is contained in:
Dan Gohman
2022-11-28 08:31:52 -08:00
parent d993f75414
commit fcb5639e8b
4 changed files with 153 additions and 63 deletions
+18
View File
@@ -0,0 +1,18 @@
# install-rust
A small github action to install `rustup` and a Rust toolchain. This is
generally expressed inline, but it was repeated enough in this repository it
seemed worthwhile to extract.
Some gotchas:
* Can't `--self-update` on Windows due to permission errors (a bug in Github
Actions)
* `rustup` isn't installed on macOS (a bug in Github Actions)
When the above are fixed we should delete this action and just use this inline:
```yml
- run: rustup update $toolchain && rustup default $toolchain
shell: bash
```
+12
View File
@@ -0,0 +1,12 @@
name: 'Install Rust toolchain'
description: 'Install both `rustup` and a Rust toolchain'
inputs:
toolchain:
description: 'Default toolchan to install'
required: false
default: 'stable'
runs:
using: node16
main: 'main.js'
+36
View File
@@ -0,0 +1,36 @@
const child_process = require('child_process');
const toolchain = process.env.INPUT_TOOLCHAIN;
const fs = require('fs');
function set_env(name, val) {
fs.appendFileSync(process.env['GITHUB_ENV'], `${name}=${val}\n`)
}
// Needed for now to get 1.24.2 which fixes a bug in 1.24.1 that causes issues
// on Windows.
if (process.platform === 'win32') {
child_process.execFileSync('rustup', ['self', 'update']);
}
child_process.execFileSync('rustup', ['set', 'profile', 'minimal']);
child_process.execFileSync('rustup', ['update', toolchain, '--no-self-update']);
child_process.execFileSync('rustup', ['default', toolchain]);
// Deny warnings on CI to keep our code warning-free as it lands in-tree. Don't
// do this on nightly though since there's a fair amount of warning churn there.
if (!toolchain.startsWith('nightly')) {
set_env("RUSTFLAGS", "-D warnings");
}
// Save disk space by avoiding incremental compilation, and also we don't use
// any caching so incremental wouldn't help anyway.
set_env("CARGO_INCREMENTAL", "0");
// Turn down debuginfo from 2 to 1 to help save disk space
set_env("CARGO_PROFILE_DEV_DEBUG", "1");
set_env("CARGO_PROFILE_TEST_DEBUG", "1");
if (process.platform === 'darwin') {
set_env("CARGO_PROFILE_DEV_SPLIT_DEBUGINFO", "unpacked");
set_env("CARGO_PROFILE_TEST_SPLIT_DEBUGINFO", "unpacked");
}
+87 -63
View File
@@ -1,83 +1,107 @@
on: [push, pull_request]
name: CI
on:
push:
branches:
- main
pull_request:
jobs:
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: ./.github/actions/install-rust
with:
toolchain: stable
- run: cargo fmt --all -- --check
check:
name: Check
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [ubuntu-latest, windows-latest, macos-latest]
build: [stable, nightly]
include:
- build: ubuntu-latest
- build: stable
os: ubuntu-latest
- build: windows-latest
os: windows-latest
- build: macos-latest
os: macos-latest
rust:
- stable
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- uses: actions-rs/cargo@v1
with:
command: check
rust: stable
- build: nightly
os: ubuntu-latest
rust: nightly
test:
name: Test Suite
env:
# -D warnings is commented out in our install-rust action; re-add it here.
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: ./.github/actions/install-rust
with:
toolchain: ${{ matrix.rust }}
- run: rustup target add x86_64-apple-darwin wasm32-unknown-unknown
- run: cargo check --workspace --release -vv --target=x86_64-apple-darwin
- run: cargo check --workspace --release -vv --target=wasm32-unknown-unknown
check_nightly:
name: Check on Rust nightly
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [ubuntu-latest, ubuntu-18.04, windows-latest, macos-latest]
build: [nightly]
include:
- build: ubuntu-latest
- build: nightly
os: ubuntu-latest
- build: ubuntu-18.04
os: ubuntu-18.04
- build: windows-latest
os: windows-latest
- build: macos-latest
os: macos-latest
rust:
- nightly
- stable
- 1.48.0
exclude:
- build: macos-latest
rust: 1.48.0
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- uses: actions-rs/cargo@v1
with:
command: test
rust: nightly
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: ./.github/actions/install-rust
with:
toolchain: ${{ matrix.rust }}
- run: >
rustup target add
wasm32-wasi
- run: cargo check --workspace --release -vv --target=wasm32-wasi
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust:
- stable
build: [ubuntu-nightly, windows-nightly, ubuntu-stable, windows-stable, macos-nightly, macos-stable]
include:
- build: ubuntu-nightly
os: ubuntu-latest
rust: nightly
- build: windows-nightly
os: windows-latest
rust: nightly
- build: macos-nightly
os: macos-latest
rust: nightly
- build: ubuntu-stable
os: ubuntu-latest
rust: stable
- build: windows-stable
os: windows-latest
rust: stable
- build: macos-stable
os: macos-latest
rust: stable
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- uses: actions/checkout@v3
with:
submodules: true
- uses: ./.github/actions/install-rust
with:
toolchain: ${{ matrix.rust }}
- run: cargo test --workspace