Split the huge workspace into smaller & improve CI (#2774)

* Split repository into multiple workspaces, update CI

* pull_request_target for build-website workflow

This should allow the workflow to read secrets instead of requiring a different, publish-website workflow to be needed to publish the side

* pull_request_target for build-api-docs workflow

This should allow the workflow to read secrets instead of requiring a different, publish-api-docs workflow to be needed to publish the side

* use `paths` instead of `path_ignore` for examples

* cleanup main-checks.yml

* it's rustfmt, not fmt

* correct paths for workflow files

* it's rustfmt, not fmt: part 2 electric bolgoo

* me idiot: part infinity

* ???

* main checks should be the same then?

* ??? part 2

* it should work now

* more fixes

* checkout before using file, actually use stable for wasm-bindgen-cli

* Revert "pull_request_target for build-api-docs workflow"

This reverts commit 38977292c8.

* Revert "pull_request_target for build-website workflow"

This reverts commit 1638a0cd24.

* Benchmark workflow uses pull_request event

* pull_request for size-cmp
This commit is contained in:
Muhammad Hamza 2022-07-07 00:17:03 +05:00 committed by GitHub
parent 11424bd840
commit 2e4a919679
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 2093 additions and 136 deletions

View File

@ -3,4 +3,3 @@ runner = 'wasm-bindgen-test-runner'
[unstable]
doctest-xcompile = true
# [unstable] must be the last section -- ci/write-optimisation-flags.sh relies on it

View File

@ -6,7 +6,7 @@ on:
- 'website/**'
branches:
- master
pull_request_target:
pull_request:
paths-ignore:
- 'website/**'
types: [labeled, synchronize, opened, reopened]
@ -32,6 +32,8 @@ jobs:
# gh-pages branch is updated and pushed automatically with extracted benchmark data
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
# This needs access to secersts so only run it on push to master
if: github.event_name == 'push'
with:
name: "Yew master branch benchmarks (Lower is better)"
tool: "customSmallerIsBetter"
@ -42,11 +44,8 @@ jobs:
# Push and deploy GitHub pages branch automatically
alert-threshold: "200%"
alert-comment-cc-users: "@yewstack/yew"
comment-always: ${{ github.event_name != 'pull_request_target' || contains(github.event.pull_request.labels.*.name, 'performance') }}
comment-on-alert: true
# Don't push to gh-pages if its a pull request
auto-push: ${{ github.event_name != 'pull_request_target' }}
save-data-file: ${{ github.event_name != 'pull_request_target' }}
auto-push: true
save-data-file: true
benchmark:
runs-on: ubuntu-latest
@ -243,11 +242,14 @@ jobs:
- name: Build process-benchmark-results
shell: bash
run: |
cd yew
cd yew/tools
cargo build --release -p process-benchmark-results
- name: transform results to be fit for display benchmark-action/github-action-benchmark@v1
uses: mathiasvr/command-output@v1
id: results
with:
run: cat js-framework-benchmark/webdriver-ts/results/results.json | ./yew/target/release/process-benchmark-results
run: cat js-framework-benchmark/webdriver-ts/results/results.json | ./yew/tools/target/release/process-benchmark-results
- name: Show output JSON
run: echo ${{ steps.results.outputs.stdout }}

View File

@ -25,6 +25,7 @@ jobs:
- name: Build changelog generator
run: cargo build --release -p changelog
working-directory: tools
- name: Read yew changelog in this step
run: ./target/release/changelog yew minor -t ${{ secrets.GITHUB_TOKEN }}

View File

@ -2,14 +2,24 @@ name: Main Checks
on:
pull_request:
paths:
- '.github/workflows/main-checks.yml'
- 'ci/**'
- 'packages/**/*'
- 'Cargo.toml'
push:
branches: [master]
jobs:
clippy:
name: Clippy
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
profile:
- dev
- release
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
@ -25,34 +35,15 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --features "csr,ssr,hydration,tokio" -- -D warnings
args: --all-targets --features "csr,ssr,hydration,tokio" --profile ${{ matrix.profile }} -- -D warnings
- name: Lint feature soundness
if: matrix.profile == 'dev'
run: bash ../../ci/feature-soundness.sh
working-directory: packages/yew
clippy-release:
name: Clippy on release profile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: clippy
- uses: Swatinem/rust-cache@v1
- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --features "csr,ssr,hydration,tokio" --release -- -D warnings
- name: Lint feature soundness
if: matrix.profile == 'release'
run: bash ../../ci/feature-soundness-release.sh
working-directory: packages/yew
@ -70,6 +61,7 @@ jobs:
name: Documentation Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/toolchain@v1
@ -78,10 +70,16 @@ jobs:
override: true
profile: minimal
- name: Install wasm-bindgen-test-runner
run: cargo install --git https://github.com/hamza1311/wasm-bindgen --branch respect-rustdoc-tmp-paths wasm-bindgen-cli
# perhaps extract it into its own little action?
- uses: actions-rs/toolchain@v1
# for wasm-bindgen-cli, always use stable rust
with:
toolchain: stable
profile: minimal
- uses: actions/checkout@v2
- name: Install wasm-bindgen-cli
shell: bash
run: ./ci/install-wasm-bindgen-cli.sh
- uses: actions-rs/toolchain@v1
with:
@ -97,13 +95,11 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --doc --workspace --exclude yew --exclude changelog --exclude website-test --exclude ssr_router --exclude simple_ssr --target wasm32-unknown-unknown
args: --doc --workspace --exclude yew --target wasm32-unknown-unknown
- name: Run website code snippet tests
uses: actions-rs/cargo@v1
with:
command: test
args: -p website-test --target wasm32-unknown-unknown
run: cargo test -p website-test --target wasm32-unknown-unknown
working-directory: tools
- name: Run doctest - yew with features
uses: actions-rs/cargo@v1
@ -116,20 +112,27 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain:
# anyway to dynamically grep the MSRV from Cargo.toml?
- 1.60.0 # MSRV
- 1.60.0
- stable
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/toolchain@v1
# for wasm-bindgen-cli, always use stable rust
with:
toolchain: stable
profile: minimal
- name: Install wasm-bindgen-cli
shell: bash
run: ./ci/install-wasm-bindgen-cli.sh
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
@ -140,24 +143,6 @@ jobs:
- uses: browser-actions/setup-geckodriver@latest
- uses: nanasess/setup-chromedriver@v1
- uses: Swatinem/rust-cache@v1
- name: Install wasm-bindgen-cli
shell: bash
run: |
if [ ! -f "Cargo.lock" ]; then
cargo fetch
fi
VERSION=$(cargo pkgid --frozen wasm-bindgen | cut -d ":" -f 3)
# Cargo decided to change syntax after 1.61
if [ "$VERSION" = "" ]; then
VERSION=$(cargo pkgid --frozen wasm-bindgen | cut -d "@" -f 2)
fi
cargo +stable install --version $VERSION wasm-bindgen-cli
- name: Run tests - yew
run: |
cd packages/yew
@ -174,10 +159,10 @@ jobs:
name: Unit Tests on ${{ matrix.toolchain }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain:
# anyway to dynamically grep the MSRV from Cargo.toml?
- 1.60.0 # MSRV
- 1.60.0
- stable
- nightly
@ -198,7 +183,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --all-targets --workspace --exclude yew --exclude website-test --exclude ssr_router --exclude simple_ssr
args: --all-targets --workspace --exclude yew
- name: Run native tests for yew
uses: actions-rs/cargo@v1

View File

@ -2,9 +2,9 @@ name: Publish Examples
on:
push:
branches: [master]
paths-ignore:
- "**/*.md"
- "website/**"
paths:
- 'ci/**'
- 'examples/**'
jobs:
publish:
@ -24,9 +24,6 @@ jobs:
override: true
profile: minimal
- name: Write optimisation flags
run: ./ci/write-optimisation-flags.sh
- uses: Swatinem/rust-cache@v1
- uses: jetli/trunk-action@v0.1.0

View File

@ -44,6 +44,7 @@ jobs:
- name: Build changelog generator
run: cargo build --release -p changelog
working-directory: tools
- name: Generate changelog
uses: mathiasvr/command-output@v1

View File

@ -45,6 +45,7 @@ jobs:
- name: Build changelog generator
run: cargo build --release -p changelog
working-directory: tools
- name: Generate changelog
uses: mathiasvr/command-output@v1

View File

@ -44,6 +44,7 @@ jobs:
- name: Build changelog generator
run: cargo build --release -p changelog
working-directory: tools
- name: Generate changelog
uses: mathiasvr/command-output@v1

View File

@ -44,6 +44,7 @@ jobs:
- name: Build changelog generator
run: cargo build --release -p changelog
working-directory: tools
- name: Generate changelog
uses: mathiasvr/command-output@v1

View File

@ -44,6 +44,7 @@ jobs:
- name: Build changelog generator
run: cargo build --release -p changelog
working-directory: tools
- name: Generate changelog
uses: mathiasvr/command-output@v1

View File

@ -55,14 +55,6 @@ jobs:
with:
version: 'latest'
- name: Write optimisation flags for master
run: ./ci/write-optimisation-flags.sh
working-directory: yew-master
- name: Write optimisation flags for pull request
run: ./ci/write-optimisation-flags.sh
working-directory: current-pr
- name: Build master examples
run: find examples/*/index.html | xargs -I '{}' trunk build --release '{}' || exit 0
working-directory: yew-master

55
.github/workflows/tools-examples.yml vendored Normal file
View File

@ -0,0 +1,55 @@
name: Tools & Examples
on:
pull_request:
paths:
- '.github/workflows/tools-examples.yml'
- 'tools/**/*'
- 'examples/**/*'
push:
branches: [ master ]
jobs:
clippy-fmt:
name: Clippy & Format
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
workspace:
- tools
- examples
runs:
- clippy
- rustfmt
include:
- toolchain: stable
runs: clippy
- toolchain: nightly
runs: rustfmt
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true
profile: minimal
components: ${{ matrix.runs }}
- uses: Swatinem/rust-cache@v1
- name: Run clippy for ${{ matrix.workspace }}
if: matrix.runs == 'clippy'
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --all-features --manifest-path ${{ matrix.workspace }}/Cargo.toml -- -D warnings
- name: Run fmt for ${{ matrix.workspace }}
if: matrix.runs == 'rustfmt'
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --manifest-path ${{ matrix.workspace }}/Cargo.toml -- --check

View File

@ -1,48 +1,9 @@
[workspace]
members = [
# Packages
"packages/yew",
"packages/yew-macro",
"packages/yew-agent",
"packages/yew-router",
"packages/yew-router-macro",
# Examples
"examples/boids",
"examples/contexts",
"examples/counter",
"examples/counter_functional",
"examples/dyn_create_destroy_apps",
"examples/file_upload",
"examples/function_memory_game",
"examples/function_router",
"examples/function_todomvc",
"examples/futures",
"examples/game_of_life",
"examples/inner_html",
"examples/js_callback",
"examples/keyed_list",
"examples/mount_point",
"examples/nested_list",
"examples/node_refs",
"examples/password_strength",
"examples/portals",
"examples/router",
"examples/simple_ssr",
"examples/timer",
"examples/todomvc",
"examples/two_apps",
"examples/webgl",
"examples/web_worker_fib",
"examples/ssr_router",
"examples/suspense",
"examples/immutable",
# Tools
"tools/benchmark-struct",
"tools/benchmark-hooks",
"tools/changelog",
"tools/process-benchmark-results",
"tools/website-test",
"packages/*",
]
exclude = [
"tools/*",
"examples/*",
]
resolver = "2"

12
ci/install-wasm-bindgen-cli.sh Executable file
View File

@ -0,0 +1,12 @@
if [ ! -f "Cargo.lock" ]; then
cargo fetch
fi
VERSION=$(cargo pkgid --frozen wasm-bindgen | cut -d ":" -f 3)
# Cargo decided to change syntax after 1.61
if [ "$VERSION" = "" ]; then
VERSION=$(cargo pkgid --frozen wasm-bindgen | cut -d "@" -f 2)
fi
cargo +stable install --version $VERSION wasm-bindgen-cli

View File

@ -1,15 +0,0 @@
# Must be run from root of the repo:
# yew $ ./ci/write-optimisation-flags.sh
# this goes in [unstable] section
cat >> .cargo/config.toml << EOF
build-std = ["std", "panic_abort"]
build-std-features = ["panic_immediate_abort"]
EOF
cat >> Cargo.toml << EOF
[profile.release]
lto = true
codegen-units = 1
panic = "abort"
opt-level = "z"
EOF

View File

@ -0,0 +1,3 @@
build-std = ["std", "panic_abort"]
build-std-features = ["panic_immediate_abort"]
share-generics = true

15
examples/Cargo.toml Normal file
View File

@ -0,0 +1,15 @@
[workspace]
members = [
"*",
]
exclude = [
"target",
".cargo"
]
resolver = "2"
[profile.release]
lto = true
codegen-units = 1
panic = "abort"
opt-level = "z"

1
tools/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
!Cargo.lock

1936
tools/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

8
tools/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[workspace]
members = [
"*",
]
exclude = [
"target"
]
resolver = "2"