diff --git a/.github/workflows/examples-ci.yml b/.github/workflows/examples-ci.yml new file mode 100644 index 00000000..1e381509 --- /dev/null +++ b/.github/workflows/examples-ci.yml @@ -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')) }} diff --git a/.prettierignore b/.prettierignore index ce36d661..289a43b7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,6 +2,7 @@ pnpm-lock.yaml dist .tuono +out vite.config.ts.timestamp-* diff --git a/examples/README.md b/examples/README.md index 082c121c..c8556289 100644 --- a/examples/README.md +++ b/examples/README.md @@ -11,7 +11,7 @@ tuono new [NAME] You can install any example included in this folder by just using the `--template` flag: ```sh -tuono new [NAME] --template [TEMPLATE] +tuono new [NAME] --template [TEMPLATE] ``` `[TEMPLATE]` is the folder name. diff --git a/examples/tuono-app/README.md b/examples/tuono-app/README.md index 6cecfae3..b575862c 100644 --- a/examples/tuono-app/README.md +++ b/examples/tuono-app/README.md @@ -5,5 +5,3 @@ This is the starter tuono project. To download it run in your terminal: ```sh tuono new my-first-tuono-app ``` - - diff --git a/examples/tuono-tutorial/tuono.config.ts b/examples/tuono-tutorial/tuono.config.ts index cd34c2c6..bb3b20b1 100644 --- a/examples/tuono-tutorial/tuono.config.ts +++ b/examples/tuono-tutorial/tuono.config.ts @@ -1,11 +1,11 @@ import type { TuonoConfig } from 'tuono/config' const config: TuonoConfig = { - vite: { - alias: { - '@': 'src', - }, - }, + vite: { + alias: { + '@': 'src', + }, + }, } export default config diff --git a/package.json b/package.json index ce649a2d..6d01bff4 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,14 @@ "test": "turbo test --filter=./devtools/* --filter=./packages/*", "test:watch": "turbo test:watch --filter=./devtools/* --filter=./packages/*", "test:e2e": "pnpm --filter='fixture-*' run test:e2e", - "repo:root:format": "prettier . !./assets/** !./crates !./examples !./devtools/** !./packages/** --check", - "repo:root:format:fix": "prettier . !./assets/** !./crates !./examples !./devtools/** !./packages/** --write", - "check-all": "turbo build lint format typecheck --filter=!./examples" + "examples:format": "prettier ./examples/** --check", + "examples:format:fix": "prettier ./examples/** --write", + "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", "license": "MIT",