Skip to content

Commit

Permalink
ci: consolidate tasks and use sccache and nextest
Browse files Browse the repository at this point in the history
  • Loading branch information
shadaj committed Jan 8, 2024
1 parent 5e6ebac commit 6c9c9a9
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 145 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ rustflags = [
## TODO(mingwei): Need rust-analyzer support:
# "-Aclippy::uninlined-format-args",
]

[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe"
18 changes: 18 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[test-groups]
serial-integration = { max-threads = 1 }

[[profile.default.overrides]]
filter = 'binary(deadlock_detector)'
test-group = 'serial-integration'

[[profile.default.overrides]]
filter = 'binary(two_pc)'
test-group = 'serial-integration'

[[profile.default.overrides]]
filter = 'binary(kvs)'
test-group = 'serial-integration'

[[profile.default.overrides]]
filter = 'binary(kvs_replicated)'
test-group = 'serial-integration'
169 changes: 88 additions & 81 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
cancel_others: "true"

check:
name: Check
name: Lint and Check
if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.event_name != 'pull_request' }}
timeout-minutes: 15
needs: pre_job
Expand All @@ -40,7 +40,15 @@ jobs:
# resolve to 'nothing' so we will exclude 'nothing'. https://stackoverflow.com/a/73822998
- rust_release: ${{ (needs.pre_job.outputs.should_skip != 'true' && 'nothing') || 'pinned-nightly' }}
- rust_release: ${{ (github.event_name != 'pull_request' && 'nothing') || 'latest-nightly' }}
- os: ${{ (github.event_name != 'pull_request' && 'nothing') || 'windows-latest' }}

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
CARGO_PROFILE_DEV_STRIP: "debuginfo"
CARGO_PROFILE_TEST_STRIP: "debuginfo"
CARGO_PROFILE_RELEASE_STRIP: "debuginfo"

steps:
- name: Checkout sources
Expand All @@ -53,6 +61,22 @@ jobs:
toolchain: nightly
override: ${{ matrix.rust_release == 'latest-nightly' }}

- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- name: Run cargo fmt
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --features python -- -D warnings

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
Expand Down Expand Up @@ -108,12 +132,6 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
target_selection:
- "--lib --bins"
- "--examples"
- "--tests"
- "--benches"
- "--doc"
rust_release: [pinned-nightly, latest-nightly]
exclude:
# For non-pull requests, event_name != 'pull_request' will be true, and 'nothing' is
Expand All @@ -123,6 +141,15 @@ jobs:
- rust_release: ${{ (github.event_name != 'pull_request' && 'nothing') || 'latest-nightly' }}
- os: ${{ (github.event_name != 'pull_request' && 'nothing') || 'windows-latest' }}

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
CARGO_PROFILE_DEV_STRIP: "debuginfo"
CARGO_PROFILE_TEST_STRIP: "debuginfo"
CARGO_PROFILE_RELEASE_STRIP: "debuginfo"

steps:
- name: Checkout sources
uses: actions/checkout@v3
Expand All @@ -134,101 +161,75 @@ jobs:
toolchain: nightly
override: ${{ matrix.rust_release == 'latest-nightly' }}

- name: Run cargo test on target_selection
uses: actions-rs/cargo@v1
with:
command: test
args: --profile cidev --no-fail-fast --features python ${{ matrix.target_selection }}
- name: Run sccache-cache
uses: mozilla-actions/[email protected]

test-wasm:
name: Test Suite (WebAssembly)
if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.event_name != 'pull_request' }}
timeout-minutes: 15
needs: pre_job
runs-on: ubuntu-latest
strategy:
matrix:
rust_release: [pinned-nightly, latest-nightly]
exclude:
# For non-pull requests, event_name != 'pull_request' will be true, and 'nothing' is
# truthy, so the entire && operator will resolve to 'nothing'. Then the || operator will
# resolve to 'nothing' so we will exclude 'nothing'. https://stackoverflow.com/a/73822998
- rust_release: ${{ (needs.pre_job.outputs.should_skip != 'true' && 'nothing') || 'pinned-nightly' }}
- rust_release: ${{ (github.event_name != 'pull_request' && 'nothing') || 'latest-nightly' }}

steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Install cargo-nextest (linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
target: wasm32-unknown-unknown
override: ${{ matrix.rust_release == 'latest-nightly' }}

- name: Get wasm-bindgen version
id: wasm-bindgen-version
run: echo "VERSION=$(cargo pkgid wasm-bindgen-shared | cut -d '@' -f2)" >> "$GITHUB_OUTPUT"
- name: Install cargo-nextest (windows)
if: ${{ matrix.os == 'windows-latest' }}
shell: bash
run: curl -LsSf https://get.nexte.st/latest/windows-tar | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin

- name: Install WebAssembly test runner
- name: Run cargo nextest on all targets
uses: actions-rs/cargo@v1
with:
command: install
args: wasm-bindgen-cli@${{ steps.wasm-bindgen-version.outputs.VERSION }}
command: nextest
args: run --no-fail-fast --features python --all-targets

- name: Run cargo test
- name: Run doctests
uses: actions-rs/cargo@v1
env:
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER: wasm-bindgen-test-runner
with:
command: test
args: -p hydroflow --target wasm32-unknown-unknown --tests --no-fail-fast

test-cli:
name: Test CLI
if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.event_name != 'pull_request' }}
timeout-minutes: 25
needs: pre_job
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
args: --no-fail-fast --features python --doc

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Build CLI
- name: Build CLI (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cd hydro_deploy/hydro_cli
python -m venv .venv
source .venv/bin/activate
pip install maturin
maturin develop
- name: Build CLI (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
cd hydro_deploy/hydro_cli
python -m venv .venv
.venv/Scripts/activate
pip install maturin
maturin develop
- name: Run Python tests
- name: Run Python tests (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
ulimit -c unlimited
cd hydro_deploy/hydro_cli
source .venv/bin/activate
cd python_tests
pip install -r requirements.txt
RUST_BACKTRACE=1 pytest *.py
RUST_BACKTRACE=1 pytest
- name: Run Python tests (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
cd hydro_deploy/hydro_cli
.venv/Scripts/activate
cd python_tests
pip install -r requirements.txt
pytest
lints:
name: Lints
test-wasm:
name: Test Suite (WebAssembly)
if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.event_name != 'pull_request' }}
timeout-minutes: 10
timeout-minutes: 15
needs: pre_job
runs-on: ubuntu-latest
strategy:
Expand All @@ -250,20 +251,26 @@ jobs:
with:
profile: minimal
toolchain: nightly
target: wasm32-unknown-unknown
override: ${{ matrix.rust_release == 'latest-nightly' }}
components: rustfmt, clippy

- name: Run cargo fmt
- name: Get wasm-bindgen version
id: wasm-bindgen-version
run: echo "VERSION=$(cargo pkgid wasm-bindgen-shared | cut -d '@' -f2)" >> "$GITHUB_OUTPUT"

- name: Install WebAssembly test runner
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
command: install
args: wasm-bindgen-cli@${{ steps.wasm-bindgen-version.outputs.VERSION }}

- name: Run cargo clippy
- name: Run cargo test
uses: actions-rs/cargo@v1
env:
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER: wasm-bindgen-test-runner
with:
command: clippy
args: --all-targets --features python -- -D warnings
command: test
args: -p hydroflow --target wasm32-unknown-unknown --tests --no-fail-fast

build-website:
name: Build Website
Expand Down
47 changes: 7 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ strip = true # Strip symbols from the binary
opt-level = 3
lto = "fat"

# There is only around 19GB of free space on the github free default runners
# without stripping the debug info, the build artefacts take up about 19GB
# with stripping the debug info, they take up about 5GB, so in ci we can use this profile to
# avoid running out of disk space.
[profile.cidev]
inherits = "dev"
strip = "debuginfo"

[profile.profile]
inherits = "release"
debug = 2
Expand Down
Loading

0 comments on commit 6c9c9a9

Please sign in to comment.