mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
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
|
||||
|
||||
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.
|
||||
|
|
|
@ -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",
|
||||
|
|
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