ci(examples): split check example and improve workflows (#1191)

This commit is contained in:
Joseph Cruz 2023-06-15 21:44:37 -04:00 committed by GitHub
parent 5f0013e482
commit 18bc03e660
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 54 deletions

View file

@ -1,4 +1,4 @@
name: Check examples name: Check Examples
on: on:
push: push:
@ -6,41 +6,39 @@ on:
pull_request: pull_request:
branches: [main] branches: [main]
env:
CARGO_TERM_COLOR: always
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
jobs: jobs:
test: call-with-matrix:
name: Check examples ${{ matrix.os }} (using rustc ${{ matrix.rust }}) name: Check
runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false
matrix: matrix:
rust: directory: [examples/counter,
- nightly examples/counter_isomorphic,
os: examples/counters,
- ubuntu-latest examples/counters_stable,
examples/counter_without_macros,
steps: examples/error_boundary,
- uses: actions/checkout@v3 examples/errors_axum,
examples/fetch,
- name: Setup Rust examples/hackernews,
uses: actions-rs/toolchain@v1 examples/hackernews_axum,
with: examples/js-framework-benchmark,
toolchain: ${{ matrix.rust }} examples/leptos-tailwind-axum,
override: true examples/login_with_token_csr_only,
components: rustfmt examples/parent_child,
examples/router,
- name: Add wasm32-unknown-unknown examples/session_auth_axum,
run: rustup target add wasm32-unknown-unknown examples/slots,
examples/ssr_modes,
- name: Setup cargo-make examples/ssr_modes_axum,
uses: davidB/rust-cargo-make@v1 examples/tailwind,
examples/tailwind_csr_trunk,
- name: Cargo generate-lockfile examples/timer,
run: cargo generate-lockfile examples/todo_app_sqlite,
examples/todo_app_sqlite_axum,
- uses: Swatinem/rust-cache@v2 examples/todo_app_sqlite_viz,
examples/todomvc]
- name: Run cargo check on all examples uses: ./.github/workflows/run-example-task.yml
run: cargo make check-examples with:
directory: ${{ matrix.directory }}
cargo_make_task: "check"

View file

@ -1,19 +1,21 @@
name: Verify Example name: Run Example Task
on: on:
workflow_call: workflow_call:
inputs: inputs:
project_dir: directory:
required: true
type: string
cargo_make_task:
required: true required: true
type: string type: string
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
jobs: jobs:
test: test:
name: Verify ${{ matrix.os }} (using rustc ${{ matrix.rust }}) name: Run ${{ matrix.os }} (using rustc ${{ matrix.rust }})
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
@ -78,11 +80,11 @@ jobs:
${{ runner.os }}-pnpm-store- ${{ runner.os }}-pnpm-store-
# Verify project # Verify project
- name: Verify - name: ${{ inputs.cargo_make_task }}
run: | run: |
if [ "${{ inputs.project_dir }}" = "INTERNAL" ]; then if [ "${{ inputs.directory }}" = "INTERNAL" ]; then
echo No verification required echo No verification required
else else
cd ${{ inputs.project_dir }} cd ${{ inputs.directory }}
cargo make --profile=github-actions verify-flow cargo make --profile=github-actions ${{ inputs.cargo_make_task }}
fi fi

View file

@ -5,6 +5,9 @@ on:
push: push:
tags: tags:
- v* - v*
schedule:
# Run once a day at 3:00 AM EST
- cron: "0 8 * * *"
jobs: jobs:
call-with-matrix: call-with-matrix:
@ -12,7 +15,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
project_dir: [examples/counter, directory: [examples/counter,
examples/counter_isomorphic, examples/counter_isomorphic,
examples/counters, examples/counters,
examples/counters_stable, examples/counters_stable,
@ -38,6 +41,7 @@ examples/todo_app_sqlite,
examples/todo_app_sqlite_axum, examples/todo_app_sqlite_axum,
examples/todo_app_sqlite_viz, examples/todo_app_sqlite_viz,
examples/todomvc] examples/todomvc]
uses: ./.github/workflows/verify-example.yml uses: ./.github/workflows/run-example-task.yml
with: with:
project_dir: ${{ matrix.project_dir }} directory: ${{ matrix.directory }}
cargo_make_task: "verify-flow"

View file

@ -9,7 +9,7 @@ on:
- main - main
jobs: jobs:
changed-dirs: setup:
name: Get Changes name: Get Changes
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
@ -51,7 +51,7 @@ jobs:
- name: Set Matrix - name: Set Matrix
id: set-matrix id: set-matrix
run: | run: |
if [ ${{ steps.changed-dirs.outputs.any_changed }} == 'true' ]; then if [ ${{ steps.changed-files.outputs.any_changed }} == 'true' ]; then
# Create matrix with changed directories # Create matrix with changed directories
echo "matrix={\"directory\":${{ steps.changed-dirs.outputs.all_changed_files }}}" >> "$GITHUB_OUTPUT" echo "matrix={\"directory\":${{ steps.changed-dirs.outputs.all_changed_files }}}" >> "$GITHUB_OUTPUT"
else else
@ -61,10 +61,11 @@ jobs:
matrix-job: matrix-job:
name: Verify name: Verify
needs: [changed-dirs] needs: [setup]
strategy: strategy:
matrix: ${{ fromJSON(needs.changed-dirs.outputs.matrix) }} matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
fail-fast: false fail-fast: true
uses: ./.github/workflows/verify-example.yml uses: ./.github/workflows/run-example-task.yml
with: with:
project_dir: ${{ matrix.directory }} directory: ${{ matrix.directory }}
cargo_make_task: "verify-flow"