mirror of
https://github.com/tabler/tabler.git
synced 2026-10-11 20:56:57 +04:00
Fix the turbo cache in CI and harden the workflows (#3104)
This commit is contained in:
1 parent
5a735bc049
commit
b38a9c060e
10 files changed
+84
-21
No files matched your search
@@ -11,6 +11,7 @@
|
||||
// pnpm run check-html http://localhost:3000
|
||||
import { createReadStream, existsSync, readFileSync, statSync } from 'node:fs'
|
||||
import { createServer, type Server } from 'node:http'
|
||||
import { availableParallelism } from 'node:os'
|
||||
import { extname, join, resolve } from 'node:path'
|
||||
import { chromium, type Browser, type Page } from 'playwright'
|
||||
|
||||
@@ -41,6 +42,10 @@ const MIME: Record<string, string> = {
|
||||
|
||||
// Ids generated by libraries at runtime; duplicates there are theirs, not ours.
|
||||
const VENDOR_ID_PREFIXES = ['apexcharts-', 'jvm-', 'SvgjsSvg', 'SvgjsLinearGradient']
|
||||
// Two pages per core: each page sits idle for the settle delay below, so one
|
||||
// worker per core leaves the machine waiting. Override with CHECK_HTML_WORKERS.
|
||||
const WORKERS = Number(process.env.CHECK_HTML_WORKERS) || Math.min(16, availableParallelism() * 2)
|
||||
|
||||
// Console noise from third-party demos (WebGL driver messages, Google Maps without a key, plyr).
|
||||
const CONSOLE_IGNORE = [/GL Driver Message/, /Google Maps JavaScript API/, /allowfullscreen/, /web-share/, /No available adapters/, /\[vite\]/, /astro/i]
|
||||
|
||||
@@ -175,7 +180,7 @@ const crawl = async (browser: Browser, base: string, paths: string[]) => {
|
||||
await page.close()
|
||||
}
|
||||
}
|
||||
await Promise.all(Array.from({ length: 4 }, worker))
|
||||
await Promise.all(Array.from({ length: WORKERS }, worker))
|
||||
await context.close()
|
||||
for (const [href, from] of links) {
|
||||
const url = href.startsWith('/') ? base + href : new URL(href, base + from).href
|
||||
|
||||
@@ -6,3 +6,6 @@ node_modules/
|
||||
**/dist/
|
||||
**/.astro/
|
||||
packages-zip/
|
||||
.env
|
||||
.env.*
|
||||
.vercel/
|
||||
@@ -1,19 +1,39 @@
|
||||
name: Set up the workspace
|
||||
description: Restore the turbo cache, install pnpm and Node.js, install the dependencies
|
||||
|
||||
inputs:
|
||||
turbo-cache:
|
||||
description: Restore and save the turbo cache. The release job turns it off so a cache written by another run cannot end up in a published package.
|
||||
default: 'true'
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Cache turbo build setup
|
||||
# The key carries the workflow name: cache keys are write-once, so with one
|
||||
# key per commit the quickest workflow (lint) saved its near-empty cache and
|
||||
# the build never got to store its outputs.
|
||||
#
|
||||
# A push starts from an empty cache and saves only what this build produced,
|
||||
# which keeps the entry at the size of one build. Pull requests restore the
|
||||
# latest entry of the base branch and save nothing.
|
||||
- name: Save the turbo cache
|
||||
if: inputs.turbo-cache == 'true' && github.event_name == 'push'
|
||||
uses: actions/cache@v6
|
||||
with:
|
||||
path: .turbo
|
||||
key: ${{ runner.os }}-turbo-${{ github.sha }}
|
||||
path: .turbo/cache
|
||||
key: ${{ runner.os }}-turbo-${{ github.workflow }}-${{ github.sha }}
|
||||
|
||||
- name: Restore the turbo cache
|
||||
if: inputs.turbo-cache == 'true' && github.event_name != 'push'
|
||||
uses: actions/cache/restore@v6
|
||||
with:
|
||||
path: .turbo/cache
|
||||
key: ${{ runner.os }}-turbo-${{ github.workflow }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-turbo-
|
||||
${{ runner.os }}-turbo-${{ github.workflow }}-
|
||||
|
||||
- name: Install PNPM
|
||||
uses: pnpm/action-setup@v6
|
||||
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v7
|
||||
@@ -22,5 +42,5 @@ runs:
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install pnpm dependencies
|
||||
run: pnpm install
|
||||
run: pnpm install --frozen-lockfile
|
||||
shell: bash
|
||||
@@ -8,6 +8,10 @@ on:
|
||||
types:
|
||||
- opened
|
||||
|
||||
permissions:
|
||||
issues: read
|
||||
pull-requests: read
|
||||
|
||||
jobs:
|
||||
add-to-project:
|
||||
name: Add new issue and pr to project
|
||||
|
||||
@@ -19,14 +19,6 @@ jobs:
|
||||
- name: Set up the workspace
|
||||
uses: ./.github/actions/setup
|
||||
|
||||
# turbo directly: `pnpm run build` also zips the package, which only the release needs
|
||||
- name: Build
|
||||
run: pnpm run build
|
||||
|
||||
- name: Install Playwright
|
||||
uses: ./.github/actions/playwright
|
||||
|
||||
- name: Check rendered html
|
||||
run: pnpm run check:html preview/dist docs/dist --quiet
|
||||
|
||||
- name: Check markup classes
|
||||
run: pnpm run check:markup-classes --html preview/dist --html docs/dist --css preview/dist/dist/css --css preview/dist/dist/libs --css preview/dist/preview/css --css docs/dist/css --css docs/dist/preview/css
|
||||
run: pnpm exec turbo build
|
||||
@@ -7,6 +7,9 @@ on:
|
||||
- main
|
||||
- dev
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
FORCE_COLOR: 2
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Compress Images
|
||||
uses: calibreapp/image-actions@main
|
||||
# pinned to a commit: this job holds a write token
|
||||
uses: calibreapp/image-actions@26d5b54006db4da7a1b29903f33404a6f77b58cf # main, 2026-09-02
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,33 @@
|
||||
name: HTML checks
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
html-checks:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clone repository
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Set up the workspace
|
||||
uses: ./.github/actions/setup
|
||||
|
||||
# only the two sites the checks read; the Build workflow covers the rest
|
||||
- name: Build the preview and the docs
|
||||
run: pnpm exec turbo build --filter=@tabler/preview --filter=@tabler/docs
|
||||
|
||||
- name: Install Playwright
|
||||
uses: ./.github/actions/playwright
|
||||
|
||||
- name: Check rendered html
|
||||
run: pnpm run check:html preview/dist docs/dist --quiet
|
||||
|
||||
- name: Check markup classes
|
||||
run: pnpm run check:markup-classes --html preview/dist --html docs/dist --css preview/dist/dist/css --css preview/dist/dist/libs --css preview/dist/preview/css --css docs/dist/css --css docs/dist/preview/css
|
||||
@@ -14,7 +14,7 @@ jobs:
|
||||
- name: Clone Tabler
|
||||
uses: actions/checkout@v7
|
||||
- name: Prevent lock file change
|
||||
uses: xalvarez/prevent-file-change-action@v3
|
||||
uses: xalvarez/prevent-file-change-action@dbc67c205c9ed02aa39c497b422c24f364c3e8dd # v3.0.1
|
||||
with:
|
||||
githubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
pattern: Gemfile.lock|pnpm-lock.json|pnpm-lock.yaml
|
||||
|
||||
@@ -26,16 +26,18 @@ jobs:
|
||||
|
||||
- name: Set up the workspace
|
||||
uses: ./.github/actions/setup
|
||||
with:
|
||||
turbo-cache: 'false'
|
||||
|
||||
- name: Update npm # trusted publishing requires npm >= 11.5.1
|
||||
run: npm install -g npm@latest
|
||||
run: npm install -g npm@11.19.1
|
||||
|
||||
- name: Build
|
||||
run: pnpm run build
|
||||
|
||||
- name: Create release Pull Request or publish to NPM
|
||||
id: changesets
|
||||
uses: changesets/action@v2
|
||||
uses: changesets/action@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2
|
||||
with:
|
||||
version-script: pnpm run version
|
||||
publish-script: pnpm run publish
|
||||
|
||||
Reference in new issue
Block a user