Skip to content

Commit

Permalink
Merge branch 'main' into arpan-withastro#12506-ref
Browse files Browse the repository at this point in the history
  • Loading branch information
apatel369 authored Dec 4, 2024
2 parents ddb82a5 + 350b3da commit a116f13
Show file tree
Hide file tree
Showing 77 changed files with 773 additions and 348 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-knives-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Removes the misleading log message telling that a custom renderer is not recognized while it clearly is and works.
5 changes: 5 additions & 0 deletions .changeset/little-rules-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/upgrade': patch
---

Fixes an issue where running `upgrade` in a directory without `astro` installed shows a false success message
5 changes: 5 additions & 0 deletions .changeset/rare-cooks-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes an issue where the `experimental.svg` had incorrect type, resulting in some errors in the editors.
5 changes: 5 additions & 0 deletions .changeset/red-emus-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/db': patch
---

Fixes a bug that caused an error to be logged about invalid entrypoints
5 changes: 5 additions & 0 deletions .changeset/six-toes-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Correctly handles images in content collections with uppercase file extensions
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/---01-bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ body:
id: bug-reproduction
attributes:
label: Link to Minimal Reproducible Example
description: 'Use [astro.new](https://astro.new) to create a minimal reproduction of the problem. **A minimal reproduction is required** so that others can help debug your issue. If a report is vague (e.g. just a generic error message) and has no reproduction, it may be auto-closed. Not sure how to create a minimal example? [Read our guide](https://docs.astro.build/en/guides/troubleshooting/#creating-minimal-reproductions)'
description: 'Use [StackBlitz](https://astro.new/repro) to create a minimal reproduction of the problem. **A minimal reproduction is required** so that others can help debug your issue. If a report is vague (e.g. just a generic error message) and has no reproduction, it may be auto-closed. Not sure how to create a minimal example? [Read our guide](https://docs.astro.build/en/guides/troubleshooting/#creating-minimal-reproductions)'
placeholder: 'https://stackblitz.com/abcd1234'
validations:
required: true
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/continuous_benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
uses: CodSpeedHQ/action@513a19673a831f139e8717bf45ead67e47f00044 # v3.2.0
timeout-minutes: 30
with:
run: pnpm benchmark codspeed
working-directory: ./benchmark
run: pnpm bench
token: ${{ secrets.CODSPEED_TOKEN }}

