Skip to content

Commit

Permalink
feat: rewrite Wrangler Action in TypeScript
Browse files Browse the repository at this point in the history
* Removes dependencies such as Docker, decreasing spin-up time
* Adds community-requested features, including bulk secrets API utilization from Wrangler
* Fixes CI/CD
* Adds testing
* Improves command implementation
* Begins using Node for the Action engine/runner
* Openly discusses all changes with the community
  GitHub Discussions opened and Issues monitored

BREAKING CHANGES:
* Docker is no longer a dependency
* Wrangler v1 is no longer supported

Additional related Internal tickets:
Major Version Default: https://jira.cfdata.org/browse/DEVX-632
Rewrite Project: DEVX-804,802,800,632
  • Loading branch information
JacobMGEvans committed Aug 4, 2023
1 parent 4c10c18 commit ff04a40
Show file tree
Hide file tree
Showing 29 changed files with 5,140 additions and 411 deletions.
159 changes: 89 additions & 70 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,91 +1,110 @@
on: push
name: Wrangler Action Self Testing
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
wrangler_action_self_testing:
runs-on: ubuntu-latest
name: Lint
steps:
- uses: actions/checkout@v2
- name: Lint shell script
uses: azohra/[email protected]
with:
path: "entrypoint.sh"
build-only:
runs-on: ubuntu-latest
name: Only build the app
steps:
- uses: actions/checkout@v2
- name: Build app
- name: Checkout Repo
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "latest"
cache: "npm"

- name: Install Dependencies
run: npm install

- name: Unit Tests
run: npm run test

- name: Check Formatting
run: npm run check

- name: Build Action
run: npm run build

- name: Only build app
uses: ./
with:
workingDirectory: "./test/base"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: deploy --dry-run

# START Setup and teardown of Worker Environment Tests
- name: Environment support
uses: ./
with:
workingDirectory: "./test/environment"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
workingDirectory: "test"
publish: false
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
environment: dev
secrets: |
SECRET1
SECRET2
preCommands: echo "*** pre commands ***"
postCommands: |
echo "*** post commands ***"
wrangler build
echo "******"
env:
SECRET1: ${{ secrets.SECRET1 }}
SECRET2: ${{ secrets.SECRET2 }}
publish:
runs-on: ubuntu-latest
name: Publish app
steps:
- uses: actions/checkout@v2
- name: Publish app
uses: ./
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
environment: "production"
workingDirectory: 'test'
publish_legacy_credentials:
runs-on: ubuntu-latest
name: Publish app with legacy credentials
steps:
- uses: actions/checkout@v2
- name: Publish app
uses: ./
with:
apiKey: ${{ secrets.CLOUDFLARE_API_KEY }}
email: ${{ secrets.CLOUDFLARE_EMAIL }}
environment: "production"
workingDirectory: 'test'
publish_hardcoded_wrangler_version:
runs-on: ubuntu-latest
name: Publish app with hardcoded Wrangler version
steps:
- uses: actions/checkout@v2
- name: Publish app
uses: ./
with:
apiKey: ${{ secrets.CLOUDFLARE_API_KEY }}
email: ${{ secrets.CLOUDFLARE_EMAIL }}
environment: "production"
wranglerVersion: '1.5.0'
workingDirectory: 'test'
publish_secrets:
runs-on: ubuntu-latest
name: Publish app with secrets
steps:
- uses: actions/checkout@v2
- name: Publish app

- name: Clean up Deployed Environment Worker
uses: ./
with:
workingDirectory: "./test/base"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
environment: "production"
workingDirectory: "test"
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: delete --name wrangler-action-dev-environment-test --force

# END Setup and teardown of Worker Environment Tests
# START Setup and teardown of Workers w/ Secrets Tests
- name: Deploy app secrets w/ hardcoded Wrangler v2
uses: ./
with:
wranglerVersion: "2.20.0"
workingDirectory: "./test/base"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
secrets: |
SECRET1
SECRET2
preCommands: echo "*** pre command ***"
postCommands: |
echo "*** post commands ***"
echo "******"
env:
SECRET1: ${{ secrets.SECRET1 }}
SECRET2: ${{ secrets.SECRET2 }}
SECRET2: ${{ secrets.SECRET2 }}

