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

ci: only deploy Workers when pushing to special branches #4848

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,50 +1,53 @@
name: Edge Preview Authenticated Proxy Worker
name: Deploy Edge Preview Authenticated Proxy Worker (production)

# On a push to `deploy-worker/edge-preview-authenticated-proxy`, on Cloudflare,
# deploy to production.
on:
push:
branches:
- main
paths:
- "packages/edge-preview-authenticated-proxy/**"
- deploy-worker/edge-preview-authenticated-proxy

jobs:
publish_worker:
deploy_worker:
if: ${{ github.repository_owner == 'cloudflare' }}
name: Publish Worker
name: Deploy Edge Preview Authenticated Proxy (production)
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2

- name: Use pnpm 8.8.0
uses: pnpm/action-setup@v2
with:
version: 8.8.0

- name: Use Node.js 16.18
uses: actions/setup-node@v3
with:
node-version: 16.18
cache: "pnpm"

- name: Install workerd Dependencies
- name: Install workerd dependencies
if: ${{ runner.os == 'Linux' }}
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install -y libc++1

- name: Install NPM Dependencies
- name: Install NPM dependencies
run: pnpm install --frozen-lockfile

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

- name: Build & Publish Worker
run: pnpm run publish
- name: Build & deploy Worker
run: pnpm run deploy
env:
NODE_ENV: "production"
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
name: Error Formatting Worker
name: Deploy Format Errors Worker (production)

# On a push to `deploy-worker/format-errors`, on Cloudflare,
# deploy to production.
on:
push:
branches:
- main
paths:
- "packages/format-errors/**"
- deploy-worker/format-errors

jobs:
publish_worker:
deploy_worker:
if: ${{ github.repository_owner == 'cloudflare' }}
name: Publish Worker
name: Deploy Format Errors Worker (production)
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2

- name: Use pnpm 8.8.0
uses: pnpm/action-setup@v2
with:
version: 8.8.0

- name: Use Node.js 16.18
uses: actions/setup-node@v3
with:
node-version: 16.18
cache: "pnpm"

- name: Install workerd Dependencies
- name: Install workerd dependencies
if: ${{ runner.os == 'Linux' }}
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install -y libc++1
- name: Install NPM Dependencies

- name: Install NPM dependencies
run: pnpm install --frozen-lockfile

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

- name: Build & Publish Worker
run: pnpm run publish
- name: Build & deploy Worker
run: pnpm run deploy
env:
NODE_ENV: "production"
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,52 @@
name: Playground Preview Worker
name: Deploy Playground Preview Worker (production)

# On a push to `deploy-worker/playground-preview-worker`, on Cloudflare,
# deploy to production.
on:
push:
branches:
- main
paths:
- "packages/playground-preview-worker/**"
- deploy-worker/playground-preview-worker

jobs:
publish_worker:
deploy_worker:
if: ${{ github.repository_owner == 'cloudflare' }}
name: Publish Worker
name: Deploy Playground Preview Worker (production)
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2

- name: Use pnpm 8.8.0
uses: pnpm/action-setup@v2
with:
version: 8.8.0

- name: Use Node.js 16.18
uses: actions/setup-node@v3
with:
node-version: 16.18
cache: "pnpm"

- name: Install workerd Dependencies
- name: Install workerd dependencies
if: ${{ runner.os == 'Linux' }}
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install -y libc++1

- name: Install NPM Dependencies
- name: Install NPM dependencies
run: pnpm install --frozen-lockfile

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

- name: Build & Publish Worker
- name: Build & deploy Worker
run: pnpm run deploy
env:
NODE_ENV: "production"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,66 @@
name: Playground Worker tests
name: Deploy Playground Preview Worker (testing)

# On a push to `main`, on Cloudflare, where there are changes to the files in this worker's package,
# or an update to a PR, on Cloudflare, labelled as `playground-worker`,
# deploy to testing and then run the end-to-end tests against this deployment.
on:
push:
branches:
- main
- changeset-release/main
paths:
- "packages/playground-preview-worker/**"

pull_request:
types: [synchronize, opened, reopened, labeled, unlabeled]
repository_dispatch:

jobs:
e2e-test:
if: github.repository_owner == 'cloudflare' && (github.event_name != 'pull_request' || (github.event_name == 'pull_request' && contains(github.event.*.labels.*.name, 'playground-worker' )) || (github.event_name == 'pull_request' && github.head_ref == 'changeset-release/main'))
name: "Playground Worker Test"
if: github.repository_owner == 'cloudflare' && (github.event_name != 'pull_request' || contains(github.event.*.labels.*.name, 'playground-worker'))
name: "Deploy Playground Preview Worker (testing)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The triggering based on a label should probably be removed in favour of the path-based triggering above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was wondering about that. Here is where I landed:

Since the playground preview tests all share the same deployed testing environment Worker I think it is safer to restrict this to labeled PRs to avoid collisions - it always runs on pushes to main anyway.

runs-on: ubuntu-latest

steps:
- name: Checkout Repo
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2

- name: Use pnpm 8.8.0
uses: pnpm/action-setup@v2
with:
version: 8.8.0
- name: Use Node.js 18

- name: Use Node.js 16.18
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 16.18
cache: "pnpm"

- name: Install workerd Dependencies
- name: Install workerd dependencies
if: ${{ runner.os == 'Linux' }}
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install -y libc++1

- name: Install NPM Dependencies
- name: Install NPM dependencies
run: pnpm install --frozen-lockfile

- name: Run builds
- name: Build tools and libraries
run: pnpm run build
env:
NODE_ENV: "production"
CI_OS: ${{ runner.os }}

- name: Build & Publish Testing Playground Worker
- name: Build & deploy Worker
run: pnpm run deploy:testing
env:
NODE_ENV: "production"
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
working-directory: packages/playground-preview-worker

- name: Run tests & collect coverage
run: pnpm run test:ci
run: pnpm run test:e2e
env:
TMP_CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
TMP_CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
Expand Down
2 changes: 1 addition & 1 deletion packages/edge-preview-authenticated-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"check:lint": "eslint .",
"publish": "wrangler deploy",
"deploy": "wrangler deploy",
"start": "wrangler dev",
"test": "vitest run",
"type:tests": "tsc -p ./tests/tsconfig.json",
Expand Down
2 changes: 1 addition & 1 deletion packages/format-errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"check:lint": "eslint .",
"publish": "wrangler deploy",
"deploy": "wrangler deploy",
"build": "wrangler build",
"start": "wrangler dev"
},
Expand Down
3 changes: 1 addition & 2 deletions packages/playground-preview-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"deploy": "wrangler -j deploy",
"deploy:testing": "wrangler -j deploy -e testing",
"start": "wrangler -j dev",
"test": "vitest run",
"test:ci": "vitest run"
"test:e2e": "vitest run"
},
"dependencies": {
"hono": "^3.3.2",
Expand Down
9 changes: 1 addition & 8 deletions packages/playground-preview-worker/tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { fetch } from "undici";
import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest";

function removeUUID(str: string) {
return str.replace(
/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/g,
"00000000-0000-0000-0000-000000000000"
);
}
import { beforeAll, describe, expect, it } from "vitest";

const REMOTE = "https://playground-testing.devprod.cloudflare.dev";
const PREVIEW_REMOTE =
Expand Down
Loading