Skip to content

Commit 284369a

Browse files
anonrigbillyvg
authored andcommitted
test(cloudflare): add example astro package (#10108)
1 parent 73d8aa1 commit 284369a

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
@@ -860,6 +860,7 @@ jobs:
860860
matrix:
861861
test-application:
862862
[
863+
'cloudflare-astro',
863864
'node-express-app',
864865
'create-react-app',
865866
'create-next-app',
@@ -946,6 +947,16 @@ jobs:
946947
timeout-minutes: 5
947948
run: yarn test:assert
948949

950+
- name: Deploy Astro to Cloudflare
951+
uses: cloudflare/pages-action@v1
952+
if: matrix.test-application == 'cloudflare-astro'
953+
with:
954+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
955+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
956+
projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }}
957+
directory: dist
958+
workingDirectory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
959+
949960
job_required_jobs_passed:
950961
name: All required jobs passed or were skipped
951962
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>
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
---
2+
import Layout from '../layouts/Layout.astro';
3+
import Card from '../components/Card.astro';
4+
---
5+
6+
<Layout title="Welcome to Astro.">
7+
<main>
8+
<svg
9+
class="astro-a"
10+
width="495"
11+
height="623"
12+
viewBox="0 0 495 623"
13+
fill="none"
14+
xmlns="http://www.w3.org/2000/svg"
15+
aria-hidden="true"
16+
>
17+
<path
18+
fill-rule="evenodd"
19+
clip-rule="evenodd"
20+
d="M167.19 364.254C83.4786 364.254 0 404.819 0 404.819C0 404.819 141.781 19.4876 142.087 18.7291C146.434 7.33701 153.027 0 162.289 0H332.441C341.703 0 348.574 7.33701 352.643 18.7291C352.92 19.5022 494.716 404.819 494.716 404.819C494.716 404.819 426.67 364.254 327.525 364.254L264.41 169.408C262.047 159.985 255.147 153.581 247.358 153.581C239.569 153.581 232.669 159.985 230.306 169.408L167.19 364.254ZM160.869 530.172C160.877 530.18 160.885 530.187 160.894 530.195L160.867 530.181C160.868 530.178 160.868 530.175 160.869 530.172ZM136.218 411.348C124.476 450.467 132.698 504.458 160.869 530.172C160.997 529.696 161.125 529.242 161.248 528.804C161.502 527.907 161.737 527.073 161.917 526.233C165.446 509.895 178.754 499.52 195.577 500.01C211.969 500.487 220.67 508.765 223.202 527.254C224.141 534.12 224.23 541.131 224.319 548.105C224.328 548.834 224.337 549.563 224.347 550.291C224.563 566.098 228.657 580.707 237.264 593.914C245.413 606.426 256.108 615.943 270.749 622.478C270.593 621.952 270.463 621.508 270.35 621.126C270.045 620.086 269.872 619.499 269.685 618.911C258.909 585.935 266.668 563.266 295.344 543.933C298.254 541.971 301.187 540.041 304.12 538.112C310.591 533.854 317.059 529.599 323.279 525.007C345.88 508.329 360.09 486.327 363.431 457.844C364.805 446.148 363.781 434.657 359.848 423.275C358.176 424.287 356.587 425.295 355.042 426.275C351.744 428.366 348.647 430.33 345.382 431.934C303.466 452.507 259.152 455.053 214.03 448.245C184.802 443.834 156.584 436.019 136.218 411.348Z"
21+
fill="url(#paint0_linear_1805_24383)"></path>
22+
<defs>
23+
<linearGradient
24+
id="paint0_linear_1805_24383"
25+
x1="247.358"
26+
y1="0"
27+
x2="247.358"
28+
y2="622.479"
29+
gradientUnits="userSpaceOnUse"
30+
>
31+
<stop stop-opacity="0.9"></stop>
32+
<stop offset="1" stop-opacity="0.2"></stop>
33+
</linearGradient>
34+
</defs>
35+
</svg>
36+
<h1>Welcome to <span class="text-gradient">Astro</span></h1>
37+
<p class="instructions">
38+
To get started, open the directory <code>src/pages</code> in your project.<br />
39+
<strong>Code Challenge:</strong> Tweak the "Welcome to Astro" message above.
40+
</p>
41+
<ul role="list" class="link-card-grid">
42+
<Card
43+
href="https://docs.astro.build/"
44+
title="Documentation"
45+
body="Learn how Astro works and explore the official API docs."
46+
/>
47+
<Card
48+
href="https://astro.build/integrations/"
49+
title="Integrations"
50+
body="Supercharge your project with new frameworks and libraries."
51+
/>
52+
<Card
53+
href="https://astro.build/themes/"
54+
title="Themes"
55+
body="Explore a galaxy of community-built starter themes."
56+
/>
57+
<Card
58+
href="https://astro.build/chat/"
59+
title="Community"
60+
body="Come say hi to our amazing Discord community. ❤️"
61+
/>
62+
</ul>
63+
</main>
64+
</Layout>
65+
66+
<style>
67+
main {
68+
margin: auto;
69+
padding: 1rem;
70+
width: 800px;
71+
max-width: calc(100% - 2rem);
72+
color: white;
73+
font-size: 20px;
74+
line-height: 1.6;
75+
}
76+
.astro-a {
77+
position: absolute;
78+
top: -32px;
79+
left: 50%;
80+
transform: translatex(-50%);
81+
width: 220px;
82+
height: auto;
83+
z-index: -1;
84+
}
85+
h1 {
86+
font-size: 4rem;
87+
font-weight: 700;
88+
line-height: 1;
89+
text-align: center;
90+
margin-bottom: 1em;
91+
}
92+
.text-gradient {
93+
background-image: var(--accent-gradient);
94+
-webkit-background-clip: text;
95+
-webkit-text-fill-color: transparent;
96+
background-size: 400%;
97+
background-position: 0%;
98+
}
99+
.instructions {
100+
margin-bottom: 2rem;
101+
border: 1px solid rgba(var(--accent-light), 25%);
102+
background: linear-gradient(rgba(var(--accent-dark), 66%), rgba(var(--accent-dark), 33%));
103+
padding: 1.5rem;
104+
border-radius: 8px;
105+
}
106+
.instructions code {
107+
font-size: 0.8em;
108+
font-weight: bold;
109+
background: rgba(var(--accent-light), 12%);
110+
color: rgb(var(--accent-light));
111+
border-radius: 4px;
112+
padding: 0.3em 0.4em;
113+
}
114+
.instructions strong {
115+
color: rgb(var(--accent-light));
116+
}
117+
.link-card-grid {
118+
display: grid;
119+
grid-template-columns: repeat(auto-fit, minmax(24ch, 1fr));
120+
gap: 2rem;
121+
padding: 0;
122+
}
123+
</style>

packages/astro/src/integration/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
8888
updateConfig({
8989
vite: {
9090
ssr: {
91-
noExternal: ['@sentry/astro'],
91+
// @sentry/node is required in case we have 2 different @sentry/node
92+
// packages installed in the same project.
93+
// Ref: https://github.com/getsentry/sentry-javascript/issues/10121
94+
noExternal: ['@sentry/astro', '@sentry/node'],
9295
},
9396
},
9497
});

0 commit comments

Comments
 (0)