- name: Health Check Deployed Worker
run: node .github/workflows/workerHealthCheck.cjs
shell: bash

- name: Deploy app secrets w/ default version
uses: ./
with:
workingDirectory: "./test/base"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
secrets: |
SECRET1
SECRET2
env:
SECRET1: ${{ secrets.SECRET1 }}
SECRET2: ${{ secrets.SECRET2 }}

- name: Health Check Deployed Worker
run: node .github/workflows/workerHealthCheck.cjs
shell: bash

- name: Clean Up Deployed Workers
uses: ./
with:
workingDirectory: "./test/base"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: delete --name wrangler-action-test --force
# END Setup and teardown of Workers w/ Secrets Tests
18 changes: 18 additions & 0 deletions .github/workflows/workerHealthCheck.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { execSync } = require("child_process");

function workerHealthCheck() {
const url =
"https://wrangler-action-test.devprod-testing7928.workers.dev/secret-health-check";

const buffer = execSync(`curl ${url}`);

const response = buffer.toString();

response.includes("OK")
? console.log(`Status: Worker is up! Secrets: ${response}`)
: console.log(`Worker is down!`);

return response;
}

workerHealthCheck();
95 changes: 95 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
dist
.idea
.vscode

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Node ###
node_modules
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release


# Moved from ./templates for ignoring all locks in templates
templates/**/*-lock.*
templates/**/*.lock

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 80,
"singleQuote": false,
"semi": true,
"useTabs": true
}
64 changes: 51 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,61 @@
# 2.0.0 (Breaking update)
# Changelog

## Additions
- [Version 3.0.0](#version-300)
- [Version 2.0.0](#version-200)

* New `command` input
* This allows you to specify the Wrangler command you would like to run.
## Version 3.0.0 (Breaking update)

### Additions

- **Rewritten Wrangler Action in TypeScript.**
- Bulk secrets API utilization from Wrangler.
- Added testing for improved reliability.
- Implemented multiline support for the `command` input to allow running multiple Wrangler commands.
- Now using Node for the Action engine/runner.
- Open discussions with the community on all changes through GitHub Discussions and monitored Issues.

### Removals

- Removed Docker as a dependency.
- Dropped support for Wrangler v1.

### Changes

- Fixed CI/CD issues.

### Breaking changes

- Wrangler v1 is no longer supported.
- Please update to the latest version of Wrangler.
- Updated default version of Wrangler to v3.4.0

### Additional Notes

- Major Version Default: [DEVX-632](https://jira.cfdata.org/browse/DEVX-632)
- Rewrite Project Tickets: [DEVX-804](https://jira.cfdata.org/browse/DEVX-804), [DEVX-802](https://jira.cfdata.org/browse/DEVX-802), [DEVX-800](https://jira.cfdata.org/browse/DEVX-800), [DEVX-632](https://jira.cfdata.org/browse/DEVX-632)

---

## Version 2.0.0 (Breaking update)

### Additions

- New `command` input
- This allows you to specify the Wrangler command you would like to run.
For example, if you want to publish the production version of your Worker you may run `publish --env=production`.
* This opens up other possibilities too like publishing a Pages project: `pages publish <directory> --project-name=<name>`.
* New `accountId` input
* This allows you to specify your account ID.
- This opens up other possibilities too like publishing a Pages project: `pages publish <directory> --project-name=<name>`.
- New `accountId` input
- This allows you to specify your account ID.

## Removals
### Removals

* Removed `publish` input (refer to [Breaking changes](#breaking-changes)).
- Removed `publish` input (refer to [Breaking changes](#breaking-changes)).

## Changes
### Changes

-- no changes --

## __Breaking changes__
### Breaking changes

* `publish` has been removed.
* You should instead do `command: publish`.
- `publish` has been removed.
- You should instead do `command:
7 changes: 0 additions & 7 deletions Dockerfile

This file was deleted.

Loading

0 comments on commit ff04a40

Please sign in to comment.