improve our smoke tests to run on all examples (#2174)
* improve smoke test * chore(lint): Prettier fix Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
bc080288fe
commit
a656155629
3 changed files with 45 additions and 7 deletions
20
.github/workflows/ci.yml
vendored
20
.github/workflows/ci.yml
vendored
|
@ -163,11 +163,11 @@ jobs:
|
||||||
run: yarn workspace astro run test
|
run: yarn workspace astro run test
|
||||||
|
|
||||||
smoke:
|
smoke:
|
||||||
name: 'Smoke Test: ${{ matrix.target }}'
|
name: 'Test (Smoke) ${{ matrix.os }}'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
target: [docs, www]
|
os: [windows-latest, ubuntu-latest]
|
||||||
needs:
|
needs:
|
||||||
- build
|
- build
|
||||||
steps:
|
steps:
|
||||||
|
@ -177,7 +177,7 @@ jobs:
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 16
|
node-version: 14
|
||||||
cache: 'yarn'
|
cache: 'yarn'
|
||||||
|
|
||||||
- name: Download Build Artifacts
|
- name: Download Build Artifacts
|
||||||
|
@ -198,9 +198,15 @@ jobs:
|
||||||
env:
|
env:
|
||||||
CI: true
|
CI: true
|
||||||
|
|
||||||
- name: Build
|
- name: Test
|
||||||
run: yarn build
|
if: ${{ matrix.os != 'windows-latest' }}
|
||||||
working-directory: ${{ matrix.target }}
|
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.
|
# Changelog can only run _after_ Build and Test.
|
||||||
# We download all `dist/` artifacts from GitHub to skip the build process.
|
# We download all `dist/` artifacts from GitHub to skip the build process.
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"release": "yarn build && changeset publish",
|
"release": "yarn build && changeset publish",
|
||||||
"build": "turbo run build --no-deps --scope=astro --scope=create-astro --scope=\"@astrojs/*\"",
|
"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/*\"",
|
"dev": "turbo run dev --no-deps --no-cache --parallel --scope=astro --scope=create-astro --scope=\"@astrojs/*\"",
|
||||||
"test": "turbo run test --scope=astro",
|
"test": "turbo run test --scope=astro",
|
||||||
"test:templates": "turbo run test --scope=create-astro",
|
"test:templates": "turbo run test --scope=create-astro",
|
||||||
|
|
31
scripts/smoke/index.js
Normal file
31
scripts/smoke/index.js
Normal file
|
@ -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();
|
Loading…
Reference in a new issue