ci: add checks on examples (#605)

This commit is contained in:
Marco Pasqualetti
2025-03-05 19:00:08 +01:00
committed by GitHub
parent a322ce2fad
commit 9b6f8098b6
6 changed files with 138 additions and 11 deletions
+123
View File
@@ -0,0 +1,123 @@
name: Examples CI
on:
push:
branches:
- 'main'
pull_request:
concurrency:
group: '${{ github.workflow }}-${{ github.head_ref || github.ref }}'
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
example_list:
name: Get examples names
runs-on: ubuntu-latest
timeout-minutes: 1
outputs:
names: ${{ steps.find_folder.outputs.names }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- id: find_folder
working-directory: examples
# produces the list of folder inside examples without leading `./` and trailing `/`:
# ```text
# tuono-tutorial
# with-tailwind
# tuono-app
# with-mdx
# ```
#
# after, using `jq` the output is converted into a JSON array:
# ```json
# ["tuono-tutorial","with-tailwind","tuono-app","with-mdx"]
# ```
#
# and added to `$GITHUB_OUTPUT` env variable:
run: |
NAMES=$(find . -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
echo "names=$(echo "$NAMES" | jq -R -s -c 'split("\n")[:-1]')" >> "$GITHUB_OUTPUT"
check_rust:
needs:
- example_list
strategy:
matrix:
example_name: ${{ fromJson(needs.example_list.outputs.names) }}
os:
- 'ubuntu-latest'
- 'macos-latest'
# to be added
# - 'windows-latest'
# Only on this repo some examples build including plugins fails
# However, if the project is downloaded via `tuono new`` it will work
# @see https://github.com/tuono-labs/tuono/pull/605#pullrequestreview-2656262230
# needs further investigations
exclude:
- example_name: with-tailwind
name: 'Check `${{ matrix.example_name }}` build on ${{ matrix.os }}'
runs-on: ${{ matrix.os }}
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install NodeJS Dependencies
uses: ./.github/actions/install-node-dependencies
- name: Setup rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Build Rust
run: cargo build
- name: Build typescript
run: pnpm run build
- name: Check "build"
working-directory: ./examples/${{ matrix.example_name }}
run: ../../target/debug/tuono build
check_typescript:
name: Check typescript
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install NodeJS Dependencies
uses: ./.github/actions/install-node-dependencies
- name: Build typescript
run: pnpm run build
- name: Check formatting
run: pnpm run examples:format
- name: Typecheck
run: pnpm run examples:typecheck
ci_ok:
name: Examples CI OK
runs-on: ubuntu-latest
timeout-minutes: 1
if: always()
needs:
- example_list
- check_rust
- check_typescript
steps:
- name: Exit with error if some jobs are not successful
run: exit 1
if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled')) }}
+1
View File
@@ -2,6 +2,7 @@ pnpm-lock.yaml
dist dist
.tuono .tuono
out
vite.config.ts.timestamp-* vite.config.ts.timestamp-*
+1 -1
View File
@@ -11,7 +11,7 @@ tuono new [NAME]
You can install any example included in this folder by just using the `--template` flag: You can install any example included in this folder by just using the `--template` flag:
```sh ```sh
tuono new [NAME] --template [TEMPLATE] tuono new [NAME] --template [TEMPLATE]
``` ```
`[TEMPLATE]` is the folder name. `[TEMPLATE]` is the folder name.
-2
View File
@@ -5,5 +5,3 @@ This is the starter tuono project. To download it run in your terminal:
```sh ```sh
tuono new my-first-tuono-app tuono new my-first-tuono-app
``` ```
+5 -5
View File
@@ -1,11 +1,11 @@
import type { TuonoConfig } from 'tuono/config' import type { TuonoConfig } from 'tuono/config'
const config: TuonoConfig = { const config: TuonoConfig = {
vite: { vite: {
alias: { alias: {
'@': 'src', '@': 'src',
}, },
}, },
} }
export default config export default config
+8 -3
View File
@@ -13,9 +13,14 @@
"test": "turbo test --filter=./devtools/* --filter=./packages/*", "test": "turbo test --filter=./devtools/* --filter=./packages/*",
"test:watch": "turbo test:watch --filter=./devtools/* --filter=./packages/*", "test:watch": "turbo test:watch --filter=./devtools/* --filter=./packages/*",
"test:e2e": "pnpm --filter='fixture-*' run test:e2e", "test:e2e": "pnpm --filter='fixture-*' run test:e2e",
"repo:root:format": "prettier . !./assets/** !./crates !./examples !./devtools/** !./packages/** --check", "examples:format": "prettier ./examples/** --check",
"repo:root:format:fix": "prettier . !./assets/** !./crates !./examples !./devtools/** !./packages/** --write", "examples:format:fix": "prettier ./examples/** --write",
"check-all": "turbo build lint format typecheck --filter=!./examples" "examples:typecheck": "pnpm --filter \"./examples/*\" exec tsc --noEmit",
"repo:root:format": "prettier . !./assets !./crates !./examples !./devtools !./packages --check",
"repo:root:format:fix": "prettier . !./assets !./crates !./examples !./devtools !./packages --write",
"check-packages": "turbo build lint format typecheck --filter=!./examples",
"check-examples": "pnpm run \"/^examples:(format|typecheck)$/\"",
"check-all": "pnpm run check-packages && pnpm run check-examples && pnpm run repo:root:format"
}, },
"author": "Valerio Ageno", "author": "Valerio Ageno",
"license": "MIT", "license": "MIT",