Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement IsTerminal for wasm32-unknown-unknown and wasm32-wasi. #10

Merged
merged 3 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/actions/install-rust/README.md
Original file line number Diff line number Diff line change
@@ -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 changes: 12 additions & 0 deletions .github/actions/install-rust/action.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 36 additions & 0 deletions .github/actions/install-rust/main.js
Original file line number Diff line number Diff line change
@@ -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");
}
146 changes: 85 additions & 61 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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
rust: stable
- build: nightly
os: ubuntu-latest
rust: nightly

env:
# -D warnings is commented out in our install-rust action; re-add it here.
RUSTFLAGS: -D warnings
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
- uses: actions/checkout@v3
with:
submodules: true
- uses: ./.github/actions/install-rust
with:
toolchain: ${{ matrix.rust }}

test:
name: Test Suite
- 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
rust: nightly

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
- 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 --all-targets

fmt:
name: Rustfmt
runs-on: ubuntu-latest
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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ include = ["src", "build.rs", "Cargo.toml", "COPYRIGHT", "LICENSE*", "/*.md"]
[dependencies]
io-lifetimes = "1.0.0"

[target.'cfg(not(any(windows, target_os = "hermit")))'.dependencies]
rustix = { version = "0.36.0", features = ["termios"] }
[target.'cfg(not(any(windows, target_os = "hermit", target_os = "unknown")))'.dependencies]
rustix = { version = "0.36.4", features = ["termios"] }

[target.'cfg(target_os = "hermit")'.dependencies]
hermit-abi = "0.2.0"
Expand All @@ -33,5 +33,5 @@ features = [
[dev-dependencies]
atty = "0.2.14"

[target.'cfg(unix)'.dev-dependencies]
[target.'cfg(any(unix, target_os = "wasi"))'.dev-dependencies]
libc = "0.2.110"
Loading