-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add setup for Vercel / Netlify tests (#7716)
Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com>
- Loading branch information
1 parent
e5e5cc8
commit 471324b
Showing
21 changed files
with
397 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Hosted tests | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * 0' | ||
|
||
env: | ||
ASTRO_TELEMETRY_DISABLED: true | ||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }} | ||
VERCEL_ORG_ID: ${{ secrets.VERCEL_TEST_ORG_ID }} | ||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_TEST_PROJECT_ID }} | ||
VERCEL_TOKEN: ${{ secrets.VERCEL_TEST_TOKEN }} | ||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_TEST_SITE_ID }} | ||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_TEST_AUTH_TOKEN }} | ||
FORCE_COLOR: true | ||
|
||
jobs: | ||
test: | ||
name: Run tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup PNPM | ||
uses: pnpm/action-setup@v2 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: "pnpm" | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Install Hosts CLIs | ||
run: pnpm install --global netlify-cli vercel | ||
|
||
- name: Deploy Vercel | ||
working-directory: ./packages/integrations/vercel/test/hosted/hosted-astro-project | ||
run: | ||
pnpm run build | ||
vercel --prod --prebuilt | ||
|
||
- name: Deploy Netlify | ||
working-directory: ./packages/integrations/netlify/test/hosted/hosted-astro-project | ||
run: | ||
pnpm run build | ||
netlify deploy --prod | ||
|
||
- name: Test both hosts | ||
run: | ||
pnpm run test:e2e:hosts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The tests in this folder are done directly on a deployed Netlify website (hosted at https://curious-boba-495d6d.netlify.app) and are not run by the test suite. They instead run every week through a GitHub action. | ||
|
||
The purpose of those tests is to make sure that everything works as expected while deployed. In a way, they're as E2E as it gets. |
11 changes: 11 additions & 0 deletions
11
packages/integrations/netlify/test/hosted/hosted-astro-project/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import netlify from '@astrojs/netlify'; | ||
import { defineConfig } from 'astro/config'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
output: 'server', | ||
adapter: netlify(), | ||
experimental: { | ||
assets: true, | ||
}, | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/integrations/netlify/test/hosted/hosted-astro-project/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "netlify-hosted-astro-project", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"build": "astro build" | ||
}, | ||
"dependencies": { | ||
"@astrojs/netlify": "file:../../..", | ||
"astro": "file:../../../../../astro" | ||
} | ||
} |
Binary file added
BIN
+9.35 MB
...es/integrations/netlify/test/hosted/hosted-astro-project/src/assets/penguin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
packages/integrations/netlify/test/hosted/hosted-astro-project/src/env.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference types="astro/client-image" /> |
6 changes: 6 additions & 0 deletions
6
packages/integrations/netlify/test/hosted/hosted-astro-project/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
import { Image } from 'astro:assets'; | ||
import penguin from '../assets/penguin.png'; | ||
--- | ||
|
||
<Image src={penguin} width={300} alt="" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { expect } from 'chai'; | ||
|
||
const NETLIFY_TEST_URL = 'https://curious-boba-495d6d.netlify.app'; | ||
|
||
describe('Hosted Netlify Tests', () => { | ||
it('Image endpoint works', async () => { | ||
const image = await fetch( | ||
NETLIFY_TEST_URL + '/_image?href=%2F_astro%2Fpenguin.e9c64733.png&w=300&f=webp' | ||
); | ||
|
||
expect(image.status).to.equal(200); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The tests in this folder are done directly on a deployed Vercel website (hosted at https://astro-vercel-image-test.vercel.app) and are not run by the test suite. They instead run every week through a GitHub action. | ||
|
||
The purpose of those tests is to make sure that everything works as expected while deployed. In a way, they're as E2E as it gets. |
11 changes: 11 additions & 0 deletions
11
packages/integrations/vercel/test/hosted/hosted-astro-project/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import vercel from '@astrojs/vercel/serverless'; | ||
import { defineConfig } from 'astro/config'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
output: 'server', | ||
adapter: vercel(), | ||
experimental: { | ||
assets: true, | ||
}, | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/integrations/vercel/test/hosted/hosted-astro-project/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "vercel-hosted-astro-project", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"build": "astro build" | ||
}, | ||
"dependencies": { | ||
"@astrojs/vercel": "file:../../..", | ||
"astro": "file:../../../../../astro" | ||
} | ||
} |
Binary file added
BIN
+9.35 MB
...ges/integrations/vercel/test/hosted/hosted-astro-project/src/assets/penguin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
packages/integrations/vercel/test/hosted/hosted-astro-project/src/env.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference types="astro/client-image" /> |
6 changes: 6 additions & 0 deletions
6
packages/integrations/vercel/test/hosted/hosted-astro-project/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
import { Image } from 'astro:assets'; | ||
import penguin from '../assets/penguin.png'; | ||
--- | ||
|
||
<Image src={penguin} width={300} alt="" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { expect } from 'chai'; | ||
|
||
const VERCEL_TEST_URL = 'https://astro-vercel-image-test.vercel.app'; | ||
|
||
describe('Hosted Vercel Tests', () => { | ||
it('Image endpoint works', async () => { | ||
const image = await fetch( | ||
VERCEL_TEST_URL + '/_image?href=%2F_astro%2Fpenguin.e9c64733.png&w=300&f=webp' | ||
); | ||
|
||
expect(image.status).to.equal(200); | ||
}); | ||
}); |
Oops, something went wrong.