Skip to content

Commit

Permalink
ci: add build generated templates job
Browse files Browse the repository at this point in the history
  • Loading branch information
denolfe committed Jun 5, 2024
1 parent a72f53b commit 6617df6
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,35 @@ jobs:
yarn build
yarn generate:types
generated-templates:
needs: build

steps:
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off

- name: Setup Node@${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: ${{ env.PNPM_VERSION }}
run_install: false

- name: Restore build
uses: actions/cache@v4
timeout-minutes: 10
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}

- name: Build all generated templates
run: pnpm tsx ./scripts/build-generated-templates.ts

all-green:
name: All Green
if: always()
Expand Down
36 changes: 36 additions & 0 deletions scripts/build-generated-templates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as fs from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import path from 'path'
import { execSync } from 'child_process'

const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)

main().catch((error) => {
console.error(error)
process.exit(1)
})

async function main() {
// Get all directories in `templates` directory
const repoRoot = path.resolve(dirname, '..')
const templatesDir = path.resolve(repoRoot, 'templates')

const rawTemplateDirs = await fs.readdir(templatesDir, { withFileTypes: true })
const templateDirnames = rawTemplateDirs
.filter(
(dirent) =>
dirent.isDirectory() && (dirent.name.startsWith('with') || dirent.name == 'blank'),
)
.map((dirent) => dirent.name)

console.log(`Found generated templates: ${templateDirnames}`)

// Build each template
for (const template of templateDirnames) {
const cmd = `cd ${templatesDir}/${template} && pnpm install --ignore-workspace --no-frozen-lockfile && pnpm build`
console.log(`🔧 Building ${template}...`)
console.log(` cmd: ${cmd}\n\n`)
execSync(cmd, { stdio: 'inherit' })
}
}

0 comments on commit 6617df6

Please sign in to comment.