Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize CI caching and path filtering #2340

Merged
merged 27 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
748000d
fix docs.rs logo url
Madoshakalaka Dec 22, 2021
f0bc0aa
fix formatting
Madoshakalaka Dec 22, 2021
ff29dcc
bump docusaurus to beta14
Madoshakalaka Dec 22, 2021
b8a7196
bring back the semicolon
Madoshakalaka Dec 22, 2021
39bb577
cache npm for build-website workflow
Madoshakalaka Jan 6, 2022
ef19cc4
Add prebuilt cargo-sweep binary
Madoshakalaka Jan 6, 2022
5f590a8
Optimize website CI
Madoshakalaka Jan 7, 2022
5591ad8
per-job caching, stale cache invalidation
Madoshakalaka Jan 7, 2022
8e55e96
Merge branch 'master' into ci-optimization
Madoshakalaka Jan 7, 2022
c09cfca
extract fmt job as workflow
Madoshakalaka Jan 7, 2022
9700bed
fix typo in cargo-sweep executable path
Madoshakalaka Jan 7, 2022
36755af
chmod +x
Madoshakalaka Jan 7, 2022
a0700b6
rename to main-checks.yml
Madoshakalaka Jan 7, 2022
c107369
--exclude has to be used with --workspace
Madoshakalaka Jan 7, 2022
e38f422
revert accidental revert
Madoshakalaka Jan 7, 2022
6d1fab8
Switch from cargo-sweep to rust-cache
Madoshakalaka Jan 8, 2022
b852f79
link to this related issue of extra brackets
Madoshakalaka Jan 8, 2022
7961a2f
remove blanks
Madoshakalaka Jan 8, 2022
3b8f182
exclude website-test in main tests
Madoshakalaka Jan 8, 2022
b79a3ac
rename suffixes from .mdx to .md
Madoshakalaka Jan 10, 2022
43c97f2
replace actions-rs/install with wasm-pack-action
Madoshakalaka Jan 10, 2022
bfea80a
shouldn't ignore .md because website snippet tests depends on .md fil…
Madoshakalaka Jan 12, 2022
1b9a7b0
Merge branch 'master' into ci-optimization
Madoshakalaka Jan 12, 2022
e60ba6b
Merge remote-tracking branch 'matt/ci-optimization' into ci-optimization
Madoshakalaka Jan 12, 2022
c77cb78
restore accidentally deleted mdx files
Madoshakalaka Jan 12, 2022
7b7c166
include tools/website-test (for real this time)
Madoshakalaka Jan 12, 2022
94a5619
Merge branch 'master' into ci-optimization
Madoshakalaka Jan 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: cargo fmt
on:
pull_request:
paths:
- "**/*.rs"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this.
It inspired me to make actions that add labels that i have been adding manually. (They are needed for changelog generation)

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
150 changes: 43 additions & 107 deletions .github/workflows/pull-request.yml → .github/workflows/main-checks.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: Pull Request
name: Main Checks

on:
pull_request:
push:
branches: [master]

jobs:
lint:
name: Format & Clippy

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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 website code snippet tests
uses: actions-rs/cargo@v1
with:
command: test
args: -p website-test

- name: Run doctest - yew with features
run: |
cd packages/yew
cargo test --doc --features "doc_test wasm_test"
uses: actions-rs/cargo@v1
with:
command: test
args: --doc --features doc_test --features wasm_test


- name: Run website code snippet tests
run: |
cd tools/website-test
cargo test

integration_tests:
name: Integration Tests on ${{ matrix.toolchain }}
Expand All @@ -147,6 +97,7 @@ jobs:
strategy:
matrix:
toolchain:
# anyway to dynamically grep the MSRV from Cargo.toml?
- 1.56.0 # MSRV
- stable

Expand All @@ -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: |
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

20 changes: 7 additions & 13 deletions .github/workflows/publish-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Publish Examples
on:
push:
branches: [master]
paths-ignore:
- "**/*.md"
- "website/**"

jobs:
publish:
Expand All @@ -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: |
Expand Down Expand Up @@ -75,6 +67,8 @@ jobs:
)
done



- name: Deploy to Firebase
uses: siku2/action-hosting-deploy@v0
with:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/publish-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
run: |
echo "build failed"
exit 1

# need to checkout to get "firebase.json", ".firebaserc"
- uses: actions/checkout@v2

Expand Down Expand Up @@ -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:
Expand All @@ -67,4 +64,4 @@ jobs:
# PR information
prNumber: "${{ env.PR_NUMBER }}"
prBranchName: "${{ env.PR_BRANCH }}"
commitSHA: "${{ env.COMMIT_SHA }}"
commitSHA: "${{ env.COMMIT_SHA }}"
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,5 @@ members = [
"tools/process-benchmark-results",
"tools/benchmark-struct",
"tools/benchmark-hooks",
]
exclude = [
# Tools
"tools/website-test",
]
10 changes: 3 additions & 7 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading