-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,34 @@ | ||
name: "Test edge function compatibility" | ||
name: "Test edge function compatibility for Hono on Cloudflare Workers" | ||
on: push | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
env: | ||
NETLIFY_AUTH_TOKEN: ${{ secrets.netlify_auth_token }} | ||
NETLIFY_SITE_ID: ${{ secrets.netlify_site_id }} | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
APP_URL: "https://hono.rishabh-77b.workers.dev" | ||
CLOUDFLARE_PROJECT_NAME: "hono" | ||
TEST_DEPLOYED_VERSION: true | ||
defaults: | ||
run: | ||
working-directory: examples/next/with-emailpassword | ||
working-directory: examples/cloudflare-workers/with-email-password-hono-be-only | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: echo $GITHUB_SHA | ||
- run: npm install git+https://github.com:supertokens/supertokens-node.git#$GITHUB_SHA | ||
- run: npm install | ||
- run: npm install [email protected] [email protected] puppeteer@^11.0.0 isomorphic-fetch@^3.0.0 | ||
- run: netlify deploy --alias 0 --build --json --auth=$NETLIFY_AUTH_TOKEN > deployInfo.json | ||
- run: cat deployInfo.json | ||
- run: | | ||
|
||
- name: Replace APP_URL with deployed URL value | ||
run: | | ||
sed -i "s|process.env.REACT_APP_API_URL|\"${{ env.APP_URL }}\"|" config.ts | ||
sed -i "s|process.env.REACT_APP_WEBSITE_URL|\"${{ env.APP_URL }}\"|" config.ts | ||
- name: Deploy the changes | ||
run: npx wrangler deploy --name ${{ env.CLOUDFLARE_PROJECT_NAME }} index.ts | ||
|
||
- name: Run tests | ||
run: | | ||
( \ | ||
(echo "=========== Test attempt 1 ===========" && npx mocha --no-config --timeout 80000 test/**/*.test.js) || \ | ||
(echo "=========== Test attempt 2 ===========" && npx mocha --no-config --timeout 80000 test/**/*.test.js) || \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: "Test edge function compatibility for Next.js on Cloudflare Workers" | ||
on: push | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
env: | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
APP_URL: "supertokens-node-b95.pages.dev" | ||
CLOUDFLARE_PROJECT_NAME: "supertokens-node-pr-check-for-edge-function-compat" | ||
TEST_DEPLOYED_VERSION: true | ||
defaults: | ||
run: | ||
working-directory: examples/next/with-emailpassword | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: echo $GITHUB_SHA | ||
- run: npm install git+https://github.com:supertokens/supertokens-node.git#$GITHUB_SHA | ||
- run: npm install | ||
- run: npm install [email protected] [email protected] puppeteer@^11.0.0 isomorphic-fetch@^3.0.0 | ||
|
||
# Step to update the runtime to edge to all files in app/api/ | ||
- name: Add runtime export to API files | ||
run: | | ||
find app/api -type f \( -name "*.js" -o -name "*.ts" \) -exec sed -i '1s/^/export const runtime = "edge";\n/' {} + | ||
echo 'export const runtime = "edge";' >> app/auth/[[...path]]/page.tsx | ||
# Install next on pages to build the app | ||
- name: Install next-on-pages | ||
run: npm install --save-dev @cloudflare/next-on-pages | ||
|
||
# Setup the compatibility flag to make non edge functions run | ||
- name: Create a wrangler.toml | ||
run: echo "compatibility_flags = [ "nodejs_compat" ]" >> wrangler.toml | ||
|
||
- name: Replace APP_URL with deployed URL value | ||
run: | | ||
sed -i "s|process.env.APP_URL|\"${{ env.APP_URL }}\"|" config/appInfo.ts | ||
- name: Build using next-on-pages | ||
run: npx next-on-pages | ||
|
||
- name: Publish to Cloudflare Pages | ||
id: deploy | ||
uses: cloudflare/pages-action@v1 | ||
with: | ||
apiToken: ${{ env.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }} | ||
projectName: ${{ env.CLOUDFLARE_PROJECT_NAME }} | ||
directory: "./examples/next/with-emailpassword/.vercel/output/static" | ||
wranglerVersion: "3" | ||
branch: "master" | ||
|
||
- name: Extract deployment info and save to JSON | ||
id: extract_deploy_info | ||
run: | | ||
DEPLOY_ID=${{ steps.deploy.outputs.id }} | ||
DEPLOY_URL=${{ steps.deploy.outputs.url }} | ||
echo "{\"deploy_url\": \"$DEPLOY_URL\", \"deploy_id\": \"$DEPLOY_ID\"}" > deployInfo.json | ||
- name: Run tests | ||
run: | | ||
( \ | ||
(echo "=========== Test attempt 1 ===========" && npx mocha --no-config --timeout 80000 test/**/*.test.js) || \ | ||
(echo "=========== Test attempt 2 ===========" && npx mocha --no-config --timeout 80000 test/**/*.test.js) || \ | ||
(echo "=========== Test attempt 3 ===========" && npx mocha --no-config --timeout 80000 test/**/*.test.js) \ | ||
) | ||
- name: The job has failed | ||
if: ${{ failure() }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: screenshots | ||
path: | | ||
./**/*screenshot.jpeg |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.