Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run all smoke tests with the static build #2609

Merged
merged 6 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/with-vite-plugin-pwa/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

<body>
<h1>Welcome to <a href="https://astro.build/">Astro</a></h1>
<script src={Astro.resolve('../index.ts')} type="module" hoist></script>
<script src="/src/index.ts" type="module" hoist></script>
</body>
</html>
56 changes: 31 additions & 25 deletions scripts/smoke/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ async function run() {
process.exit(1);
}

// Run with the static build too
if(directory.pathname.includes('astro.build')) {
// astro.build uses the static build, so rerunning with the flag actually negates it.
continue;
}

try {
await execa('yarn', ['build', '--', '--experimental-static-build'], { cwd: fileURLToPath(directory), stdout: 'inherit', stderr: 'inherit' });
} catch (err) {
console.log(err);

process.exit(1);
}

console.log();
}
}
Expand All @@ -79,42 +93,34 @@ const downloadGithubZip = async (/** @type {GithubOpts} */ opts) => {
/** Expected directory when the zip is downloaded. */
const githubDir = new URL(`${opts.name}-${opts.branch}`, scriptDir);

/** Whether the expected directory is already available */
const hasGithubDir = await fs.stat(githubDir).then(
(stats) => stats.isDirectory(),
() => false
);
console.log('🤖', 'Downloading', `${opts.org}/${opts.name}#${opts.branch}`);

if (!hasGithubDir) {
console.log('🤖', 'Downloading', `${opts.org}/${opts.name}#${opts.branch}`);
const buffer = await fetchGithubZip(opts);

const buffer = await fetchGithubZip(opts);
console.log('🤖', 'Extracting', `${opts.org}/${opts.name}#${opts.branch}`);

console.log('🤖', 'Extracting', `${opts.org}/${opts.name}#${opts.branch}`);
new Zip(buffer).extractAllTo(fileURLToPath(scriptDir), true);

new Zip(buffer).extractAllTo(fileURLToPath(scriptDir), true);
console.log('🤖', 'Preparing', `${opts.org}/${opts.name}#${opts.branch}`);

console.log('🤖', 'Preparing', `${opts.org}/${opts.name}#${opts.branch}`);
const astroPackage = await readDirectoryPackage(astroDir);

const astroPackage = await readDirectoryPackage(astroDir);
const githubPackage = await readDirectoryPackage(githubDir);

const githubPackage = await readDirectoryPackage(githubDir);

if ('astro' in Object(githubPackage.dependencies)) {
githubPackage.dependencies['astro'] = astroPackage.version;
}

if ('astro' in Object(githubPackage.devDependencies)) {
githubPackage.devDependencies['astro'] = astroPackage.version;
}
if ('astro' in Object(githubPackage.dependencies)) {
githubPackage.dependencies['astro'] = astroPackage.version;
}

if ('astro' in Object(githubPackage.peerDependencies)) {
githubPackage.peerDependencies['astro'] = astroPackage.version;
}
if ('astro' in Object(githubPackage.devDependencies)) {
githubPackage.devDependencies['astro'] = astroPackage.version;
}

await writeDirectoryPackage(githubDir, githubPackage);
if ('astro' in Object(githubPackage.peerDependencies)) {
githubPackage.peerDependencies['astro'] = astroPackage.version;
}

await writeDirectoryPackage(githubDir, githubPackage);

return githubDir;
};

Expand Down