Skip to content

Commit

Permalink
Move build all examples (FuelLabs#1398)
Browse files Browse the repository at this point in the history
* Move build-all-examples to scripts

* Remove print

* Reorder scripts/build-all-examples alphabetically

* use clap for build-all-examples

* Cargo.lock update

* Take paths for build-all-examples

* Remove unused import

* Rename build-all-examples -> build-examples

* Update ci.yml with new build-examples command

* Update Cargo.lock

* Add help text for build-examples script

* Use --all and --paths args to differentiate between building all and specific paths

* build-examples --all -> --all-examples to make it even more explicit

* Better description for script

* Refactor script

* Rename build-examples to examples-checker

* update Cargo.toml and Cargo.lock with new script name

* Update CI workflow

* Better usage of Path

* Remove redundant builds, add dedicated fmt job

* Remove usage of success bool in run_forc_command

* Use [] instead of &Vec<>

* handle print_summary failure as error instead of exit(1)

Co-authored-by: bing <[email protected]>
  • Loading branch information
bing and bing authored May 2, 2022
1 parent 1d149d8 commit b89ec66
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 119 deletions.
49 changes: 37 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,36 @@ jobs:
with:
command: install
args: --debug --path ./forc-fmt
- name: Build Sway examples and check formatting
- name: Build Sway examples
uses: actions-rs/cargo@v1
with:
command: run
args: --bin build-all-examples
args: --bin examples-checker build --all-examples

forc-fmt-check-sway-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- uses: Swatinem/rust-cache@v1
- name: Install Forc
uses: actions-rs/cargo@v1
with:
command: install
args: --debug --path ./forc
- name: Install Forc fmt
uses: actions-rs/cargo@v1
with:
command: install
args: --debug --path ./forc-fmt
- name: Check Sway examples formatting
uses: actions-rs/cargo@v1
with:
command: run
args: --bin examples-checker fmt --all-examples

build-mdbook:
needs: cancel-previous-runs
Expand Down Expand Up @@ -122,11 +147,11 @@ jobs:
with:
command: install
args: --debug --path ./forc-fmt
- name: Build Sway examples and check formatting
- name: Build Sway examples
uses: actions-rs/cargo@v1
with:
command: run
args: --bin build-all-examples
args: --bin examples-checker build --all-examples
- uses: actions-rs/cargo@v1
name: Cargo Build Workspace
with:
Expand Down Expand Up @@ -154,11 +179,11 @@ jobs:
with:
command: install
args: --debug --path ./forc-fmt
- name: Build Sway examples and check formatting
- name: Build Sway examples
uses: actions-rs/cargo@v1
with:
command: run
args: --bin build-all-examples
args: --bin examples-checker build --all-examples
- name: Check Clippy Linter
uses: actions-rs/cargo@v1
with:
Expand Down Expand Up @@ -242,11 +267,11 @@ jobs:
with:
command: install
args: --debug --path ./forc-fmt
- name: Build Sway examples and check formatting
- name: Build Sway examples
uses: actions-rs/cargo@v1
with:
command: run
args: --bin build-all-examples
args: --bin examples-checker build --all-examples
- name: Build All Tests
run: cd test/src/sdk-harness && bash build.sh && cd ../../../
- name: Cargo Test sway-lib-std
Expand Down Expand Up @@ -275,11 +300,11 @@ jobs:
with:
command: install
args: --debug --path ./forc-fmt
- name: Build Sway examples and check formatting
- name: Build Sway examples
uses: actions-rs/cargo@v1
with:
command: run
args: --bin build-all-examples
args: --bin examples-checker build --all-examples
- name: Run tests
uses: actions-rs/cargo@v1
with:
Expand Down Expand Up @@ -327,11 +352,11 @@ jobs:
with:
command: install
args: --debug --path ./forc-fmt
- name: Build Sway examples and check formatting
- name: Build Sway examples
uses: actions-rs/cargo@v1
with:
command: run
args: --bin build-all-examples
args: --bin examples-checker build --all-examples
- name: Install cargo-udeps
uses: actions-rs/cargo@v1
with:
Expand Down
12 changes: 8 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
resolver = "2"
members = [
"docstrings",
"examples/build-all-examples",
"forc",
"forc-explore",
"forc-fmt",
"forc-gm",
"forc-lsp",
"forc-pkg",
"forc-util",
"scripts/examples-checker",
"scripts/forc-documenter",
"sway-core",
"sway-fmt",
Expand Down
6 changes: 0 additions & 6 deletions examples/build-all-examples/Cargo.toml

This file was deleted.

96 changes: 0 additions & 96 deletions examples/build-all-examples/src/main.rs

This file was deleted.

10 changes: 10 additions & 0 deletions scripts/examples-checker/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "examples-checker"
description = "Runs `forc build` or `forc fmt --check` on Sway projects specified by paths or within Sway `examples` directory."
version = "0.0.0"
edition = "2021"
publish = false

[dependencies]
anyhow = "1.0.41"
clap = { version = "3.1", features = ["env", "derive"] }
Loading

0 comments on commit b89ec66

Please sign in to comment.