Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate tests to CircleCi #2716

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
243 changes: 243 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
version: 2.1

orbs:
node: circleci/[email protected]
bun: ksylvest/[email protected]
deno: ksylvest/[email protected]

executors:
ubuntu:
machine:
image: 'ubuntu-2404:2024.11.1'
resource_class: large
windows:
machine:
image: 'windows-server-2022-gui:2024.07.1'
resource_class: windows.large
shell: bash.exe

parameters:
# Comma separated list, e.g. canary, latest, 14.2.15, 13.5.1
next-versions:
type: string
default: latest
# Should match the buildbot node version
node-version:
type: string
default: '18.20'
# Should match the DENO_VERSION_RANGE from https://github.com/netlify/edge-bundler/blob/main/node/bridge.ts#L17
deno-version:
type: string
default: '1.37.0'

jobs:
e2e:
parameters:
next-version:
type: string
executor: ubuntu
parallelism: 4
steps:
- checkout
- node/install:
node-version: << pipeline.parameters.node-version >>
- run: corepack enable
- bun/install
- deno/install
- run:
name: Set Deno Version
command: deno upgrade --version << pipeline.parameters.deno-version >>
- node/install-packages
- run:
name: Install Netlify CLI
environment:
NETLIFY_SITE_ID: $NETLIFY_SITE_ID
NETLIFY_AUTH_TOKEN: $NETLIFY_AUTH_TOKEN
command: |
# Control netlify-cli as a regular dev dep but expose it globally for test fixtures to use
npm install -g "netlify-cli@$(npm list --json --depth=0 netlify-cli | jq -r ".dependencies[\"netlify-cli\"].version")"
npx netlify login
- run:
name: Get Playwright Version
command: |
PLAYWRIGHT_VERSION=$(npm view @playwright/test version)
echo $PLAYWRIGHT_VERSION > /tmp/playwright-version
- restore_cache:
name: Restore Playwright Cache
key: v1-{{ arch }}-playwright-{{ checksum "/tmp/playwright-version" }}
- run:
name: Install Playwright Browsers
command: |
if [ ! -d ~/.cache/ms-playwright ]; then
npx playwright install --with-deps
fi
- save_cache:
name: Save Playwright Cache
paths:
- ~/.cache/ms-playwright
key: v1-{{ arch }}-playwright-{{ checksum "/tmp/playwright-version" }}
- run:
name: Resolve Next.js version
command: |
RESOLVED_VERSION=$(npm view next@<< parameters.next-version >> version)
echo "export RESOLVED_VERSION=$RESOLVED_VERSION" >> $BASH_ENV
echo "Resolved Next.js version for 'next@<< parameters.next-version >>' is '$RESOLVED_VERSION'"
- run:
name: Run Playwright tests
command: |
SHARD=$((${CIRCLE_NODE_INDEX}+1))
npm run test:ci:e2e -- --shard=${SHARD}/${CIRCLE_NODE_TOTAL}
environment:
NEXT_VERSION: << parameters.next-version >>
NETLIFY_SITE_ID: $NETLIFY_SITE_ID
NETLIFY_AUTH_TOKEN: $NETLIFY_AUTH_TOKEN
PLAYWRIGHT_BLOB_OUTPUT_NAME:
report-<< parameters.next-version >>-{{ .Environment.CIRCLE_NODE_INDEX }}.zip
- persist_to_workspace:
name: Upload Blob Report to CircleCI Artifacts
root: .
paths:
- ./blob-report

