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

Adds aliases between CI, config.toml, and Makefile.toml #376

Merged
merged 10 commits into from
Nov 10, 2020
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
23 changes: 23 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[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"

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

# Run Clippy on all code paths
clippy-all = "clippy --all-features --all-targets"

### META TASKS ###

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

# Run all lints and tests
ci = "make ci"
75 changes: 48 additions & 27 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,65 +11,86 @@ on:

jobs:

# Build job

build:

# Test job - runs all "cargo make" testing commands
test:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
feature-set: [ "", "--all-features" ] # no feature options ("") uses default.
# --no-default-features is not allowed
# at root of virtual workspace for
# both build and test.


runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

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

# Build job > Build and run steps

- name: Build
uses: actions-rs/[email protected]
with:
command: build
args: ${{ matrix.feature-set }} --verbose

- name: Test
args: --all-targets --all-features
- name: Test All Targets
uses: actions-rs/[email protected]
with:
command: test
args: ${{ matrix.feature-set }} --verbose
command: test-all
- name: Test Docs
uses: actions-rs/[email protected]
with:
command: test-docs

# Formatting job

format:
runs-on: ubuntu-latest

# Build job - builds all permutations of features
build:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Rust formatter
## make this command fail if cargo fmt had to make changes
run: cargo fmt && git diff-index --exit-code HEAD
# TODO(#234) re-include cache steps, also using Rust version in cache key

- name: Install cargo-all-features
uses: actions-rs/[email protected]
with:
command: install
args: cargo-all-features --version "^1.4"
- name: Build
uses: actions-rs/[email protected]
with:
command: build
args: --all-targets --all-features
- name: Build All Feature Permutations
uses: actions-rs/[email protected]
with:
command: build-all-features

# Linting job (cargo-clippy) - completes and puts warnings inline in PR

# Lint job - runs all "cargo make" linting commands
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

# 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

needs: [build]

# Clippy job (cargo-clippy) - completes and puts warnings inline in PR
clippy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

# Linting job > Install and run clippy steps
# Clippy job > Install and run clippy steps

- name: Install clippy
run: rustup component add clippy
Expand Down Expand Up @@ -190,7 +211,7 @@ jobs:

runs-on: ubuntu-latest

needs: [build, format, benchmark]
needs: [build, lint, benchmark]

## Only create docs for merges/pushes to master (skip PRs).
## Multiple unfinished PRs should not clobber docs from approved code.
Expand Down
7 changes: 6 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ That branch may end up containing one of more commits that are constituting the

### Checklist

Each commit and pull request should follow the [style guide](./docs/style-guide.md) and pass all checks such as tests and `cargo fmt`. If the PR is adding any public API changes, we'd also like to ensure that full coverage of `cargo doc` is preserved and code coverage is above `90%`.
Each commit and pull request should follow the [style guide](./docs/style-guide.md) and be properly formatted with `cargo fmt`. If the PR is adding any public API changes, we'd also like to ensure that full coverage of `cargo doc` is preserved and code coverage is above `90%`.

Handy commands (run from the root directory):

- `cargo quick` runs the fastest tests and lints.
- `cargo ci` runs all tests and lints.

### Structure of commits in a Pull Request

Expand Down
34 changes: 34 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[config]
default_to_workspace = false
load_cargo_aliases = true

### INDIVIDUAL TEST AND LINT TASKS ###
# Note: If a task is purely a cargo alias, define it in .cargo/config.toml

[tasks.build-all-features]
description = "Build all permutations of all features"
category = "ICU4X Development"
install_crate = { crate_name = "cargo-all-features", binary = "cargo-build-all-features", test_arg = ["--help"] }
install_crate_args = ["--version", "^1.4"]
command = "cargo"
args = ["build-all-features"]

### META TASKS ###

[tasks.quick]
description = "Run quick version of all lints and tests"
category = "ICU4X Development"
dependencies = [
"test-all",
"fmt-check",
"clippy-all",
]

[tasks.ci]
description = "Run all lints and tests"
category = "ICU4X Development"
dependencies = [
"quick",
"test-docs",
"build-all-features",
]
2 changes: 1 addition & 1 deletion components/plurals/benches/pluralrules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn pluralrules(c: &mut Criterion) {
});
});

let lid = langid!("pl");
let lid = langid!("be");
let pr = PluralRules::try_new(lid, &provider, PluralRuleType::Cardinal).unwrap();
c.bench_function("plurals/pluralrules/select/fs", |b| {
b.iter(|| {
Expand Down
7 changes: 7 additions & 0 deletions components/provider_cldr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ include = [
"README.md"
]

[package.metadata.cargo-all-features]
# Omit most optional dependency features from permutation testing
skip_optional_dependencies = true
extra_features = [
"log",
]

[dependencies]
icu_provider = { version = "0.1", path = "../provider" }
icu_locid = { version = "0.1", path = "../locid" }
Expand Down
12 changes: 12 additions & 0 deletions components/provider_fs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ include = [
"README.md"
]

[package.metadata.cargo-all-features]
# Skip combinations of export with bincode, since they are designed to fail
skip_feature_sets = [
["export", "bincode"],
["export-bin", "bincode"],
]
# Omit most optional dependency features from permutation testing
skip_optional_dependencies = true
extra_features = [
"log",
]

[dependencies]
icu_provider = { version = "0.1", path = "../provider" }
icu_locid = { version = "0.1", path = "../locid", features = ["serde"] }
Expand Down
9 changes: 8 additions & 1 deletion resources/testdata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ locales = [
# Git tag or sha1 for the CLDR data used to generate the testdata
gitref = "36.0.0"

[package.metadata.cargo-all-features]
# Omit most optional dependency features from permutation testing
skip_optional_dependencies = true
extra_features = [
"log",
]

[dependencies]
icu_provider = { version = "0.1", path = "../../components/provider" }
icu_provider_fs = { version = "0.1", path = "../../components/provider_fs" }
Expand All @@ -109,7 +116,7 @@ simple_logger = { version = "1.11", optional = true }
icu_locid_macros = { version = "0.1", path = "../../components/locid/macros" }

[features]
metadata = ["serde", "serde_json", "icu_locid/serde"]
metadata = ["cargo_metadata", "serde", "serde_json", "icu_locid/serde"]
icu4x-gen-testdata = [
"cargo_metadata",
"clap",
Expand Down