Skip to content

Commit

Permalink
Run prerelease using global pnpm (#5856)
Browse files Browse the repository at this point in the history
* Run prerelease using global pnpm

* Remove pnpm & yarn version import

* turbo-ify

* pnpm windows

* fixups

* split in JS

* fixups

* Actually run the tests 😅

* composite matrix
  • Loading branch information
penalosa authored May 16, 2024
1 parent df2daf2 commit 5dd9573
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 85 deletions.
22 changes: 11 additions & 11 deletions .github/actions/run-c3-e2e/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: "Run C3 E2E Tests"
description: "Runs the C3 E2E tests on npm, pnpm, and bun"
inputs:
package-manager:
packageManager:
description: "Which package manager to run the tests with"
required: true
packageManagerVersion:
description: "Which package manager version to run the tests with"
required: true
quarantine:
description: "Whether to run the tests in quarantine mode"
required: false
Expand All @@ -20,11 +23,11 @@ inputs:
runs:
using: "composite"
steps:
- if: ${{ matrix.pm == 'bun' }}
name: Install Bun ${{ env.bun-version }}
- if: ${{ inputs.packageManager == 'bun' }}
name: Install Bun ${{ inputs.packageManagerVersion }}
uses: oven-sh/setup-bun@v1
with:
bun-version: ${{ env.bun-version }}
bun-version: ${{ inputs.packageManagerVersion }}

# Needed because gatsby requires git
- name: Configure Git
Expand All @@ -36,21 +39,18 @@ runs:
- name: E2E Tests
id: run-e2e
shell: bash
continue-on-error: true
run: pnpm run --filter create-cloudflare test:e2e:${{ inputs.package-manager }}
run: pnpm run test:e2e --filter create-cloudflare
env:
CLOUDFLARE_API_TOKEN: ${{ inputs.apiToken }}
CLOUDFLARE_ACCOUNT_ID: ${{ inputs.accountId }}
E2E_QUARANTINE: ${{ inputs.quarantine }}
FRAMEWORK_CLI_TO_TEST: ${{ inputs.framework }}
TEST_PM: ${{ inputs.packageManager }}
TEST_PM_VERSION: ${{ inputs.packageManagerVersion }}

- name: Upload Logs
uses: actions/upload-artifact@v3
if: always()
with:
name: e2e-logs-${{matrix.os}}
path: packages/create-cloudflare/.e2e-logs

- name: Fail if errors detected
shell: bash
if: ${{ steps.run-e2e.outcome == 'failure' }}
run: exit 1
18 changes: 15 additions & 3 deletions .github/workflows/c3-e2e-dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
pm: [npm, pnpm, bun, yarn]
pm:
[
{ name: npm, version: "0.0.0" },
{ name: pnpm, version: "9.0.0" },
{ name: bun, version: "1.0.3" },
{ name: yarn, verison: "1.0.0" },
]
# include a single windows test with pnpm
include:
- os: windows-latest
pm: pnpm
pm: { name: pnpm, version: "9.0.0" }
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
Expand All @@ -58,11 +64,17 @@ jobs:

- name: Install Dependencies
uses: ./.github/actions/install-dependencies
with:
turbo-api: ${{ secrets.TURBO_API }}
turbo-team: ${{ secrets.TURBO_TEAM }}
turbo-token: ${{ secrets.TURBO_TOKEN }}
turbo-signature: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}

