-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rewrite Wrangler Action in TypeScript
* 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
1 parent
4c10c18
commit caf6976
Showing
29 changed files
with
5,140 additions
and
411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"printWidth": 80, | ||
"singleQuote": false, | ||
"semi": true, | ||
"useTabs": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.