Enable Windows tests (#1712)
This commit is contained in:
parent
758c712f01
commit
c0d9ed832e
8 changed files with 366 additions and 358 deletions
24
.github/workflows/ci.yml
vendored
24
.github/workflows/ci.yml
vendored
|
@ -18,19 +18,18 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest]
|
os: [ubuntu-latest]
|
||||||
node_version: [12, 14, 16]
|
node_version: [12, 14, 16]
|
||||||
# TODO: uncomment this (Vite has trouble resolving imports on Windows)
|
include:
|
||||||
# include:
|
- os: windows-latest
|
||||||
# - os: windows-latest
|
node_version: 16
|
||||||
# node_version: 14
|
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
env:
|
env:
|
||||||
LANG: en-us
|
LANG: en-us
|
||||||
name: 'Test: node-${{ matrix.node_version }}, ${{ matrix.os }}'
|
name: 'Test: node-${{ matrix.node_version }}, ${{ matrix.os }}'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Check out code using Git
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set node version to ${{ matrix.node_version }}
|
- name: Set Node version to ${{ matrix.node_version }}
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node_version }}
|
node-version: ${{ matrix.node_version }}
|
||||||
|
@ -50,16 +49,16 @@ jobs:
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: 'Lint: node-14, ubuntu-latest'
|
name: 'Lint: node-16, ubuntu-latest'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set node version to 14
|
- name: Set Node version to 16
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 14
|
node-version: 16
|
||||||
cache: 'yarn'
|
cache: 'yarn'
|
||||||
|
|
||||||
- name: Debug
|
- name: Debug
|
||||||
|
@ -79,14 +78,15 @@ jobs:
|
||||||
# runs-on: ubuntu-latest
|
# runs-on: ubuntu-latest
|
||||||
# name: 'Smoke: node-14, ubuntu-latest'
|
# name: 'Smoke: node-14, ubuntu-latest'
|
||||||
# steps:
|
# steps:
|
||||||
# - uses: actions/checkout@v2
|
# - name: Check out code using Git
|
||||||
|
# uses: actions/checkout@v2
|
||||||
# with:
|
# with:
|
||||||
# fetch-depth: 0
|
# fetch-depth: 0
|
||||||
|
|
||||||
# - name: Set node version to 14
|
# - name: Set Node version to 16
|
||||||
# uses: actions/setup-node@v2
|
# uses: actions/setup-node@v2
|
||||||
# with:
|
# with:
|
||||||
# node-version: 14
|
# node-version: 16
|
||||||
# cache: 'yarn'
|
# cache: 'yarn'
|
||||||
|
|
||||||
# - name: Debug
|
# - name: Debug
|
||||||
|
|
18
.github/workflows/format.yml
vendored
18
.github/workflows/format.yml
vendored
|
@ -5,24 +5,26 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
env:
|
|
||||||
node_version: 14
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
format:
|
format:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Check out code using Git
|
||||||
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.head_ref }}
|
ref: ${{ github.head_ref }}
|
||||||
- uses: actions/setup-node@v2
|
- name: Set Node version to 16
|
||||||
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.node_version }}
|
node-version: 16
|
||||||
- run: yarn --frozen-lockfile --ignore-engines
|
cache: 'yarn'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: yarn --frozen-lockfile --ignore-engines
|
||||||
env:
|
env:
|
||||||
CI: true
|
CI: true
|
||||||
- run: yarn lerna run build --scope @astrojs/parser
|
- run: yarn lerna run build --scope @astrojs/parser
|
||||||
- run: yarn format
|
- name: Format code
|
||||||
|
run: yarn format
|
||||||
- name: Commit changes
|
- name: Commit changes
|
||||||
uses: stefanzweifel/git-auto-commit-action@v4
|
uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
with:
|
with:
|
||||||
|
|
5
.github/workflows/release.yml
vendored
5
.github/workflows/release.yml
vendored
|
@ -10,15 +10,16 @@ jobs:
|
||||||
name: Changelog
|
name: Changelog
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out branch
|
- name: Check out code using Git
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
fetch-depth: 0 # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
||||||
|
|
||||||
- name: Set up Node.js 14.x
|
- name: Set Node version to 14
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 14.x
|
node-version: 14.x
|
||||||
|
cache: 'yarn'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn --frozen-lockfile --ignore-engines
|
run: yarn --frozen-lockfile --ignore-engines
|
||||||
|
|
20
.github/workflows/stat.yml
vendored
20
.github/workflows/stat.yml
vendored
|
@ -5,22 +5,22 @@ on:
|
||||||
# * is a special character in YAML so you have to quote this string
|
# * is a special character in YAML so you have to quote this string
|
||||||
- cron: '0 12 * * *'
|
- cron: '0 12 * * *'
|
||||||
|
|
||||||
env:
|
|
||||||
node_version: 14
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
stat:
|
stat:
|
||||||
if: github.repository == 'snowpackjs/astro'
|
if: github.repository == 'snowpackjs/astro'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
# Check out code using git
|
- name: Check out code using Git
|
||||||
- uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
# Install Node 14
|
- name: Set Node version to 16
|
||||||
- uses: actions/setup-node@v1
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
version: 14
|
node-version: 16
|
||||||
- run: yarn install --frozen-lockfile --ignore-engines --ignore-scripts
|
cache: 'yarn'
|
||||||
- run: node scripts/stats/index.js
|
- name: Install dependencies
|
||||||
|
run: yarn install --frozen-lockfile --ignore-engines --ignore-scripts
|
||||||
|
- name: Collect stats
|
||||||
|
run: node scripts/stats/index.js
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Commit changes
|
- name: Commit changes
|
||||||
|
|
|
@ -142,7 +142,11 @@ class AstroBuilder {
|
||||||
target: 'es2020', // must match an esbuild target
|
target: 'es2020', // must match an esbuild target
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
rollupPluginHTML({ input, extractAssets: false }) as any, // "any" needed for CI; also we don’t need typedefs for this anyway
|
rollupPluginHTML({
|
||||||
|
rootDir: viteConfig.root,
|
||||||
|
input,
|
||||||
|
extractAssets: false,
|
||||||
|
}) as any, // "any" needed for CI; also we don’t need typedefs for this anyway
|
||||||
...(viteConfig.plugins || []),
|
...(viteConfig.plugins || []),
|
||||||
],
|
],
|
||||||
publicDir: viteConfig.publicDir,
|
publicDir: viteConfig.publicDir,
|
||||||
|
|
|
@ -79,7 +79,8 @@ export async function ssr({ astroConfig, filePath, logging, mode, origin, pathna
|
||||||
// Important: This needs to happen first, in case a renderer provides polyfills.
|
// Important: This needs to happen first, in case a renderer provides polyfills.
|
||||||
const renderers = await resolveRenderers(viteServer, astroConfig);
|
const renderers = await resolveRenderers(viteServer, astroConfig);
|
||||||
// Load the module from the Vite SSR Runtime.
|
// Load the module from the Vite SSR Runtime.
|
||||||
const mod = (await viteServer.ssrLoadModule(fileURLToPath(filePath))) as ComponentInstance;
|
const viteFriendlyURL = `/@fs${filePath.pathname}`;
|
||||||
|
const mod = (await viteServer.ssrLoadModule(viteFriendlyURL)) as ComponentInstance;
|
||||||
// Handle dynamic routes
|
// Handle dynamic routes
|
||||||
let params: Params = {};
|
let params: Params = {};
|
||||||
let pageProps: Props = {};
|
let pageProps: Props = {};
|
||||||
|
@ -174,7 +175,7 @@ export async function ssr({ astroConfig, filePath, logging, mode, origin, pathna
|
||||||
}
|
}
|
||||||
|
|
||||||
// inject CSS
|
// inject CSS
|
||||||
[...getStylesForID(fileURLToPath(filePath), viteServer)].forEach((href) => {
|
[...getStylesForID(filePath.pathname, viteServer)].forEach((href) => {
|
||||||
tags.push({
|
tags.push({
|
||||||
tag: 'link',
|
tag: 'link',
|
||||||
attrs: { type: 'text/css', rel: 'stylesheet', href },
|
attrs: { type: 'text/css', rel: 'stylesheet', href },
|
||||||
|
@ -187,7 +188,7 @@ export async function ssr({ astroConfig, filePath, logging, mode, origin, pathna
|
||||||
|
|
||||||
// run transformIndexHtml() in dev to run Vite dev transformations
|
// run transformIndexHtml() in dev to run Vite dev transformations
|
||||||
if (mode === 'development') {
|
if (mode === 'development') {
|
||||||
html = await viteServer.transformIndexHtml(fileURLToPath(filePath), html, pathname);
|
html = await viteServer.transformIndexHtml(filePath.pathname, html, pathname);
|
||||||
}
|
}
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
|
|
|
@ -46,7 +46,8 @@ export default function astro({ config, devServer }: AstroPluginOptions): vite.P
|
||||||
}
|
}
|
||||||
// pages and layouts should be transformed as full documents (implicit <head> <body> etc)
|
// pages and layouts should be transformed as full documents (implicit <head> <body> etc)
|
||||||
// everything else is treated as a fragment
|
// everything else is treated as a fragment
|
||||||
const isPage = id.startsWith(fileURLToPath(config.pages)) || id.startsWith(fileURLToPath(config.layouts));
|
const normalizedID = fileURLToPath(new URL(`file://${id}`));
|
||||||
|
const isPage = normalizedID.startsWith(fileURLToPath(config.pages)) || id.startsWith(fileURLToPath(config.layouts));
|
||||||
let source = await fs.promises.readFile(id, 'utf8');
|
let source = await fs.promises.readFile(id, 'utf8');
|
||||||
let tsResult: TransformResult | undefined;
|
let tsResult: TransformResult | undefined;
|
||||||
|
|
||||||
|
|
|
@ -21179,7 +21179,7 @@ function htmlInlineScriptProxyPlugin(config) {
|
||||||
if (proxyMatch) {
|
if (proxyMatch) {
|
||||||
const index = Number(proxyMatch[1]);
|
const index = Number(proxyMatch[1]);
|
||||||
const file = cleanUrl(id);
|
const file = cleanUrl(id);
|
||||||
const url = file.replace(config.root, '');
|
const url = file.replace(normalizePath$4(config.root), '');
|
||||||
const result = htmlProxyMap.get(config).get(url)[index];
|
const result = htmlProxyMap.get(config).get(url)[index];
|
||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -21319,7 +21319,7 @@ function buildHtmlPlugin(config) {
|
||||||
.map((child) => child.content || '')
|
.map((child) => child.content || '')
|
||||||
.join('');
|
.join('');
|
||||||
// <script type="module">...</script>
|
// <script type="module">...</script>
|
||||||
const filePath = id.replace(config.root, '');
|
const filePath = id.replace(normalizePath$4(config.root), '')
|
||||||
addToHTMLProxyCache(config, filePath, inlineModuleIndex, contents);
|
addToHTMLProxyCache(config, filePath, inlineModuleIndex, contents);
|
||||||
js += `\nimport "${id}?html-proxy&index=${inlineModuleIndex}.js"`;
|
js += `\nimport "${id}?html-proxy&index=${inlineModuleIndex}.js"`;
|
||||||
shouldRemove = true;
|
shouldRemove = true;
|
||||||
|
@ -22950,7 +22950,6 @@ var commondir = function (basedir, relfiles) {
|
||||||
);
|
);
|
||||||
return ps.slice(0, i);
|
return ps.slice(0, i);
|
||||||
}, files[0].split(/\/+|\\+/));
|
}, files[0].split(/\/+|\\+/));
|
||||||
|
|
||||||
// Windows correctly handles paths with forward-slashes
|
// Windows correctly handles paths with forward-slashes
|
||||||
return res.length > 1 ? res.join('/') : '/'
|
return res.length > 1 ? res.join('/') : '/'
|
||||||
};
|
};
|
||||||
|
@ -56977,14 +56976,14 @@ const devHtmlHook = async (html, { path: htmlPath, server, originalUrl }) => {
|
||||||
processNodeUrl(src, s, config, htmlPath, originalUrl);
|
processNodeUrl(src, s, config, htmlPath, originalUrl);
|
||||||
}
|
}
|
||||||
else if (isModule) {
|
else if (isModule) {
|
||||||
const url = filePath.replace(config.root, '');
|
const url = filePath.replace(normalizePath$4(config.root), '');
|
||||||
const contents = node.children
|
const contents = node.children
|
||||||
.map((child) => child.content || '')
|
.map((child) => child.content || '')
|
||||||
.join('');
|
.join('');
|
||||||
// add HTML Proxy to Map
|
// add HTML Proxy to Map
|
||||||
addToHTMLProxyCache(config, url, scriptModuleIndex, contents);
|
addToHTMLProxyCache(config, url, scriptModuleIndex, contents);
|
||||||
// inline js module. convert to src="proxy"
|
// inline js module. convert to src="proxy"
|
||||||
s.overwrite(node.loc.start.offset, node.loc.end.offset, `<script type="module" src="${config.base + url.slice(1)}?html-proxy&index=${scriptModuleIndex}.js"></script>`);
|
s.overwrite(node.loc.start.offset, node.loc.end.offset, `<script type="module" src="${filePath}?html-proxy&index=${scriptModuleIndex}.js"></script>`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// elements with [href/src] attrs
|
// elements with [href/src] attrs
|
||||||
|
|
Loading…
Add table
Reference in a new issue