Skip to content

Commit

Permalink
Modernize github workflows (#3711)
Browse files Browse the repository at this point in the history
* modernize github workflows

this mainly fixes some inconsistencies in style, outdated or wrong comments and action version
- replace Legit-Labs/action-download-artifact with actions/download-artifact
- fix Swatinem/rust-cache arguments
- fix benchmark transformations
- expand feature soundness lints
- wording and capitalization in comments

* fix no_run on crate level doc

* fix some more small issues
  • Loading branch information
WorldSEnder authored Aug 22, 2024
1 parent 73d519e commit 3871418
Show file tree
Hide file tree
Showing 25 changed files with 200 additions and 215 deletions.
23 changes: 7 additions & 16 deletions .github/workflows/benchmark-core.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
name: Benchmark - core

on:
Expand Down Expand Up @@ -32,29 +31,21 @@ jobs:
with:
toolchain: stable

- name: Restore Rust cache for master
- name: Restore Rust cache for yew packages
uses: Swatinem/rust-cache@v2
with:
working-directory: yew-master
key: master

- name: Restore Rust cache for current pull request
uses: Swatinem/rust-cache@v2
with:
working-directory: current-pr
key: pr
shared-key: yew-packages
workspaces: |
yew-master
current-pr
- name: Run pull request benchmark
run: cargo bench -q > ../output.log
working-directory: current-pr/tools/benchmark-core
run: cargo bench -q > ../output.log

- name: Run master benchmark
run: cargo bench -q > ../output.log
continue-on-error: true
working-directory: yew-master/tools/benchmark-core

- name: Make sure master's output log exists
run: touch yew-master/tools/output.log
run: cargo bench -q > ../output.log

- name: Write Pull Request ID
run: |
Expand Down
19 changes: 7 additions & 12 deletions .github/workflows/benchmark-ssr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
name: Benchmark - SSR

on:
Expand Down Expand Up @@ -37,25 +36,21 @@ jobs:
toolchain: stable
targets: wasm32-unknown-unknown

- name: Restore Rust cache for master
- name: Restore Rust cache for yew packages
uses: Swatinem/rust-cache@v2
with:
working-directory: yew-master
key: master

- name: Restore Rust cache for current pull request
uses: Swatinem/rust-cache@v2
with:
working-directory: current-pr
key: pr
shared-key: yew-packages
workspaces: |
yew-master
current-pr
- name: Run pull request benchmark
run: cargo run --profile=bench -- --output-path ../output.json
working-directory: current-pr/tools/benchmark-ssr
run: cargo run --profile=bench -- --output-path ../output.json

- name: Run master benchmark
run: cargo run --profile=bench -- --output-path ../output.json
working-directory: yew-master/tools/benchmark-ssr
run: cargo run --profile=bench -- --output-path ../output.json

- name: Write Pull Request ID
run: |
Expand Down
50 changes: 28 additions & 22 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ on:
- "website/**"
types: [labeled, synchronize, opened, reopened]

permissions:
# deployments permission to deploy GitHub pages website
deployments: write
# contents permission to update benchmark contents in gh-pages branch
contents: write
# Cancel outstanding benchmarks on pull requests
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#example-using-a-fallback-value
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
benchmark:
Expand All @@ -37,39 +37,45 @@ jobs:
toolchain: stable
targets: wasm32-unknown-unknown

- uses: jetli/[email protected]
with:
version: "latest"
- name: Setup wasm-pack
uses: jetli/[email protected]

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
node-version: ">=18"
cache: "npm"
cache-dependency-path: js-framework-benchmark/package-lock.json

- uses: Swatinem/rust-cache@v2
- name: Restore Rust cache for yew packages
uses: Swatinem/rust-cache@v2
with:
shared-key: yew-packages
workspaces: |
yew
- name: Setup chrome
id: setup-chrome
uses: browser-actions/setup-chrome@v1
with:
install-chromedriver: true

- name: setup js-framework-benchmark
- name: Setup js-framework-benchmark
working-directory: js-framework-benchmark
run: |
npm ci
npm run install-server
npm run install-webdriver-ts
- name: setup benchmark-struct benchmark
- name: Setup benchmark-struct benchmark
run: |
ls -lauh
rm *.js
rm *.wasm
echo "STRUCT_BUILD_DIR=$PWD" >> $GITHUB_ENV
working-directory: js-framework-benchmark/frameworks/keyed/yew/bundled-dist/

- name: build benchmark-struct app
- name: Build benchmark-struct app
working-directory: yew/tools/benchmark-struct
run: |
wasm-pack build \
Expand All @@ -79,19 +85,19 @@ jobs:
--out-name js-framework-benchmark-yew \
--out-dir $STRUCT_BUILD_DIR
- name: show built benchmark-struct benchmark files
- name: Show built benchmark-struct benchmark files
run: |
ls -lauh js-framework-benchmark/frameworks/keyed/yew/bundled-dist/
- name: setup yew-hooks benchmark
- name: Setup yew-hooks benchmark
run: |
ls -lauh
rm *.js
rm *.wasm
echo "HOOKS_BUILD_DIR=$PWD" >> $GITHUB_ENV
working-directory: js-framework-benchmark/frameworks/keyed/yew-hooks/bundled-dist/

- name: build benchmark-hooks app
- name: Build benchmark-hooks app
working-directory: yew/tools/benchmark-hooks
run: |
wasm-pack build \
Expand All @@ -101,25 +107,25 @@ jobs:
--out-name js-framework-benchmark-yew-hooks \
--out-dir $HOOKS_BUILD_DIR
- name: show built benchmark-hooks benchmark files
- name: Show built benchmark-hooks benchmark files
run: |
ls -lauh js-framework-benchmark/frameworks/keyed/yew-hooks/bundled-dist/
- name: run js-framework-benchmark server
- name: Run js-framework-benchmark server
working-directory: js-framework-benchmark
run: |
npm start &
sleep 5
- name: js-framework-benchmark/webdriver-ts npm run bench
- name: Run js-framework-benchmark/webdriver-ts npm run bench
working-directory: js-framework-benchmark/webdriver-ts
run: xvfb-run npm run bench -- --framework keyed/yew keyed/yew-hooks --runner playwright
run: xvfb-run npm run bench -- --framework keyed/yew keyed/yew-hooks --runner playwright --chromeBinary "${{ steps.setup-chrome.outputs.chrome-path }}"

- name: transform results to be fit for display benchmark-action/github-action-benchmark@v1
- name: Transform results to be fit for display benchmark-action/github-action-benchmark@v1
run: |
mkdir artifacts/
jq -s . js-framework-benchmark/webdriver-ts/results/*.json | cargo run --manifest-path yew/Cargo.toml --release -p process-benchmark-results > artifacts/results.json
echo "$EVENT_INFO" > artifacts/PR_INFO
echo "$EVENT_INFO" > artifacts/.PR_INFO
env:
EVENT_INFO: ${{ toJSON(github.event) }}

Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/build-api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
PR_INFO_FILE: ".PR_INFO"
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -55,12 +53,12 @@ jobs:
- if: github.event_name == 'pull_request'
name: Build pr info
run: |
echo "${{ github.event.number }}" > $PR_INFO_FILE
echo "${{ github.event.number }}" > .PR_INFO
- if: github.event_name == 'pull_request'
name: Upload pr info
uses: actions/upload-artifact@v4
with:
name: pr-info
path: "${{ env.PR_INFO_FILE }}"
path: .PR_INFO
retention-days: 1
6 changes: 2 additions & 4 deletions .github/workflows/build-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ jobs:
build:
name: Build Website
runs-on: ubuntu-latest
env:
PR_INFO_FILE: ".PR_INFO"
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -57,12 +55,12 @@ jobs:
- if: github.event_name == 'pull_request'
name: Build pr info
run: |
echo "${{ github.event.number }}" > $PR_INFO_FILE
echo "${{ github.event.number }}" > .PR_INFO
- if: github.event_name == 'pull_request'
name: Upload pr info
uses: actions/upload-artifact@v4
with:
name: pr-info
path: "${{ env.PR_INFO_FILE }}"
path: .PR_INFO
retention-days: 1
24 changes: 9 additions & 15 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ jobs:
feature-soundness:
name: Feature Soundness
runs-on: ubuntu-latest
# if normal clippy doesn't succeed, do not try to lint feature soundness
needs: clippy

strategy:
fail-fast: false
matrix:
Expand All @@ -32,27 +35,16 @@ jobs:
components: clippy

- uses: Swatinem/rust-cache@v2
with:
shared-key: clippy

- name: Lint feature soundness
if: matrix.profile == 'dev'
run: bash ../../ci/feature-soundness.sh
working-directory: packages/yew
run: bash ./ci/feature-soundness.sh

- name: Lint feature soundness
if: matrix.profile == 'release'
run: bash ../../ci/feature-soundness-release.sh
working-directory: packages/yew

- name: Run release clippy
if: matrix.profile == 'release'
run: |
ls packages | xargs -I {} \
cargo clippy \
-p {} \
--all-targets \
--all-features \
--workspace \
-- -D warnings
run: bash ./ci/feature-soundness-release.sh

clippy:
name: Clippy Workspace
Expand All @@ -73,6 +65,8 @@ jobs:
components: clippy

- uses: Swatinem/rust-cache@v2
with:
shared-key: clippy

- name: Run clippy
run: |
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/main-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
shared-key: yew-packages

# for wasm-bindgen-cli, always use stable rust
- name: Setup toolchain
Expand Down Expand Up @@ -74,6 +76,8 @@ jobs:
- uses: actions/checkout@v4

- uses: Swatinem/rust-cache@v2
with:
shared-key: yew-packages

# for wasm-bindgen-cli, always use stable rust
- name: Setup toolchain
Expand Down Expand Up @@ -122,15 +126,15 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}

- uses: Swatinem/rust-cache@v2
with:
shared-key: yew-packages

- name: Run native tests
env:
Expand Down Expand Up @@ -159,6 +163,8 @@ jobs:
toolchain: nightly

- uses: Swatinem/rust-cache@v2
with:
shared-key: yew-packages

- name: Run tests
env:
Expand Down
22 changes: 7 additions & 15 deletions .github/workflows/post-benchmark-core.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
name: Post Comment for Benchmark - core

on:
Expand All @@ -9,22 +8,21 @@ on:

jobs:
post-benchmark-core:
if: github.event.workflow_run.event == 'pull_request'
name: Post Comment on Pull Request
name: Post Benchmark Comment on Pull Request
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request'
runs-on: ubuntu-latest

steps:
- name: Download Repository
uses: actions/checkout@v4

- name: Download Artifact
uses: Legit-Labs/action-download-artifact@v2
uses: actions/download-artifact@v4
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
workflow: benchmark-core.yml
run_id: ${{ github.event.workflow_run.id }}
github-token: "${{ secrets.GITHUB_TOKEN }}"
run-id: ${{ github.event.workflow_run.id }}
name: benchmark-core
path: "benchmark-core/"
path: benchmark-core/

- name: Make pull request comment
run: |
Expand All @@ -45,13 +43,7 @@ jobs:
EOF
- name: Read Pull Request ID
run: |
PR_NUMBER=$(cat "benchmark-core/.PR_NUMBER")
if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]]; then
echo "pr number invalid"
exit 1
fi
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
run: echo "PR_NUMBER=$(cat benchmark-core/.PR_NUMBER)" >> $GITHUB_ENV

- name: Post Comment
uses: actions/github-script@v6
Expand Down
Loading

0 comments on commit 3871418

Please sign in to comment.