Skip to content

Commit

Permalink
refactor: Move the examples workspace manifest into examples director…
Browse files Browse the repository at this point in the history
…y. Use it in CI. (FuelLabs#4145)

## Description

This moves the examples workspace manifest introduced in FuelLabs#4118 into the
`examples/` directory and cleans it up a bit.

We also now integrate the examples workspace into CI, making the old
`examples-checker` script redundant. This old script is also removed as
a part of this PR.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
  • Loading branch information
mitchmindtree authored Feb 21, 2023
1 parent d1c2ed9 commit 4ffa867
Show file tree
Hide file tree
Showing 38 changed files with 192 additions and 563 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,8 @@ jobs:
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
- name: Install Forc
run: cargo install --locked --debug --path ./forc
- name: Install Forc fmt
run: cargo install --locked --debug --path ./forc-plugins/forc-fmt
- name: Build Sway examples
run: cargo run --locked --bin examples-checker build --all-examples
- name: Build Sway examples workspace
run: cargo run --locked -p forc -- build --locked --path ./examples/Forc.toml

forc-fmt-check-sway-examples:
runs-on: ubuntu-latest
Expand All @@ -72,12 +68,8 @@ jobs:
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
- name: Install Forc
run: cargo install --locked --debug --path ./forc
- name: Install Forc fmt
run: cargo install --locked --debug --path ./forc-plugins/forc-fmt
- name: Check Sway examples formatting
run: cargo run --locked --bin examples-checker fmt --all-examples
run: cargo run --locked -p forc-fmt -- --check --path ./examples/Forc.toml

build-mdbook:
runs-on: ubuntu-latest
Expand Down
8 changes: 0 additions & 8 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ members = [
"forc-test",
"forc-tracing",
"forc-util",
"scripts/examples-checker",
"scripts/mdbook-forc-documenter",
"sway-ast",
"sway-core",
Expand Down
4 changes: 2 additions & 2 deletions ci_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ forc build --path sway-lib-core &&
forc test --path sway-lib-core &&
forc build --path sway-lib-std &&
forc test --path sway-lib-std &&
cargo run --locked --bin examples-checker build --all-examples &&
cargo run --locked --bin examples-checker fmt --all-examples &&
cargo run --locked -p forc -- build --locked --path ./examples/Forc.toml &&
cargo run --locked -p forc-fmt -- --check --path ./examples/Forc.toml &&
rm -Rf test-proj &&
forc new test-proj &&
echo "std = { path = \"../sway-lib-std/\" }" >> test-proj/Forc.toml &&
Expand Down
153 changes: 153 additions & 0 deletions examples/Forc.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
[[package]]
name = 'abi_supertraits'
source = 'member'

[[package]]
name = 'array'
source = 'member'
dependencies = ['std']

[[package]]
name = 'asm_return_tuple_pointer'
source = 'member'
dependencies = ['std']

[[package]]
name = 'break_and_continue'
source = 'member'
dependencies = ['core']

[[package]]
name = 'cei_analysis'
source = 'member'
dependencies = ['std']

[[package]]
name = 'config_time_constants'
source = 'member'

[[package]]
name = 'core'
source = 'path+from-root-087D5D776F294F03'

[[package]]
name = 'counter'
source = 'member'
dependencies = ['std']

[[package]]
name = 'enums'
source = 'member'

[[package]]
name = 'fizzbuzz'
source = 'member'
dependencies = ['std']

[[package]]
name = 'hashing'
source = 'member'
dependencies = ['std']

[[package]]
name = 'identity'
source = 'member'
dependencies = ['std']

[[package]]
name = 'liquidity_pool'
source = 'member'
dependencies = ['std']

[[package]]
name = 'match_statements'
source = 'member'
dependencies = ['std']

[[package]]
name = 'msg_sender'
source = 'member'
dependencies = ['std']

[[package]]
name = 'mut_ref_params'
source = 'member'
dependencies = ['std']

[[package]]
name = 'native_token'
source = 'member'
dependencies = ['std']

[[package]]
name = 'ownership'
source = 'member'
dependencies = ['std']

[[package]]
name = 'signatures'
source = 'member'
dependencies = ['std']

[[package]]
name = 'std'
source = 'path+from-root-087D5D776F294F03'
dependencies = ['core']

[[package]]
name = 'storage_example'
source = 'member'
dependencies = ['std']

[[package]]
name = 'storage_map'
source = 'member'
dependencies = ['std']

[[package]]
name = 'storage_variables'
source = 'member'

[[package]]
name = 'storage_vec'
source = 'member'
dependencies = ['std']

[[package]]
name = 'structs'
source = 'member'

[[package]]
name = 'subcurrency'
source = 'member'
dependencies = ['std']

[[package]]
name = 'tuples'
source = 'member'

[[package]]
name = 'vec'
source = 'member'
dependencies = ['std']

[[package]]
name = 'wallet_abi'
source = 'member'
dependencies = ['std']

[[package]]
name = 'wallet_contract_caller_script'
source = 'member'
dependencies = [
'std',
'wallet_abi',
]

[[package]]
name = 'wallet_smart_contract'
source = 'member'
dependencies = [
'std',
'wallet_abi',
]
34 changes: 34 additions & 0 deletions examples/Forc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workspace is a collection of packages that manages all the example contracts
# in the Sway repo, where each example is a package member of the workspace.
[workspace]
members = [
"abi_supertraits",
"arrays",
"asm_return_tuple_pointer",
"break_and_continue",
"cei_analysis",
"config_time_constants",
"counter",
"enums",
"fizzbuzz",
"hashing",
"identity",
"liquidity_pool",
"match_statements",
"msg_sender",
"native_token",
"ownership",
"ref_mut_params",
"signatures",
"storage_example",
"storage_map",
"storage_variables",
"storage_vec",
"structs",
"subcurrency",
"tuples",
"vec",
"wallet_abi",
"wallet_contract_caller_script",
"wallet_smart_contract",
]
3 changes: 0 additions & 3 deletions examples/abi_supertraits/Forc.lock

This file was deleted.

13 changes: 0 additions & 13 deletions examples/arrays/Forc.lock

This file was deleted.

13 changes: 0 additions & 13 deletions examples/asm_return_tuple_pointer/Forc.lock

This file was deleted.

8 changes: 0 additions & 8 deletions examples/break_and_continue/Forc.lock

This file was deleted.

13 changes: 0 additions & 13 deletions examples/cei_analysis/Forc.lock

This file was deleted.

3 changes: 0 additions & 3 deletions examples/config_time_constants/Forc.lock

This file was deleted.

13 changes: 0 additions & 13 deletions examples/counter/Forc.lock

This file was deleted.

3 changes: 0 additions & 3 deletions examples/enums/Forc.lock

This file was deleted.

13 changes: 0 additions & 13 deletions examples/fizzbuzz/Forc.lock

This file was deleted.

13 changes: 0 additions & 13 deletions examples/hashing/Forc.lock

This file was deleted.

13 changes: 0 additions & 13 deletions examples/identity/Forc.lock

This file was deleted.

13 changes: 0 additions & 13 deletions examples/liquidity_pool/Forc.lock

This file was deleted.

13 changes: 0 additions & 13 deletions examples/match_statements/Forc.lock

This file was deleted.

Loading

0 comments on commit 4ffa867

Please sign in to comment.