mirror of https://github.com/yewstack/yew
Optimize CI caching and path filtering (#2340)
* fix docs.rs logo url * fix formatting * bump docusaurus to beta14 * bring back the semicolon * cache npm for build-website workflow * Add prebuilt cargo-sweep binary * Optimize website CI * per-job caching, stale cache invalidation * extract fmt job as workflow move website test as a prerequisite for publish * fix typo in cargo-sweep executable path * chmod +x * rename to main-checks.yml * --exclude has to be used with --workspace * revert accidental revert * Switch from cargo-sweep to rust-cache * link to this related issue of extra brackets * remove blanks * exclude website-test in main tests * rename suffixes from .mdx to .md * replace actions-rs/install with wasm-pack-action fixes #2351 * shouldn't ignore .md because website snippet tests depends on .md files and there can be #[doc(include("../some.md"))] in the code * restore accidentally deleted mdx files * include tools/website-test (for real this time)
This commit is contained in:
parent
62e3194d5f
commit
6669d1873e
|
@ -0,0 +1,28 @@
|
|||
name: cargo fmt
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- "**/*.rs"
|
||||
push:
|
||||
branches: [master]
|
||||
paths:
|
||||
- "**/*.rs"
|
||||
|
||||
jobs:
|
||||
format:
|
||||
name: cargo fmt
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
profile: minimal
|
||||
components: rustfmt
|
||||
|
||||
- name: Run fmt
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
|
@ -1,4 +1,4 @@
|
|||
name: Pull Request
|
||||
name: Main Checks
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
@ -6,8 +6,9 @@ on:
|
|||
branches: [master]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Format & Clippy
|
||||
|
||||
clippy:
|
||||
name: Clippy
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
@ -16,32 +17,18 @@ jobs:
|
|||
toolchain: stable
|
||||
override: true
|
||||
profile: minimal
|
||||
components: rustfmt, clippy
|
||||
components: clippy
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}
|
||||
restore-keys: |
|
||||
cargo-${{ runner.os }}-
|
||||
|
||||
- name: Run fmt
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
|
||||
- name: Run clippy
|
||||
if: always()
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: --all-targets -- -D warnings
|
||||
|
||||
lint-release:
|
||||
|
||||
clippy-release:
|
||||
name: Clippy on release profile
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -53,53 +40,19 @@ jobs:
|
|||
profile: minimal
|
||||
components: clippy
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: cargo-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}
|
||||
restore-keys: |
|
||||
cargo-${{ runner.os }}-${{ github.job }}-
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
|
||||
|
||||
- name: Run clippy
|
||||
if: always()
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: --all-targets --release -- -D warnings
|
||||
|
||||
check_examples:
|
||||
name: Check Examples
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
profile: minimal
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}
|
||||
restore-keys: |
|
||||
cargo-${{ runner.os }}-
|
||||
|
||||
- name: Run check
|
||||
run: |
|
||||
cd examples
|
||||
cargo check --all-targets
|
||||
|
||||
doc_tests:
|
||||
name: Documentation Tests
|
||||
# Using 20.04 because 18.04 (latest) only has aspell 0.60.7 and we need 0.60.8
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
|
@ -109,36 +62,33 @@ jobs:
|
|||
override: true
|
||||
profile: minimal
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}
|
||||
restore-keys: |
|
||||
cargo-${{ runner.os }}-
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
|
||||
- name: Check spelling
|
||||
run: |
|
||||
sudo apt-get install aspell
|
||||
ci/spellcheck.sh list
|
||||
|
||||
|
||||
- name: Run doctest
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --doc
|
||||
|
||||
- name: Run doctest - yew with features
|
||||
run: |
|
||||
cd packages/yew
|
||||
cargo test --doc --features "doc_test wasm_test"
|
||||
|
||||
- name: Run website code snippet tests
|
||||
run: |
|
||||
cd tools/website-test
|
||||
cargo test
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: -p website-test
|
||||
|
||||
- name: Run doctest - yew with features
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --doc --features doc_test --features wasm_test
|
||||
|
||||
|
||||
|
||||
integration_tests:
|
||||
name: Integration Tests on ${{ matrix.toolchain }}
|
||||
|
@ -147,6 +97,7 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
toolchain:
|
||||
# anyway to dynamically grep the MSRV from Cargo.toml?
|
||||
- 1.56.0 # MSRV
|
||||
- stable
|
||||
|
||||
|
@ -159,18 +110,12 @@ jobs:
|
|||
override: true
|
||||
profile: minimal
|
||||
|
||||
- name: Install wasm-pack
|
||||
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
||||
|
||||
- uses: actions/cache@v2
|
||||
- uses: jetli/wasm-pack-action@v0.3.0
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}
|
||||
restore-keys: |
|
||||
cargo-${{ runner.os }}-
|
||||
version: "latest"
|
||||
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
|
||||
|
||||
- name: Run tests - yew
|
||||
run: |
|
||||
|
@ -182,12 +127,14 @@ jobs:
|
|||
cd packages/yew-router
|
||||
wasm-pack test --chrome --firefox --headless
|
||||
|
||||
|
||||
unit_tests:
|
||||
name: Unit Tests on ${{ matrix.toolchain }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
toolchain:
|
||||
# anyway to dynamically grep the MSRV from Cargo.toml?
|
||||
- 1.56.0 # MSRV
|
||||
- stable
|
||||
- nightly
|
||||
|
@ -203,21 +150,15 @@ jobs:
|
|||
override: true
|
||||
profile: minimal
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}
|
||||
restore-keys: |
|
||||
cargo-${{ runner.os }}-
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
|
||||
- name: Run tests
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all-targets --workspace --exclude yew
|
||||
args: --all-targets --workspace --exclude yew --exclude website-test
|
||||
|
||||
|
||||
|
||||
test-lints:
|
||||
name: Test lints on nightly
|
||||
|
@ -231,17 +172,12 @@ jobs:
|
|||
override: true
|
||||
profile: minimal
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}
|
||||
restore-keys: |
|
||||
cargo-${{ runner.os }}-
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd packages/yew-macro
|
||||
cargo +nightly test test_html_lints --features lints
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: -p yew-macro test_html_lints --features lints
|
||||
|
|
@ -2,6 +2,9 @@ name: Publish Examples
|
|||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
paths-ignore:
|
||||
- "**/*.md"
|
||||
- "website/**"
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
|
@ -19,25 +22,14 @@ jobs:
|
|||
override: true
|
||||
profile: minimal
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}
|
||||
restore-keys: |
|
||||
cargo-${{ runner.os }}-
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
|
||||
- uses: jetli/trunk-action@v0.1.0
|
||||
with:
|
||||
# Optional version of trunk to install(eg. 'v0.8.1', 'latest')
|
||||
version: 'latest'
|
||||
|
||||
- uses: jetli/wasm-bindgen-action@v0.1.0
|
||||
with:
|
||||
# Optional version of wasm-bindgen to install(eg. '0.2.68', 'latest')
|
||||
version: 'latest'
|
||||
|
||||
|
||||
- name: Build examples
|
||||
run: |
|
||||
|
@ -75,6 +67,8 @@ jobs:
|
|||
)
|
||||
done
|
||||
|
||||
|
||||
|
||||
- name: Deploy to Firebase
|
||||
uses: siku2/action-hosting-deploy@v0
|
||||
with:
|
||||
|
|
|
@ -16,7 +16,6 @@ jobs:
|
|||
run: |
|
||||
echo "build failed"
|
||||
exit 1
|
||||
|
||||
# need to checkout to get "firebase.json", ".firebaserc"
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
|
@ -49,12 +48,10 @@ jobs:
|
|||
echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV
|
||||
echo "PR_BRANCH=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_ENV
|
||||
echo "COMMIT_SHA=${{ github.event.workflow_run.head_sha }}" >> $GITHUB_ENV
|
||||
|
||||
- if: github.event.workflow_run.event == 'push'
|
||||
name: Apply push environment
|
||||
run: |
|
||||
echo "CHANNEL_ID=live" >> $GITHUB_ENV
|
||||
|
||||
- name: Deploy to Firebase
|
||||
uses: siku2/action-hosting-deploy@v1
|
||||
with:
|
||||
|
@ -67,4 +64,4 @@ jobs:
|
|||
# PR information
|
||||
prNumber: "${{ env.PR_NUMBER }}"
|
||||
prBranchName: "${{ env.PR_BRANCH }}"
|
||||
commitSHA: "${{ env.COMMIT_SHA }}"
|
||||
commitSHA: "${{ env.COMMIT_SHA }}"
|
|
@ -40,8 +40,5 @@ members = [
|
|||
"tools/process-benchmark-results",
|
||||
"tools/benchmark-struct",
|
||||
"tools/benchmark-hooks",
|
||||
]
|
||||
exclude = [
|
||||
# Tools
|
||||
"tools/website-test",
|
||||
]
|
||||
|
|
|
@ -82,7 +82,7 @@ dependencies = ["test"]
|
|||
[tasks.test]
|
||||
private = true
|
||||
command = "cargo"
|
||||
args = ["test", "--all-targets"]
|
||||
args = ["test", "--all-targets", "--workspace", "--exclude", "website-test"]
|
||||
|
||||
[tasks.doc-test-flow]
|
||||
private = true
|
||||
|
@ -95,12 +95,8 @@ command = "cargo"
|
|||
args = ["test", "--doc"]
|
||||
|
||||
[tasks.website-test]
|
||||
script = [
|
||||
"""
|
||||
cd tools/website-test
|
||||
cargo test
|
||||
"""
|
||||
]
|
||||
command = "cargo"
|
||||
args = ["test", "-p", "website-test"]
|
||||
|
||||
[tasks.bench-flow]
|
||||
private = true
|
||||
|
|
|
@ -89,7 +89,8 @@ impl Level {
|
|||
.replace("-", "_");
|
||||
|
||||
self.write_space(dst, level);
|
||||
writeln!(dst, "#[doc = include_str!(\"{}\")]", file.display())?;
|
||||
|
||||
writeln!(dst, "#[doc = include_str!(r\"{}\")]", file.display())?;
|
||||
self.write_space(dst, level);
|
||||
writeln!(dst, "pub fn {}_md() {{}}", stem)?;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue