130 lines
3.5 KiB
YAML
130 lines
3.5 KiB
YAML
name: Run Task
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
directory:
|
|
required: true
|
|
type: string
|
|
cargo_make_task:
|
|
required: true
|
|
type: string
|
|
toolchain:
|
|
required: true
|
|
type: string
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
|
|
|
|
jobs:
|
|
test:
|
|
name: Run ${{ inputs.cargo_make_task }} (${{ inputs.toolchain }})
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
# Setup environment
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: ${{ inputs.toolchain }}
|
|
|
|
- name: Add wasm32-unknown-unknown
|
|
run: rustup target add wasm32-unknown-unknown
|
|
|
|
- name: Setup cargo-make
|
|
uses: davidB/rust-cargo-make@v1
|
|
|
|
- name: Cargo generate-lockfile
|
|
run: cargo generate-lockfile
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Install binstall
|
|
uses: cargo-bins/cargo-binstall@main
|
|
|
|
- name: Install wasm-bindgen
|
|
run: cargo binstall wasm-bindgen-cli --no-confirm
|
|
|
|
- name: Install wasm-pack
|
|
run: cargo binstall wasm-pack --no-confirm
|
|
|
|
- name: Install cargo-leptos
|
|
run: cargo binstall cargo-leptos --no-confirm
|
|
|
|
- name: Install Trunk
|
|
uses: jetli/trunk-action@v0.4.0
|
|
with:
|
|
version: "latest"
|
|
|
|
- name: Print Trunk Version
|
|
run: trunk --version
|
|
|
|
- name: Install Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
|
|
- uses: pnpm/action-setup@v3
|
|
name: Install pnpm
|
|
id: pnpm-install
|
|
with:
|
|
version: 8
|
|
run_install: false
|
|
|
|
- name: Get pnpm store directory
|
|
id: pnpm-cache
|
|
run: |
|
|
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
|
|
|
- uses: actions/cache@v4
|
|
name: Setup pnpm cache
|
|
with:
|
|
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pnpm-store-
|
|
|
|
- name: Maybe install chromedriver
|
|
run: |
|
|
project_makefile=${{inputs.directory}}/Makefile.toml
|
|
webdriver_count=$(cat $project_makefile | grep "cargo-make/webdriver.toml" | wc -l)
|
|
if [ $webdriver_count -eq 1 ]; then
|
|
if ! command -v chromedriver &>/dev/null; then
|
|
echo chromedriver required
|
|
sudo apt-get update
|
|
sudo apt-get install chromium-chromedriver
|
|
else
|
|
echo chromedriver is already installed
|
|
fi
|
|
else
|
|
echo chromedriver is not required
|
|
fi
|
|
|
|
- name: Maybe install playwright browser dependencies
|
|
run: |
|
|
for pw_path in $(find ${{inputs.directory}} -name playwright.config.ts)
|
|
do
|
|
pw_dir=$(dirname $pw_path)
|
|
if [ ! -v $pw_dir ]; then
|
|
echo "Playwright required in $pw_dir"
|
|
cd $pw_dir
|
|
pnpm dlx playwright install --with-deps
|
|
else
|
|
echo Playwright is not required
|
|
fi
|
|
done
|
|
|
|
- name: Install Deno
|
|
uses: denoland/setup-deno@v1
|
|
with:
|
|
deno-version: v1.x
|
|
|
|
# Run Cargo Make Task
|
|
- name: ${{ inputs.cargo_make_task }}
|
|
run: |
|
|
cd ${{ inputs.directory }}
|
|
cargo make --profile=github-actions ${{ inputs.cargo_make_task }}
|