Skip to content

Commit

Permalink
chore: move sdk source code to a subdir (#338)
Browse files Browse the repository at this point in the history
* chore: move sdk source code to a subdir

Having Cargo.toml at the root causes problems where other
Cargo.toml files (e.g. in the examples dir) end up thinking that
they are part of a cargo workspace. This is causing problems
when trying to build lambda examples.

It's better for the SDK's Cargo.toml to not exist in a parent dir
of any Cargo.toml files that are not related to the SDK library
itself. To that end, this commit moves all of the SDK code into
a subdir called `sdk`. The `Makefile` is still at the root, and
the targets have been updated to descend into the sdk directory
before executing.
  • Loading branch information
cprice404 authored May 22, 2024
1 parent 866af17 commit 8eddf9a
Show file tree
Hide file tree
Showing 102 changed files with 3,494 additions and 18 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ jobs:
- name: Build
run: make build
- name: Test Setup
# This script relies on dev dependencies such as Tokio, so we run it with the --example flag
run: cargo run --example test-setup
run: make ci-test-setup
- name: Unit tests
run: make test-unit
- name: Integration Tests
Expand All @@ -78,8 +77,7 @@ jobs:
- name: Test Teardown
# We want the teardown to execute even if an earlier step fails, hence the `always()` condition
if: always()
# This script relies on dev dependencies such as Tokio, so we run it with the --example flag
run: cargo run --example test-teardown
run: make ci-test-teardown

- name: Run examples
run: make run-examples
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/on-push-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,7 @@ jobs:
run: cargo login $CARGO_REGISTRY_TOKEN

- name: Publish
run: cargo publish
run: |
cd sdk
cargo publish
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@

# Generated by Cargo
# will have compiled files and executables
/target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
target

# These are backup files generated by rustfmt
**/*.rs.bk
27 changes: 19 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ all: precommit
## Check the formatting of all files, run clippy on the source code, then run
## clippy on the tests (but allow expect to be used in tests)
lint:
cargo fmt -- --check
cargo clippy --all-features -- -D warnings -W clippy::unwrap_used -W clippy::expect_used -W missing_docs
cd sdk && \
cargo fmt -- --check && \
cargo clippy --all-features -- -D warnings -W clippy::unwrap_used -W clippy::expect_used -W missing_docs && \
cargo clippy --tests -- -D warnings -W clippy::unwrap_used

.PHONY: build
## Build project
build:
cargo build --verbose
cd sdk && cargo build --verbose

.PHONY: clean
## Remove build files
clean:
cargo clean
cd sdk && cargo clean

.PHONY: clean-build
## Build project
Expand All @@ -27,7 +28,7 @@ clean-build: clean build
.PHONY: docs
## Build the docs, fail on warnings
docs:
RUSTDOCFLAGS="-D warnings" cargo doc
cd sdk && RUSTDOCFLAGS="-D warnings" cargo doc

.PHONY: precommit
## Run clean-build and test as a step before committing.
Expand All @@ -36,16 +37,26 @@ precommit: clean-build lint test build-examples

.PHONY: test-unit
test-unit:
cargo test --lib
cd sdk && cargo test --lib

.PHONY: test-doctests
test-doctests:
cargo test --doc
cd sdk && cargo test --doc

.PHONY: ci-test-setup
ci-test-setup:
# This script relies on dev dependencies such as Tokio, so we run it with the --example flag
cd sdk && cargo run --example test-setup

.PHONY: test-integration
## Run integration tests
test-integration:
cargo test --tests
cd sdk && cargo test --tests

.PHONY: ci-test-teardown
ci-test-teardown:
# This script relies on dev dependencies such as Tokio, so we run it with the --example flag
cd sdk && cargo run --example test-teardown

.PHONY: test
## Run unit and integration tests
Expand Down
Loading

0 comments on commit 8eddf9a

Please sign in to comment.