- name: E2E Tests
uses: ./.github/actions/run-c3-e2e
with:
package-manager: ${{ matrix.pm }}
packageManager: ${{ matrix.pm.name }}
packageManagerVersion: ${{ matrix.pm.version }}
framework: ${{ needs.get-dependabot-bumped-framework.outputs.bumped-framework-cli }}
accountId: ${{ secrets.C3_TEST_CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.C3_TEST_CLOUDFLARE_API_TOKEN }}
18 changes: 14 additions & 4 deletions .github/workflows/c3-e2e-quarantine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ on:
- main
paths:
- packages/create-cloudflare/**
env:
bun-version: 1.0.3

jobs:
e2e:
timeout-minutes: 30
Expand All @@ -23,7 +22,12 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
pm: [npm, pnpm, bun]
pm:
[
{ name: npm, version: "0.0.0" },
{ name: pnpm, version: "9.0.0" },
{ name: bun, version: "1.0.3" },
]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
Expand All @@ -33,11 +37,17 @@ jobs:

- name: Install Dependencies
uses: ./.github/actions/install-dependencies
with:
turbo-api: ${{ secrets.TURBO_API }}
turbo-team: ${{ secrets.TURBO_TEAM }}
turbo-token: ${{ secrets.TURBO_TOKEN }}
turbo-signature: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}

- name: E2E Tests
uses: ./.github/actions/run-c3-e2e
with:
package-manager: ${{ matrix.pm }}
packageManager: ${{ matrix.pm.name}}
packageManagerVersion: ${{ matrix.pm.version }}
quarantine: true
accountId: ${{ secrets.C3_TEST_CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.C3_TEST_CLOUDFLARE_API_TOKEN }}
26 changes: 21 additions & 5 deletions .github/workflows/c3-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ on:
- main
paths:
- packages/create-cloudflare/**
env:
bun-version: 1.0.3

jobs:
e2e:
Expand All @@ -27,11 +25,17 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
pm: [npm, pnpm, bun, yarn]
pm:
[
{ name: npm, version: "0.0.0" },
{ name: pnpm, version: "9.0.0" },
{ name: bun, version: "1.0.3" },
{ name: yarn, verison: "1.0.0" },
]
# include a single windows test with pnpm
include:
- os: windows-latest
pm: pnpm
pm: { name: pnpm, version: "9.0.0" }
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
Expand All @@ -41,13 +45,25 @@ jobs:

- name: Install Dependencies
uses: ./.github/actions/install-dependencies
with:
turbo-api: ${{ secrets.TURBO_API }}
turbo-team: ${{ secrets.TURBO_TEAM }}
turbo-token: ${{ secrets.TURBO_TOKEN }}
turbo-signature: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}

- name: Build
run: pnpm run build
env:
NODE_ENV: "production"
CI_OS: ${{ runner.os }}

- name: E2E Tests
uses: ./.github/actions/run-c3-e2e
env:
NPM_PUBLISH_TOKEN: NOT_USED
with:
package-manager: ${{ matrix.pm }}
packageManager: ${{ matrix.pm.name }}
packageManagerVersion: ${{ matrix.pm.version }}
quarantine: false
accountId: ${{ secrets.C3_TEST_CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.C3_TEST_CLOUDFLARE_API_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
NODE_ENV: "production"

- name: Run tests
run: pnpm run test:e2e
run: pnpm run test:e2e --filter=wrangler
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.TEST_CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.TEST_CLOUDFLARE_ACCOUNT_ID }}
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/prereleases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,19 @@ jobs:
NODE_OPTIONS: "--max_old_space_size=8192"

- name: Publish wrangler@beta to NPM
run: pnpm publish --tag beta
run: pnpm --filter wrangler publish --tag beta
env:
NPM_PUBLISH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
# this is the "test/staging" key for sparrow analytics
SPARROW_SOURCE_KEY: "5adf183f94b3436ba78d67f506965998"
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
SENTRY_DSN: "https://[email protected]/583"
ALGOLIA_PUBLIC_KEY: ${{ secrets.ALGOLIA_PUBLIC_KEY }}
working-directory: packages/wrangler

- name: Publish create-cloudflare@beta to NPM
run: pnpm publish --tag beta
run: pnpm --filter create-cloudflare publish --tag beta
env:
NPM_PUBLISH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
working-directory: packages/create-cloudflare

- name: Get Package Version
run: echo "WRANGLER_VERSION=$(npm view wrangler@beta version)" >> $GITHUB_ENV
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"prettify": "prettier . --write --ignore-unknown",
"test": "vitest run --no-file-parallelism && dotenv -- turbo test --filter=wrangler --filter=miniflare --filter=kv-asset-handler --filter=@cloudflare/vitest-pool-workers --filter=@cloudflare/vitest-pool-workers-examples",
"test:ci": "dotenv -- turbo test:ci --concurrency 1",
"test:e2e": "dotenv -- turbo test:e2e --log-order=stream --filter=wrangler",
"test:e2e": "dotenv -- turbo test:e2e --log-order=stream",
"test:watch": "turbo test:watch",
"type:tests": "dotenv -- turbo type:tests",
"gen:package": "turbo gen package"
Expand Down
1 change: 0 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"chalk": "^2.4.2",
"esbuild": "^0.17.12",
"log-update": "^5.0.1",
"pnpm": "^8.6.11",
"undici": "5.28.4"
}
}
9 changes: 2 additions & 7 deletions packages/create-cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@
"check:type": "tsc",
"lint": "eslint",
"prepublishOnly": "pnpm -w run build",
"test:e2e:npm": "pnpm run build && cross-env TEST_PM=npm vitest run --config ./vitest-e2e.config.ts",
"test:e2e:pnpm": "pnpm run build && cross-env TEST_PM=pnpm vitest run --config ./vitest-e2e.config.ts",
"test:e2e:bun": "pnpm run build && cross-env TEST_PM=bun vitest run --config ./vitest-e2e.config.ts",
"test:e2e:yarn": "pnpm run build && cross-env TEST_PM=yarn vitest run --config ./vitest-e2e.config.ts",
"test:e2e": "vitest run --config ./vitest-e2e.config.ts",
"test:unit": "vitest run --config ./vitest.config.ts",
"test:unit:watch": "vitest --config ./vitest.config.ts",
"watch": "node -r esbuild-register scripts/build.ts --watch",
Expand Down Expand Up @@ -76,16 +73,14 @@
"indent-string": "^5.0.0",
"magic-string": "^0.30.5",
"open": "^8.4.0",
"pnpm": "^8.10.0",
"recast": "^0.22.0",
"semver": "^7.5.1",
"undici": "5.28.4",
"vite-tsconfig-paths": "^4.0.8",
"which-pm-runs": "^1.1.0",
"wrangler": "workspace:*",
"wrap-ansi": "^9.0.0",
"yargs": "^17.7.1",
"yarn": "^1.22.19"
"yargs": "^17.7.1"
},
"engines": {
"node": ">=18.14.1"
Expand Down
28 changes: 4 additions & 24 deletions packages/create-cloudflare/src/helpers/packageManagers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import path from "path";
import { brandColor, dim } from "@cloudflare/cli/colors";
import semver from "semver";
import whichPmRuns from "which-pm-runs";
import { devDependencies } from "../../package.json";
import { runCommand } from "./command";
import type { C3Context } from "types";

Expand All @@ -23,29 +22,10 @@ export const detectPackageManager = () => {

let { name, version } = pmInfo ?? { name: "npm", version: "0.0.0" };

if (process.env.TEST_PM) {
switch (process.env.TEST_PM) {
case "pnpm":
name = "pnpm";
version = devDependencies["pnpm"].replace("^", "");
process.env.npm_config_user_agent = "pnpm";
break;
case "yarn":
name = "yarn";
version = devDependencies["yarn"].replace("^", "");
process.env.npm_config_user_agent = "yarn";
break;
case "bun":
name = "bun";
version = "1.0.0";
process.env.npm_config_user_agent = "bun";
break;
case "npm":
name = "npm";
version = "0.0.0";
process.env.npm_config_user_agent = "npm";
break;
}
if (process.env.TEST_PM && process.env.TEST_PM_VERSION) {
name = process.env.TEST_PM as PmName;
version = process.env.TEST_PM_VERSION;
process.env.npm_config_user_agent = name;
}

switch (name) {
Expand Down
8 changes: 7 additions & 1 deletion packages/create-cloudflare/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

"pipeline": {
"build": {
"env": ["VITEST", "TEST_PM", "npm_config_user_agent", "CI"],
"env": [
"VITEST",
"TEST_PM",
"TEST_PM_VERSION",
"npm_config_user_agent",
"CI"
],
"outputs": ["dist/**"]
},
"test:e2e:*": {
Expand Down
23 changes: 0 additions & 23 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5dd9573

Please sign in to comment.