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

Refactor Makefile.toml and use it as the source of truth for (almost) all CI #783

Merged
merged 24 commits into from
Jun 10, 2021
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
32 changes: 2 additions & 30 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,15 @@

[alias]

### INDIVIDUAL TEST AND LINT TASKS ###

# Build and run all code paths except docs
test-all = "test --all-features --all-targets"

# Build and run all docs tests
test-docs = "test --all-features --doc"

# Build and run docs tests with default features
test-docs-defaults = "test --doc"

# Check for formatting on all code
fmt-check = "fmt -- --check"

# Check for license headers
license-check = "make license-header-check"

# Check for generated README.md
readme-check = "make generated-readme-check"
quick = "make quick"
tidy = "make tidy"

# Run Clippy on all code paths
# Keep args in sync with `clippy` job in .github/workflows/build-test.yml
# unknown-clippy-lints: to allow us to work with nightly clippy lints that we don't CI
# field-reassign-with-default: https://github.com/rust-lang/rust-clippy/issues/6559 (fixed in nightly but not stable)
clippy-all = "clippy --all-features --all-targets -- -D warnings -Aclippy::field-reassign-with-default"

### META TASKS ###

# Run quick version of all lints and tests
quick = "make quick"

# Run all lints and tests
ci = "make ci"
Manishearth marked this conversation as resolved.
Show resolved Hide resolved

# Run all lints and tests
bincode-gen-testdata = "make bincode-gen-testdata"

### WASM TASKS ###

# Re-build standard library with panic=abort.
Expand Down
212 changes: 161 additions & 51 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ name: Build and Test

# TODO(#234) re-include cache steps, also using Rust version in cache key

# Note: Each of these jobs, except for the clippy job and the optional benchmarking/coverage
# jobs, maps to a `ci-job-foo` entry in Makefile.toml. If adding further CI jobs, please add them
# as makefile targets as well, and list them under `ci-all`.
#
# Clippy is special because we're using actions-rs/clippy-check which is able to surface clippy failures on
# PR bodies

on:
push:
branches: [ main ]
Expand All @@ -15,17 +22,38 @@ on:
jobs:

# Build job - basic smoke test
build:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Load the default Rust toolchain via the rust-toolchain file.
run: rustup show

- name: Get cargo-make version
id: cargo-make-version
run: |
echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)"
shell: bash
- name: Attempt to load cached cargo-make
uses: actions/cache@v2
id: cargo-make-cache
with:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }}
- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
uses: actions-rs/[email protected]
with:
crate: cargo-make
version: latest

- name: Check
Manishearth marked this conversation as resolved.
Show resolved Hide resolved
uses: actions-rs/[email protected]
with:
command: check
args: --all-targets --all-features
command: make
args: ci-job-check

# Test job - runs all "cargo make" testing commands
test:
Expand All @@ -39,26 +67,43 @@ jobs:
- uses: actions/checkout@v2
- name: Load the default Rust toolchain via the rust-toolchain file.
run: rustup show

- name: Get cargo-make version
id: cargo-make-version
run: |
echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)"
shell: bash
- name: Attempt to load cached cargo-make
uses: actions/cache@v2
id: cargo-make-cache
with:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }}
- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
uses: actions-rs/[email protected]
with:
crate: cargo-make
version: latest

- name: Build
uses: actions-rs/[email protected]
with:
command: build
args: --all-targets --all-features
- name: Test All Targets
uses: actions-rs/[email protected]
with:
command: test-all
- name: Test Docs
- name: Run `cargo make ci-job-test`
uses: actions-rs/[email protected]
with:
command: test-docs
command: make
args: ci-job-test


# Feature coverage job - builds all permutations of features
features:
runs-on: ubuntu-latest
needs: [build]

needs: [check]
steps:
- uses: actions/checkout@v2
- name: Load the default Rust toolchain via the rust-toolchain file.
Expand All @@ -68,19 +113,37 @@ jobs:
with:
command: install
args: cargo-all-features --version "^1.4"
- name: Test Docs with Default Features
uses: actions-rs/[email protected]

- name: Get cargo-make version
id: cargo-make-version
run: |
echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)"
shell: bash
- name: Attempt to load cached cargo-make
uses: actions/cache@v2
id: cargo-make-cache
with:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }}
- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
uses: actions-rs/[email protected]
with:
command: test-docs-defaults
crate: cargo-make
version: latest

- name: Build All Feature Permutations
uses: actions-rs/[email protected]
with:
command: build-all-features
command: make
args: ci-job-features

# WASM Tests - runs Node.js tests for WASM bindings
wasm:
runs-on: ubuntu-latest
needs: [build]
needs: [check]

steps:
- uses: actions/checkout@v2
Expand All @@ -92,11 +155,27 @@ jobs:
run: |
sudo apt-get install wabt binaryen
cargo install twiggy

- name: Get cargo-make version
id: cargo-make-version
run: |
echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)"
shell: bash
- name: Attempt to load cached cargo-make
uses: actions/cache@v2
id: cargo-make-cache
with:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }}
- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
uses: actions-rs/[email protected]
with:
crate: cargo-make
version: latest

- name: Build
uses: actions-rs/[email protected]
with:
Expand All @@ -106,14 +185,14 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: 14.17.0
- name: Test
run: |
npm install
npm test
working-directory: ./ffi/wasm/test
- name: Build
uses: actions-rs/[email protected]
with:
command: make
args: wasm-test-release

# Lint job - runs all "cargo make" linting commands
lint:
# Fmt job - runs cargo fmt
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -124,60 +203,91 @@ jobs:
- name: Install rustfmt
run: rustup component add rustfmt


- name: Get cargo-make version
id: cargo-make-version
run: |
echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)"
shell: bash
- name: Attempt to load cached cargo-make
uses: actions/cache@v2
id: cargo-make-cache
with:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }}
- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
uses: actions-rs/[email protected]
with:
crate: cargo-make
version: latest

- name: Install cargo-readme
uses: actions-rs/[email protected]
with:
crate: cargo-readme
version: latest

# TODO(#234) re-include cache steps, also using Rust version in cache key

- name: Check Format
uses: actions-rs/[email protected]
with:
command: fmt-check

- name: Check License Headers
uses: actions-rs/[email protected]
with:
command: license-check
command: make
args: ci-job-fmt

- name: Check Generated README.md
uses: actions-rs/[email protected]
with:
command: readme-check

# Bincode job - Test that the bincode data provider can be generated correctly.
bincode:
# Tidy job - runs all "cargo make" tidy commands
tidy:
runs-on: ubuntu-latest
# Wait for the initial build to finish. Note that this step does not currently re-use any
# artifacts from the build step. It's only waiting on the build to minimize resource use
# in case the build fails.
needs: [build]
steps:
- uses: actions/checkout@v2

- name: Load the default Rust toolchain via the rust-toolchain file.
run: rustup show

- name: Get cargo-make version
id: cargo-make-version
run: |
echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)"
shell: bash
- name: Attempt to load cached cargo-make
uses: actions/cache@v2
id: cargo-make-cache
with:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }}
- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
uses: actions-rs/[email protected]
with:
crate: cargo-make
version: latest

- name: Get cargo-readme version
id: cargo-readme-version
run: |
echo "::set-output name=hash::$(cargo search cargo-readme | grep '^cargo-readme =' | md5sum)"
shell: bash
- name: Attempt to load cached cargo-readme
uses: actions/cache@v2
id: cargo-readme-cache
with:
path: |
~/.cargo/bin/cargo-readme
~/.cargo/bin/cargo-readme.exe
key: ${{ runner.os }}-${{ steps.cargo-readme-version.outputs.hash }}
- name: Install cargo-readme
if: steps.cargo-readme-cache.outputs.cache-hit != 'true'
uses: actions-rs/[email protected]
with:
crate: cargo-readme
version: latest

# TODO(#234) re-include cache steps, also using Rust version in cache key

- name: Build the bincode
- name: Tidy
uses: actions-rs/[email protected]
with:
command: bincode-gen-testdata
command: make
args: ci-job-tidy

# Clippy job (cargo-clippy) - completes and puts warnings inline in PR
clippy:
Expand Down Expand Up @@ -223,7 +333,7 @@ jobs:

runs-on: ubuntu-latest

needs: [build]
needs: [check]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -354,7 +464,7 @@ jobs:

# Only run the memory benchmark if the main build succeeded. The memory benchmark does not
# rely on any of the build artifacts.
needs: [build]
needs: [check]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -451,7 +561,7 @@ jobs:

runs-on: ubuntu-latest

needs: [build, lint, bincode, benchmark, memory]
needs: [check, tidy, benchmark, memory]

## Only create docs for merges/pushes to main (skip PRs).
## Multiple unfinished PRs should not clobber docs from approved code.
Expand Down
Loading