Skip to content

Commit 84791bf

Browse files
authored
test(cloudflare): add example astro package (#10108)
1 parent 2c0c99e commit 84791bf

File tree

12 files changed

+342
-1
lines changed

12 files changed

+342
-1
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ jobs:
858858
matrix:
859859
test-application:
860860
[
861+
'cloudflare-astro',
861862
'node-express-app',
862863
'create-react-app',
863864
'create-next-app',
@@ -944,6 +945,16 @@ jobs:
944945
timeout-minutes: 5
945946
run: yarn test:assert
946947

948+
- name: Deploy Astro to Cloudflare
949+
uses: cloudflare/pages-action@v1
950+
if: matrix.test-application == 'cloudflare-astro'
951+
with:
952+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
953+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
954+
projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }}
955+
directory: dist
956+
workingDirectory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
957+
947958
job_required_jobs_passed:
948959
name: All required jobs passed or were skipped
949960
needs:
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# build output
2+
dist/
3+
4+
# generated types
5+
.astro/
6+
7+
# dependencies
8+
node_modules/
9+
10+
# logs
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
pnpm-debug.log*
15+
16+
# environment variables
17+
.env
18+
.env.production
19+
20+
# macOS-specific files
21+
.DS_Store
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import cloudflare from '@astrojs/cloudflare';
2+
import sentry from '@sentry/astro';
3+
import { defineConfig } from 'astro/config';
4+
5+
const dsn = process.env.E2E_TEST_DSN;
6+
7+
// https://astro.build/config
8+
export default defineConfig({
9+
output: 'hybrid',
10+
adapter: cloudflare({
11+
imageService: 'passthrough',
12+
}),
13+
integrations: [
14+
sentry({
15+
enabled: Boolean(dsn),
16+
dsn,
17+
sourceMapsUploadOptions: {
18+
enabled: false,
19+
},
20+
clientInitPath: 'sentry.client.mjs',
21+
serverInitPath: 'sentry.server.mjs',
22+
}),
23+
],
24+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "cloudflare-astro",
3+
"type": "module",
4+
"version": "0.0.1",
5+
"private": true,
6+
"scripts": {
7+
"astro": "astro",
8+
"build": "astro build",
9+
"build:bundle": "astro build",
10+
"clean": "npx rimraf node_modules,pnpm-lock.yaml",
11+
"dev": "astro dev",
12+
"preview": "astro preview",
13+
"start": "astro dev",
14+
"test:prod": "pnpm -v",
15+
"test:dev": "pnpm -v",
16+
"test:build": "pnpm install && pnpm build",
17+
"test:assert": "pnpm -v"
18+
},
19+
"dependencies": {
20+
"@astrojs/cloudflare": "8.1.0",
21+
"@sentry/astro": "latest || *",
22+
"astro": "4.1.1"
23+
},
24+
"volta": {
25+
"extends": "../../package.json"
26+
}
27+
}
Lines changed: 9 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as Sentry from '@sentry/astro';
2+
3+
Sentry.init({
4+
dsn: process.env.E2E_TEST_DSN,
5+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as Sentry from '@sentry/astro';
2+
3+
Sentry.init({
4+
dsn: process.env.E2E_TEST_DSN,
5+
});
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
interface Props {
3+
title: string;
4+
body: string;
5+
href: string;
6+
}
7+
8+
const { href, title, body } = Astro.props;
9+
---
10+
11+
<li class="link-card">
12+
<a href={href}>
13+
<h2>
14+
{title}
15+
<span>&rarr;</span>
16+
</h2>
17+
<p>
18+
{body}
19+
</p>
20+
</a>
21+
</li>
22+
<style>
23+
.link-card {
24+
list-style: none;
25+
display: flex;
26+
padding: 1px;
27+
background-color: #23262d;
28+
background-image: none;
29+
background-size: 400%;
30+
border-radius: 7px;
31+
background-position: 100%;
32+
transition: background-position 0.6s cubic-bezier(0.22, 1, 0.36, 1);
33+
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
34+
}
35+
.link-card > a {
36+
width: 100%;
37+
text-decoration: none;
38+
line-height: 1.4;
39+
padding: calc(1.5rem - 1px);
40+
border-radius: 8px;
41+
color: white;
42+
background-color: #23262d;
43+
opacity: 0.8;
44+
}
45+
h2 {
46+
margin: 0;
47+
font-size: 1.25rem;
48+
transition: color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
49+
}
50+
p {
51+
margin-top: 0.5rem;
52+
margin-bottom: 0;
53+
}
54+
.link-card:is(:hover, :focus-within) {
55+
background-position: 0;
56+
background-image: var(--accent-gradient);
57+
}
58+
.link-card:is(:hover, :focus-within) h2 {
59+
color: rgb(var(--accent-light));
60+
}
61+
</style>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="astro/client" />
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
interface Props {
3+
title: string;
4+
}
5+
6+
const { title } = Astro.props;
7+
---
8+
9+
<!doctype html>
10+
<html lang="en">
11+
<head>
12+
<meta charset="UTF-8" />
13+
<meta name="description" content="Astro description" />
14+
<meta name="viewport" content="width=device-width" />
15+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
16+
<meta name="generator" content={Astro.generator} />
17+
<title>{title}</title>
18+
</head>
19+
<body>
20+
<slot />
21+
</body>
22+
</html>
23+
<style is:global>
24+
:root {
25+
--accent: 136, 58, 234;
26+
--accent-light: 224, 204, 250;
27+
--accent-dark: 49, 10, 101;
28+
--accent-gradient: linear-gradient(
29+
45deg,
30+
rgb(var(--accent)),
31+
rgb(var(--accent-light)) 30%,
32+
white 60%
33+
);
34+
}
35+
html {
36+
font-family: system-ui, sans-serif;
37+
background: #13151a;
38+
background-size: 224px;
39+
}
40+
code {
41+
font-family:
42+
Menlo,
43+
Monaco,
44+
Lucida Console,
45+
Liberation Mono,
46+
DejaVu Sans Mono,
47+
Bitstream Vera Sans Mono,
48+
Courier New,
49+
monospace;
50+
}
51+
</style>

0 commit comments

Comments
 (0)