2 changes: 1 addition & 1 deletion .github/workflows/issue-labeled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
body: |
Hello @${{ github.event.issue.user.login }}. Please provide a [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) using a GitHub repository or [StackBlitz](https://astro.new). Issues marked with `needs repro` will be closed if they have no activity within 3 days.
Hello @${{ github.event.issue.user.login }}. Please provide a [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) using a GitHub repository or [StackBlitz](https://astro.new/repro). Issues marked with `needs repro` will be closed if they have no activity within 3 days.
labels: "needs triage"
11 changes: 11 additions & 0 deletions benchmark/bench/_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@ export function calculateStat(numbers) {
const max = Math.max(...numbers);
return { avg, stdev, max };
}

export async function makeProject(name) {
console.log('Making project:', name);
const projectDir = new URL(`../projects/${name}/`, import.meta.url);

const makeProjectMod = await import(`../make-project/${name}.js`);
await makeProjectMod.run(projectDir);

console.log('Finished making project:', name);
return projectDir;
}
48 changes: 48 additions & 0 deletions benchmark/bench/codspeed.bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { fileURLToPath } from 'node:url';
import { exec } from 'tinyexec';
import { beforeAll, bench, describe } from 'vitest';
import { astroBin, makeProject } from './_util.js';
let streamingApp;
let nonStreamingApp;
beforeAll(async () => {
const render = await makeProject('render-bench');
const root = fileURLToPath(render);
await exec(astroBin, ['build'], {
nodeOptions: {
cwd: root,
stdio: 'inherit',
},
});
const entry = new URL('./dist/server/entry.mjs', `file://${root}`);
const { manifest, createApp } = await import(entry);
streamingApp = createApp(manifest, true);
nonStreamingApp = createApp(manifest, false);
}, 900000);

describe('Bench rendering', () => {
bench('Rendering: streaming [true], .astro file', async () => {
const request = new Request(new URL('http://exmpale.com/astro'));
await streamingApp.render(request);
});
bench('Rendering: streaming [true], .md file', async () => {
const request = new Request(new URL('http://exmpale.com/md'));
await streamingApp.render(request);
});
bench('Rendering: streaming [true], .mdx file', async () => {
const request = new Request(new URL('http://exmpale.com/mdx'));
await streamingApp.render(request);
});

bench('Rendering: streaming [false], .astro file', async () => {
const request = new Request(new URL('http://exmpale.com/astro'));
await nonStreamingApp.render(request);
});
bench('Rendering: streaming [false], .md file', async () => {
const request = new Request(new URL('http://exmpale.com/md'));
await nonStreamingApp.render(request);
});
bench('Rendering: streaming [false], .mdx file', async () => {
const request = new Request(new URL('http://exmpale.com/mdx'));
await nonStreamingApp.render(request);
});
});
64 changes: 0 additions & 64 deletions benchmark/bench/codspeed.js

This file was deleted.

46 changes: 10 additions & 36 deletions benchmark/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import mri from 'mri';
import fs from 'node:fs/promises';
import path from 'node:path';
import {fileURLToPath, pathToFileURL} from 'node:url';
import { fileURLToPath, pathToFileURL } from 'node:url';
import mri from 'mri';
import { makeProject } from './bench/_util.js';

const args = mri(process.argv.slice(2));

Expand All @@ -14,7 +15,6 @@ Command
memory Run build memory and speed test
render Run rendering speed test
server-stress Run server stress test
codspeed Run codspeed test
cli-startup Run CLI startup speed test
Options
Expand All @@ -30,7 +30,6 @@ const benchmarks = {
render: () => import('./bench/render.js'),
'server-stress': () => import('./bench/server-stress.js'),
'cli-startup': () => import('./bench/cli-startup.js'),
codspeed: () => import('./bench/codspeed.js')
};

if (commandName && !(commandName in benchmarks)) {
Expand All @@ -39,26 +38,12 @@ if (commandName && !(commandName in benchmarks)) {
}

if (commandName) {
if (commandName === 'codspeed') {
const render = await makeProject('render-bench');
const rootRender = fileURLToPath(render);
const bench = benchmarks[commandName];
const benchMod = await bench();
const payload = {
render: {
root: rootRender,
output: await getOutputFile('render')
},
};
await benchMod.run(payload);
} else {
// Run single benchmark
const bench = benchmarks[commandName];
const benchMod = await bench();
const projectDir = await makeProject(args.project || benchMod.defaultProject);
const outputFile = await getOutputFile(commandName);
await benchMod.run(projectDir, outputFile);
}
// Run single benchmark
const bench = benchmarks[commandName];
const benchMod = await bench();
const projectDir = await makeProject(args.project || benchMod.defaultProject);
const outputFile = await getOutputFile(commandName);
await benchMod.run(projectDir, outputFile);
} else {
// Run all benchmarks
for (const name in benchmarks) {
Expand All @@ -70,21 +55,10 @@ if (commandName) {
}
}

export async function makeProject(name) {
console.log('Making project:', name);
const projectDir = new URL(`./projects/${name}/`, import.meta.url);

const makeProjectMod = await import(`./make-project/${name}.js`);
await makeProjectMod.run(projectDir);

console.log('Finished making project:', name);
return projectDir;
}

/**
* @param {string} benchmarkName
*/
async function getOutputFile(benchmarkName) {
export async function getOutputFile(benchmarkName) {
let file;
if (args.output) {
file = pathToFileURL(path.resolve(args.output));
Expand Down
13 changes: 7 additions & 6 deletions benchmark/make-project/markdown-cc1.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ export async function run(projectDir) {
await fs.rm(projectDir, { recursive: true, force: true });
await fs.mkdir(new URL('./src/pages/blog', projectDir), { recursive: true });
await fs.mkdir(new URL('./src/content/blog', projectDir), { recursive: true });
await fs.copyFile(new URL('./image.jpg', import.meta.url), new URL('./src/image.jpg', projectDir));
await fs.copyFile(
new URL('./image.jpg', import.meta.url),
new URL('./src/image.jpg', projectDir),
);

const promises = [];


for (let i = 0; i < 10000; i++) {
const content = `\
# Article ${i}
Expand All @@ -24,11 +26,10 @@ ${loremIpsumMd}
`;
promises.push(
fs.writeFile(new URL(`./src/content/blog/article-${i}.md`, projectDir), content, 'utf-8')
fs.writeFile(new URL(`./src/content/blog/article-${i}.md`, projectDir), content, 'utf-8'),
);
}


await fs.writeFile(
new URL(`./src/pages/blog/[...slug].astro`, projectDir),
`\
Expand All @@ -46,7 +47,7 @@ const { Content } = await entry.render();
<h1>{entry.data.title}</h1>
<Content />
`,
'utf-8'
'utf-8',
);

await Promise.all(promises);
Expand All @@ -58,6 +59,6 @@ import { defineConfig } from 'astro/config';
export default defineConfig({
});`,
'utf-8'
'utf-8',
);
}
8 changes: 4 additions & 4 deletions benchmark/make-project/markdown-cc2.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ${loremIpsumMd}
`;
promises.push(
fs.writeFile(new URL(`./data/blog/article-${i}.md`, projectDir), content, 'utf-8')
fs.writeFile(new URL(`./data/blog/article-${i}.md`, projectDir), content, 'utf-8'),
);
}

Expand All @@ -39,7 +39,7 @@ ${loremIpsumMd}
export const collections = { blog }
`
`,
);

await fs.writeFile(
Expand All @@ -60,7 +60,7 @@ const { Content } = await render(entry);
<h1>{entry.data.title}</h1>
<Content />
`,
'utf-8'
'utf-8',
);

await Promise.all(promises);
Expand All @@ -71,6 +71,6 @@ const { Content } = await render(entry);
import { defineConfig } from 'astro/config';
export default defineConfig({});`,
'utf-8'
'utf-8',
);
}
13 changes: 7 additions & 6 deletions benchmark/make-project/mdx-cc1.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ export async function run(projectDir) {
await fs.rm(projectDir, { recursive: true, force: true });
await fs.mkdir(new URL('./src/pages/blog', projectDir), { recursive: true });
await fs.mkdir(new URL('./src/content/blog', projectDir), { recursive: true });
await fs.copyFile(new URL('./image.jpg', import.meta.url), new URL('./src/image.jpg', projectDir));
await fs.copyFile(
new URL('./image.jpg', import.meta.url),
new URL('./src/image.jpg', projectDir),
);

const promises = [];


for (let i = 0; i < 10000; i++) {
const content = `\
# Article ${i}
Expand All @@ -24,11 +26,10 @@ ${loremIpsumMd}
`;
promises.push(
fs.writeFile(new URL(`./src/content/blog/article-${i}.mdx`, projectDir), content, 'utf-8')
fs.writeFile(new URL(`./src/content/blog/article-${i}.mdx`, projectDir), content, 'utf-8'),
);
}


await fs.writeFile(
new URL(`./src/pages/blog/[...slug].astro`, projectDir),
`\
Expand All @@ -46,7 +47,7 @@ const { Content } = await entry.render();
<h1>{entry.data.title}</h1>
<Content />
`,
'utf-8'
'utf-8',
);

await Promise.all(promises);
Expand All @@ -61,6 +62,6 @@ import mdx from '@astrojs/mdx';
export default defineConfig({
integrations: [mdx()],
});`,
'utf-8'
'utf-8',
);
}
Loading

0 comments on commit a116f13

Please sign in to comment.