Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
fix: remove cyclic dep (#1284)
Browse files Browse the repository at this point in the history
Co-authored-by: Rashad Alston <[email protected]>
  • Loading branch information
ra0x3 and Rashad Alston authored Aug 18, 2023
1 parent d8ccc1d commit 551a06d
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 107 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ jobs:
- name: Set env vars
id: set-env
run: >
echo "IS_MASTER=${{ env.IS_MASTER }}" >> $GITHUB_OUTPUT
echo "IS_MASTER=${{ env.IS_MASTER }}" >> $GITHUB_OUTPUT
echo "IS_DEVELOP=${{ env.IS_DEVELOP }}" >> $GITHUB_OUTPUT
echo "IS_DEVELOP=${{ env.IS_DEVELOP }}" >> $GITHUB_OUTPUT
echo "IS_RELEASE=${{ env.IS_RELEASE }}" >> $GITHUB_OUTPUT
echo "IS_RELEASE=${{ env.IS_RELEASE }}" >> $GITHUB_OUTPUT
if [[ ${{ env.IS_MASTER }} == 'true' || ${{ env.IS_DEVELOP }} == 'true' || ${{ env.IS_RELEASE }} == 'true' || ${{ env.BRANCH_NAME }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "IS_RELEASE_OR_MASTER_OR_DEVELOP_OR_SEMVER=true" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -266,8 +266,12 @@ jobs:
- name: Run E2E and integration tests
run: cargo test --locked --all-targets --features postgres -p
fuel-indexer-tests -- --test-threads=1
- name: Run trybuild tests
run: cargo test --locked --all-targets --features trybuild -p
fuel-indexer-tests
build-default-indexer:
if: needs.set-env-vars.outputs.IS_RELEASE_OR_MASTER_OR_DEVELOP_OR_SEMVER != 'true'
# if: needs.set-env-vars.outputs.IS_RELEASE_OR_MASTER_OR_DEVELOP_OR_SEMVER != 'true'
if: false
needs:
- cargo-toml-fmt-check
- set-env-vars
Expand Down Expand Up @@ -318,8 +322,9 @@ jobs:
cd ..
rm -rfv indexer-test
build-and-test-examples:
if: needs.set-env-vars.outputs.IS_RELEASE_OR_MASTER_OR_DEVELOP_OR_SEMVER !=
'true'
# if: needs.set-env-vars.outputs.IS_RELEASE_OR_MASTER_OR_DEVELOP_OR_SEMVER !=
# 'true'
if: false
needs:
- cargo-toml-fmt-check
- set-env-vars
Expand Down
12 changes: 5 additions & 7 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Fuel indexer tests are currently broken out by a database feature flag. In order

Further, the indexer uses end-to-end (E2E) tests. In order to trigger these end-to-end tests, you'll want to use the `e2e` features flag: `--features e2e`.

> All end-to-end tests also require the use of a database feature. For example, to run the end-to-end tests with a Posgres backend, use `--features e2e,postgres`.
> All end-to-end tests also require the use of a database feature. For example, to run the end-to-end tests with a Posgres backend, use `--features postgres`.
### Default tests

Expand All @@ -202,15 +202,15 @@ cargo test --locked --workspace --all-targets
### End-to-end tests

```bash
cargo test --locked --workspace --all-targets --features e2e,postgres
cargo test --locked --workspace --all-targets --features postgres
```

### `trybuild` tests

For tests related to the meta-programming used in the Fuel indexer, we use `trybuild`.

```bash
RUSTFLAGS='-D warnings' cargo test -p fuel-indexer-macros --locked
RUSTFLAGS='-D warnings' cargo test -p fuel-indexer-tests --features trybuild --locked
```

## Contributing
Expand Down
4 changes: 2 additions & 2 deletions docs/src/for-contributors/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Fuel indexer tests are currently broken out by a database feature flag. In order

Further, the indexer uses end-to-end (E2E) tests. In order to trigger these end-to-end tests, you'll want to use the `e2e` features flag: `--features e2e`.

> All end-to-end tests also require the use of a database feature. For example, to run the end-to-end tests with a Posgres backend, use `--features e2e,postgres`.
> All end-to-end tests also require the use of a database feature. For example, to run the end-to-end tests with a Posgres backend, use `--features postgres`.
### Default tests

Expand All @@ -92,7 +92,7 @@ cargo test --locked --workspace --all-targets
### End-to-end tests

```bash
cargo test --locked --workspace --all-targets --features e2e,postgres
cargo test --locked --workspace --all-targets --features postgres
```

### `trybuild` tests
Expand Down
7 changes: 0 additions & 7 deletions packages/fuel-indexer-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,5 @@ serde_json = { workspace = true }
sha2 = "0.10"
syn = { version = "2.0", features = ["full"] }

[dev-dependencies]
fuel-indexer-plugin = { workspace = true }
fuel-indexer-utils = { workspace = true }
fuels-macros = { version = "0.46", default-features = false }
serde = { workspace = true }
trybuild = "1.0"

[features]
default = ["fuel-indexer-schema/db-models"]
27 changes: 0 additions & 27 deletions packages/fuel-indexer-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,3 @@ use proc_macro::TokenStream;
pub fn indexer(attrs: TokenStream, item: TokenStream) -> TokenStream {
process_indexer_module(attrs, item)
}

#[cfg(test)]
mod tests {
#[test]
fn test_success_and_failure_macros() {
let t = trybuild::TestCases::new();
let manifest_dir = env!("CARGO_MANIFEST_DIR");
std::env::set_var("COMPILE_TEST_PREFIX", manifest_dir);

let macro_data_root = std::path::Path::new(manifest_dir)
.join("..")
.join("fuel-indexer-tests")
.join("trybuild");

t.compile_fail(macro_data_root.join("fail_if_attribute_args_include_self.rs"));
t.compile_fail(macro_data_root.join("fail_if_attribute_args_not_included.rs"));
t.pass(macro_data_root.join("pass_if_indexer_is_valid_single_type.rs"));
t.pass(macro_data_root.join("pass_if_indexer_is_valid_multi_type.rs"));
t.compile_fail(
macro_data_root.join("fail_if_attribute_schema_arg_is_invalid.rs"),
);
t.compile_fail(
macro_data_root.join("fail_if_attribute_abi_arg_includes_invalid_type.rs"),
);
t.compile_fail(macro_data_root.join("fail_if_indexer_module_is_empty.rs"));
}
}
8 changes: 8 additions & 0 deletions packages/fuel-indexer-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ fuel-indexer-api-server = { workspace = true }
fuel-indexer-database = { workspace = true }
fuel-indexer-graphql = { workspace = true }
fuel-indexer-lib = { workspace = true }
fuel-indexer-plugin = { workspace = true }
fuel-indexer-postgres = { workspace = true, features = ["metrics"] }
fuel-indexer-schema = { workspace = true, default-features = true }
fuel-indexer-types = { workspace = true }
fuel-indexer-utils = { workspace = true }
fuel-tx = { workspace = true }
fuels = { features = ["fuel-core-lib", "std"], version = "0.46" }
fuels-macros = { version = "0.46", default-features = false }
futures = "0.3"
hex = "0.4"
hyper = { version = "0.14", features = ["client", "http2", "http1", "runtime" ] }
Expand All @@ -53,6 +55,7 @@ thiserror = { workspace = true }
tokio = { features = ["macros", "rt-multi-thread"], workspace = true }
tracing = { workspace = true }
tracing-subscriber = { version = "0.2", features = ["env-filter"] }
trybuild = "1.0"
url = "2.3"
wasmer = "4"
wasmer-middlewares = "4"
Expand All @@ -61,3 +64,8 @@ wasmer-types = "4"
[features]
default = ["postgres"]
postgres = []

# Including trybuild tests with other integration tests causes $CARGO_MANIFEST_DIR to be switched from
# the workspace root level to the test crate level. This in turn causes the `abigen!` macro's path to be
# incorrect - thus the tests won't compile.
trybuild = []
Binary file modified packages/fuel-indexer-tests/indexers/simple-wasm/simple_wasm.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions packages/fuel-indexer-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(not(feature = "trybuild"))]
pub mod fixtures;

pub const WORKSPACE_ROOT: &str = env!("CARGO_MANIFEST_DIR");
Expand Down
10 changes: 7 additions & 3 deletions packages/fuel-indexer-tests/tests/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#[cfg(feature = "postgres")]
#[cfg(all(feature = "postgres", not(feature = "trybuild")))]
mod graphql_server;

#[cfg(feature = "postgres")]
#[cfg(all(feature = "postgres", not(feature = "trybuild")))]
mod indexing;

#[cfg(not(feature = "trybuild"))]
mod service;

#[cfg(feature = "postgres")]
#[cfg(all(feature = "postgres", not(feature = "trybuild")))]
mod web_server;

#[cfg(feature = "trybuild")]
mod trybuild;
23 changes: 23 additions & 0 deletions packages/fuel-indexer-tests/tests/trybuild.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#[cfg(feature = "trybuild")]
#[test]
fn test_success_and_failure_macros() {
let t = trybuild::TestCases::new();
let manifest_dir = env!("CARGO_MANIFEST_DIR");

std::env::set_var("COMPILE_TEST_PREFIX", manifest_dir);

let macro_data_root = std::path::Path::new(manifest_dir)
.join("..")
.join("fuel-indexer-tests")
.join("trybuild");

t.compile_fail(macro_data_root.join("fail_if_attribute_args_include_self.rs"));
t.compile_fail(macro_data_root.join("fail_if_attribute_args_not_included.rs"));
t.pass(macro_data_root.join("pass_if_indexer_is_valid_single_type.rs"));
t.pass(macro_data_root.join("pass_if_indexer_is_valid_multi_type.rs"));
t.compile_fail(macro_data_root.join("fail_if_attribute_schema_arg_is_invalid.rs"));
t.compile_fail(
macro_data_root.join("fail_if_attribute_abi_arg_includes_invalid_type.rs"),
);
t.compile_fail(macro_data_root.join("fail_if_indexer_module_is_empty.rs"));
}
Loading

0 comments on commit 551a06d

Please sign in to comment.