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

Fix codegen (#1) #3

Closed
wants to merge 15 commits into from
Closed
110 changes: 95 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,113 @@
name: CI

on: [push, pull_request]

name: CI
env:
RUST_BACKTRACE: 1

jobs:
build:

##########################
# Linting and formatting #
##########################

clippy:
name: Clippy
if: ${{ github.ref == 'refs/heads/master'
|| startsWith(github.ref, 'refs/tags/v')
|| !contains(github.event.head_commit.message, '[skip ci]') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy

- run: make lint

rustfmt:
name: Rustfmt
if: ${{ github.ref == 'refs/heads/master'
|| startsWith(github.ref, 'refs/tags/v')
|| !contains(github.event.head_commit.message, '[skip ci]') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt

- run: make fmt check=yes




###########
# Testing #
###########

test:
name: Test
if: ${{ github.ref == 'refs/heads/master'
|| startsWith(github.ref, 'refs/tags/v')
|| !contains(github.event.head_commit.message, '[skip ci]') }}
strategy:
fail-fast: false
matrix:
rust:
crate:
- cucumber_rust
- cucumber_rust_codegen
os:
- ubuntu
- macOS
- windows
toolchain:
- stable
- beta
- nightly
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
toolchain: ${{ matrix.toolchain }}
override: true
components: rustfmt, clippy
- uses: actions-rs/cargo@v1
with:
command: build
args: --all-features
- uses: actions-rs/cargo@v1

- run: make test crate=${{ matrix.crate }}




#################
# Documentation #
#################

docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
command: test
args: -p cucumber_rust_codegen
- uses: actions-rs/cargo@v1
profile: minimal
toolchain: nightly
override: true

- run: make doc open=no

- name: Finalize documentation
run: |
CRATE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]' | cut -f2 -d"/")
echo "<meta http-equiv=\"refresh\" content=\"0; url=${CRATE_NAME/-/_}\">" > target/doc/index.html
touch target/doc/.nojekyll

- name: Upload as artifact
uses: actions/upload-artifact@v2
with:
command: test
args: --all-features
name: Documentation
path: target/doc
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/.idea/
/*.iml
.DS_Store

/target
**/*.rs.bk
/.cache/

/target
**/*.rs.bk
Cargo.lock
.idea/
.vscode/launch.json
16 changes: 16 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Project configuration for rustfmt Rust code formatter.
# See full list of configurations at:
# https://github.com/rust-lang-nursery/rustfmt/blob/master/Configurations.md

max_width = 80
format_strings = false
imports_granularity = "Crate"

format_code_in_doc_comments = true
format_macro_matchers = true
use_try_shorthand = true

error_on_line_overflow = true
error_on_unformatted = true

unstable_features = true
45 changes: 15 additions & 30 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,30 @@ version = "0.8.4"
macros = ["cucumber_rust_codegen", "inventory"]

[dependencies]
async-stream = "0.3.0"
async-trait = "0.1.40"
clap = "2.33"
cute_custom_default = "2.1.0"
futures = "0.3.5"
futures-timer = "3.0.2"
gherkin = {package = "gherkin_rust", version = "0.10"}
globwalk = "0.8.0"
pathdiff = "0.2.0"
regex = "1.3.9"
shh = "1.0.1"
termcolor = "1.1.0"
textwrap = {version = "0.12.1", features = ["terminal_size"]}
thiserror = "1.0.20"
tracing = "0.1.25"
async-trait = "0.1"
console = "0.14"
either = "1.6"
futures = "0.3"
gherkin = { package = "gherkin_rust", version = "0.10" }
globwalk = "0.8"
itertools = "0.10"
linked-hash-map = "0.5"
regex = "1.5"
sealed = "0.3"

# Codegen dependencies
cucumber_rust_codegen = {version = "0.1", path = "./codegen", optional = true}
inventory = {version = "0.1", optional = true}
once_cell = "1.7.0"
cucumber_rust_codegen = { version = "0.1", path = "./codegen", optional = true }
inventory = { version = "0.1", optional = true }

[dev-dependencies]
capture-runner = {path = "tests/fixtures/capture-runner"}
serial_test = "0.5.0"
tokio = {version = "1", features = ["macros", "rt-multi-thread"]}
tracing-subscriber = {version = "0.2.16", features = ["fmt"]}
tokio = { version = "1.8", features = ["macros", "rt-multi-thread", "time"] }

[[test]]
harness = false
name = "cucumber_builder"

[[test]]
edition = "2018"
harness = true
name = "integration_test"
name = "wait"

[workspace]
default-members = [".", "codegen"]
members = ["codegen", "tests/fixtures/capture-runner"]
members = ["codegen"]

[package.metadata.docs.rs]
all-features = true
Expand Down
90 changes: 90 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
###############################
# Common defaults/definitions #
###############################

comma := ,

# Checks two given strings for equality.
eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
$(findstring $(2),$(1))),1)




###########
# Aliases #
###########


doc: cargo.doc


fmt: cargo.fmt


lint: cargo.lint




##################
# Cargo commands #
##################

# Generate crates documentation from Rust sources.
#
# Usage:
# make cargo.doc [crate=<crate-name>] [open=(yes|no)] [clean=(no|yes)]
#

cargo.doc:
ifeq ($(clean),yes)
@rm -rf target/doc/
endif
cargo +stable doc $(if $(call eq,$(crate),),--workspace,-p $(crate)) \
--all-features \
$(if $(call eq,$(open),no),,--open)


# Format Rust sources with rustfmt.
#
# Usage:
# make cargo.fmt [check=(no|yes)]

cargo.fmt:
cargo +nightly fmt --all $(if $(call eq,$(check),yes),-- --check,)


# Lint Rust sources with Clippy.
#
# Usage:
# make cargo.lint

cargo.lint:
cargo +stable clippy --workspace -- -D clippy::pedantic -D warnings




####################
# Testing commands #
####################

# Run Rust tests of project.
#
# Usage:
# make test [crate=<crate-name>]

test:
cargo +stable test $(if $(call eq,$(crate),),--workspace,-p $(crate)) \
--all-features




##################
# .PHONY section #
##################

.PHONY: doc fmt lint test \
cargo.doc cargo.fmt cargo.lint
6 changes: 3 additions & 3 deletions codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ proc-macro = true

[dependencies]
inflections = "1.1"
itertools = "0.9"
itertools = "0.10"
proc-macro2 = "1.0"
quote = "1.0"
regex = "1.4"
syn = { version = "1.0", features = ["derive", "extra-traits", "full"] }

[dev-dependencies]
async-trait = "0.1.41"
async-trait = "0.1"
futures = "0.3"
cucumber_rust = { path = "../", features = ["macros"] }
tokio = { version = "0.3", features = ["macros", "rt-multi-thread", "time"] }
tokio = { version = "1.8", features = ["macros", "rt-multi-thread", "time"] }

[[test]]
name = "example"
Expand Down
Loading