test:
parameters:
next-version:
type: string
os:
type: executor
default: ubuntu
executor: << parameters.os >>
parallelism: 8
steps:
- checkout
- node/install:
node-version: << pipeline.parameters.node-version >>
- run: corepack enable
- deno/install
- run:
name: Set Deno Version
command: deno upgrade --version << pipeline.parameters.deno-version >>
- node/install-packages
- run:
name: Build
command: npm run build
- run:
name: Resolve Next.js version
command: |
RESOLVED_VERSION=$(npm view next@<< parameters.next-version >> version)
echo "export RESOLVED_VERSION=$RESOLVED_VERSION" >> $BASH_ENV
echo "Resolved Next.js version for 'next@<< parameters.next-version >>' is '$RESOLVED_VERSION'"
- run:
name: Compute Fixtures Cache Key
command: |
CACHE_KEY=$(git ls-files -s tests/fixtures/ tests/utils/ tests/prepare.mjs | git hash-object --stdin)
echo "{$RESOLVED_VERSION}-{$CACHE_KEY}" > /tmp/fixtures-cache-key
- restore_cache:
name: Restore Fixtures Cache
key: v1-{{ arch }}-fixtures-{{ checksum "/tmp/fixtures-cache-key" }}
- run:
name: Prepare Fixtures
command: |
if [ ! -d tests/fixtures/simple/.next ]; then
npm run pretest
fi
environment:
NEXT_VERSION: << parameters.next-version >>
NEXT_RESOLVED_VERSION: $RESOLVED_VERSION
- save_cache:
name: Save Fixtures Cache
paths:
- tests/fixtures
key: v1-{{ arch }}-fixtures-{{ checksum "/tmp/fixtures-cache-key" }}
- run:
name: Run Unit and Integration Tests
command: |
SHARD=$((${CIRCLE_NODE_INDEX}+1))
npm run test:ci:unit-and-integration -- --shard=${SHARD}/${CIRCLE_NODE_TOTAL}
environment:
NEXT_VERSION: << parameters.next-version >>
NETLIFY_SITE_ID: $NETLIFY_SITE_ID
NETLIFY_AUTH_TOKEN: $NETLIFY_AUTH_TOKEN
TEMP: /tmp

smoke:
parameters:
next-version:
type: string
executor: ubuntu
steps:
- checkout
- node/install:
node-version: << pipeline.parameters.node-version >>
- run: corepack enable
- deno/install
- run:
name: Set Deno Version
command: deno upgrade --version << pipeline.parameters.deno-version >>
- node/install-packages
- run:
name: Build
command: npm run build
- run:
name: Install Netlify CLI
environment:
NETLIFY_SITE_ID: $NETLIFY_SITE_ID
NETLIFY_AUTH_TOKEN: $NETLIFY_AUTH_TOKEN
command: |
# Control netlify-cli as a regular dev dep but expose it globally for test fixtures to use
npm install -g "netlify-cli@$(npm list --json --depth=0 netlify-cli | jq -r ".dependencies[\"netlify-cli\"].version")"
npx netlify login
- run:
name: Resolve Next.js version
command: |
RESOLVED_VERSION=$(npm view next@<< parameters.next-version >> version)
echo "export RESOLVED_VERSION=$RESOLVED_VERSION" >> $BASH_ENV
echo "Resolved Next.js version for 'next@<< parameters.next-version >>' is '$RESOLVED_VERSION'"
- run:
name: Run Smoke Tests
command: npm run test:ci:smoke
environment:
NEXT_VERSION: << parameters.next-version >>
NETLIFY_SITE_ID: $NETLIFY_SITE_ID
NETLIFY_AUTH_TOKEN: $NETLIFY_AUTH_TOKEN

merge-reports:
parameters:
next-version:
type: string
executor: ubuntu
steps:
- checkout
- node/install:
node-version: << pipeline.parameters.node-version >>
- node/install-packages
- attach_workspace:
at: .
- run:
name: Merge reports
command: npx playwright merge-reports --reporter html ./blob-reports
- store_artifacts:
path: playwright-report
destination: html-report-<< parameters.next-version >>-${ .Environment.CIRCLE_BUILD_NUM}

workflows:
build-and-test-adapter:
jobs:
- e2e:
matrix:
parameters:
next-version: [<< pipeline.parameters.next-versions >>]
- test:
matrix:
parameters:
next-version: [<< pipeline.parameters.next-versions >>]
os: [ubuntu, windows]
- smoke:
matrix:
parameters:
next-version: [<< pipeline.parameters.next-versions >>]
- merge-reports:
requires: [e2e]
matrix:
parameters:
next-version: [<< pipeline.parameters.next-versions >>]
Loading