diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15df0d839..d470cfc96 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -163,11 +163,11 @@ jobs: run: yarn workspace astro run test smoke: - name: 'Smoke Test: ${{ matrix.target }}' - runs-on: ubuntu-latest + name: 'Test (Smoke) ${{ matrix.os }}' + runs-on: ${{ matrix.os }} strategy: matrix: - target: [docs, www] + os: [windows-latest, ubuntu-latest] needs: - build steps: @@ -177,7 +177,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v2 with: - node-version: 16 + node-version: 14 cache: 'yarn' - name: Download Build Artifacts @@ -198,9 +198,15 @@ jobs: env: CI: true - - name: Build - run: yarn build - working-directory: ${{ matrix.target }} + - name: Test + if: ${{ matrix.os != 'windows-latest' }} + run: yarn run build:examples --concurrency=1 + + # Turbo seems to fail on Windows, so run a custom script directly. + - name: Test (Windows) + if: ${{ matrix.os == 'windows-latest' }} + run: node ./scripts/smoke/index.js + # Changelog can only run _after_ Build and Test. # We download all `dist/` artifacts from GitHub to skip the build process. diff --git a/package.json b/package.json index 3ad6760a1..500e1b9ff 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "scripts": { "release": "yarn build && changeset publish", "build": "turbo run build --no-deps --scope=astro --scope=create-astro --scope=\"@astrojs/*\"", + "build:examples": "turbo run build --scope=docs --scope=www --scope=\"@example/*\"", "dev": "turbo run dev --no-deps --no-cache --parallel --scope=astro --scope=create-astro --scope=\"@astrojs/*\"", "test": "turbo run test --scope=astro", "test:templates": "turbo run test --scope=create-astro", diff --git a/scripts/smoke/index.js b/scripts/smoke/index.js new file mode 100644 index 000000000..e1e296a61 --- /dev/null +++ b/scripts/smoke/index.js @@ -0,0 +1,31 @@ +import fs from 'fs'; +import { execa } from 'execa'; +import { fileURLToPath } from 'url'; + +// NOTE: Only needed for Windows, due to a Turbo bug. +// Once Turbo works on Windows, we can remove this script +// and update our CI to run through Turbo. + +export default async function run() { + const examplesUrl = new URL('../../examples/', import.meta.url); + const examplesToTest = fs + .readdirSync(examplesUrl) + .map((filename) => new URL(filename, examplesUrl)) + .filter((fileUrl) => fs.statSync(fileUrl).isDirectory()); + const allProjectsToTest = [...examplesToTest, new URL('../../www', import.meta.url), new URL('../../docs', import.meta.url)]; + + console.log(''); + for (const projectToTest of allProjectsToTest) { + const filePath = fileURLToPath(projectToTest); + console.log(' 🤖 Testing', filePath, '\n'); + try { + await execa('yarn', ['build'], { cwd: fileURLToPath(projectToTest), stdout: 'inherit', stderr: 'inherit' }); + } catch (err) { + console.log(err); + process.exit(1); + } + console.log('\n 🤖 Test complete.'); + } +} + +run();