Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit 771ce75

Browse files
CI/CD Improvements (#170)
* CI/CD Improvements: - Added Changeset PR creation & publish Workflows - Added Typechecking workflow - Consolidated old workflows as jobs in new workflows removed build from Testing CI/CD * Workflow changes made to match known Wrangler2 CI/CD changes that are working for Changesets and triggering events * Updates to the workflow from improvements and things learned from Wrangler2 GH Actions * PR review fixups * Prettier replace of markdownlint - Markdownlint required a global or NPX implementation in CI - Prettier configs tweaked to minimize changes to Markdown docs * Prettier ran locally to confirm changes and configuration * changes per PR discussion moving linting/prettier to same job * Update package.json Co-authored-by: Sunil Pai <[email protected]> * removed the ignore from prettier command, added .vscode settings for recs and formatter default, updated gitignore * update autogenerated changeset settings Co-authored-by: Sunil Pai <[email protected]>
1 parent f4f7e09 commit 771ce75

29 files changed

+5319
-326
lines changed

.changeset/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": [
4+
"@changesets/changelog-github",
5+
{ "repo": "cloudflare/workers-types" }
6+
],
7+
"commit": false,
8+
"linked": [],
9+
"access": "public",
10+
"baseBranch": "master",
11+
"updateInternalDependencies": "patch",
12+
"ignore": []
13+
}

.changeset/proud-ways-argue.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@cloudflare/workers-types": patch
3+
---
4+
5+
CI/CD Improvements:
6+
7+
- Added Changeset PR creation & publish Workflows
8+
- Added Typechecking workflow
9+
- Consolidated old workflows as jobs in new workflows
10+
- Added configuration for Changeset CLI
11+
- Installing Changeset bot for non-blocking PR support

.github/workflows/lint.yml

-15
This file was deleted.

.github/workflows/overrides.yml

-18
This file was deleted.

.github/workflows/release.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
if: ${{ github.repository_owner == 'cloudflare' }}
11+
name: Release
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Repo
15+
uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Setup Node.js 16.7
20+
uses: actions/setup-node@v2
21+
with:
22+
node-version: 16.7
23+
24+
- uses: actions/cache@v2
25+
id: node-modules-cache
26+
with:
27+
path: |
28+
node_modules
29+
*/*/node_modules
30+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
31+
32+
- name: Install NPM
33+
run: npm install
34+
35+
- name: Check Docs
36+
run: npm run export:docs
37+
- name: Check Overrides
38+
run: npm run export:overrides
39+
40+
- name: Run Prettier
41+
run: npm run prettier:check
42+
43+
- name: Run Type Checking
44+
run: tsc
45+
46+
- name: Create Version PR or Publish to NPM
47+
id: changesets
48+
uses: changesets/action@v1
49+
with:
50+
publish: npx changeset publish --tag beta
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

.github/workflows/typechecks.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Tests, Linter & Typecheck
2+
3+
on: pull_request
4+
5+
jobs:
6+
test:
7+
name: "Typechecking"
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
13+
- name: Use Node.js 16.7
14+
uses: actions/setup-node@v2
15+
with:
16+
node-version: 16.7
17+
18+
- name: Install NPM dependencies
19+
run: npm install
20+
21+
- uses: actions/cache@v2
22+
id: node-modules-cache
23+
with:
24+
path: |
25+
node_modules
26+
*/*/node_modules
27+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
28+
29+
- name: Run Prettier
30+
run: npm run prettier:check
31+
32+
- name: Run Type Checking
33+
run: tsc

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.DS_Store
2-
.vscode
32
node_modules
43
docs.json
54
overrides.json

.prettierrc

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"printWidth": 120,
3-
"proseWrap": "always"
2+
"proseWrap": "preserve"
43
}

.vscode/extensions.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["esbenp.prettier-vscode"]
3+
}

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode"
3+
}

CHANGELOG.md

+14-12
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
## 3.2.0
1212

13-
- **Add 'error' WebSocket event types overrides [@bretthoerner], [pull/143] & [pull/150]**
13+
- **Add 'error' WebSocket event types overrides [@bretthoerner], [pull/143] & [pull/150]**
1414
- **Add PagesFunction type [@GregBrimble], [pull/154]**
1515
- **Updated types for 2021.11.400 [@autodecl-bot], [pull/145]**
1616
- **Updated types for 2021.11.700 [@autodecl-bot], [pull/149]**
@@ -76,25 +76,25 @@
7676

7777
- **Add AVIF Format for Image Resizing - [@GregBrimble], [pull/59]**
7878

79-
[@GregBrimble]: https://github.com/GregBrimble
79+
[@gregbrimble]: https://github.com/GregBrimble
8080
[pull/59]: https://github.com/cloudflare/workers-types/pull/59
8181

8282
- **Add metadata typings for KV - [@GregBrimble], [pull/54]**
8383
Adds the [new metadata](https://developers.cloudflare.com/workers/runtime-apis/kv#metadata) types to the getWithMetadata, put and list methods on a KV namespace.
8484

85-
[@GregBrimble]: https://github.com/GregBrimble
85+
[@gregbrimble]: https://github.com/GregBrimble
8686
[pull/54]: https://github.com/cloudflare/workers-types/pull/54
8787

8888
- **Complete Image Resizing properties - [@GregBrimble], [pull/50]**
8989
Adds missing options for the Image Resizing API.
9090

91-
[@GregBrimble]: https://github.com/GregBrimble
91+
[@gregbrimble]: https://github.com/GregBrimble
9292
[pull/50]: https://github.com/cloudflare/workers-types/pull/50
9393

9494
- **Add API for async handlers and end handler - [@ObsidianMinor], [pull/48]**
9595
Types for [HTML Rewriter](https://developers.cloudflare.com/workers/runtime-apis/html-rewriter#end) end of document append method
9696

97-
[@ObsidianMinor]: https://github.com/ObsidianMinor
97+
[@obsidianminor]: https://github.com/ObsidianMinor
9898
[pull/48]: https://github.com/cloudflare/workers-types/pull/48
9999

100100
### Bugfixes
@@ -153,7 +153,7 @@
153153
Remove this from your code:
154154
155155
```typescript
156-
import {} from '@cloudflare/workers-types'
156+
import {} from "@cloudflare/workers-types";
157157
```
158158
159159
And instead include the types explicitly in your TypeScript configuration compiler options:
@@ -178,10 +178,12 @@
178178
179179
```typescript
180180
// Force response to be cached for 300 seconds.
181-
fetch(event.request, { cf: { cacheTtl: 300 } })
181+
fetch(event.request, { cf: { cacheTtl: 300 } });
182182

183183
// Force response to be cached for 86400 seconds for 200 status codes, 1 second for 404, and do not cache 500 errors
184-
fetch(request, { cf: { cacheTtlByStatus: { '200-299': 86400, '404': 1, '500-599': 0 } } })
184+
fetch(request, {
185+
cf: { cacheTtlByStatus: { "200-299": 86400, "404": 1, "500-599": 0 } },
186+
});
185187
```
186188
187189
Read more about these properties in the [`Request` docs](https://developers.cloudflare.com/workers/reference/apis/request/).
@@ -195,7 +197,7 @@
195197
The Workers runtime exposes a default global cache as `caches.default`, accessed like:
196198
197199
```typescript
198-
let cache = caches.default
200+
let cache = caches.default;
199201
```
200202
201203
This is an extension to the [Service Workers spec for `CacheStorage`](https://w3c.github.io/ServiceWorker/#cachestorage), and thus needed to be added explicitly to our type definitions.
@@ -238,7 +240,7 @@
238240
Previously, this pattern wasn't allowed:
239241
240242
```typescript
241-
new Request(parsedUrl.toString(), request)
243+
new Request(parsedUrl.toString(), request);
242244
```
243245
244246
This is because the `cf` object on inbound Request objects, and that expected in the `init` dictionary arg to the Request constructor, have a different shape.
@@ -247,7 +249,7 @@
247249
248250
```typescript
249251
interface RequestInit {
250-
cf?: RequestInitCfProperties | IncomingRequestCfProperties
252+
cf?: RequestInitCfProperties | IncomingRequestCfProperties;
251253
}
252254
```
253255
@@ -291,7 +293,7 @@
291293
Previously, the `KVNamespace` interface required that callers provide an empty options object when listing all the keys in a namespace, like so:
292294
293295
```typescript
294-
await NAMESPACE.list({})
296+
await NAMESPACE.list({});
295297
```
296298
297299
However, this argument is not actually required. This change updates the interface to match the runtime.

docs/kv.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ Returns a `Promise` that you should `await` on in order to verify a successful u
2121
#### Examples
2222

2323
```js
24-
await NAMESPACE.put(key, value)
24+
await NAMESPACE.put(key, value);
2525
```

export/docs.ts

+18-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ interface CommentedDeclaration {
1919

2020
// Get files to build docs from
2121
const docsDir = path.join(__dirname, "..", "docs");
22-
const filePaths = fs.readdirSync(docsDir).map((fileName) => path.join(docsDir, fileName));
22+
const filePaths = fs
23+
.readdirSync(docsDir)
24+
.map((fileName) => path.join(docsDir, fileName));
2325

2426
// Maps fenced code-block languages to those recognised by declaration renderers
2527
const exampleLangRenames = {
@@ -33,7 +35,10 @@ function trimComment(comment?: Comment) {
3335
if (comment === undefined) return;
3436
comment.text = comment.text.trim();
3537
if (comment.params) {
36-
comment.params = comment.params.map(({ name, text }) => ({ name, text: text.trim() }));
38+
comment.params = comment.params.map(({ name, text }) => ({
39+
name,
40+
text: text.trim(),
41+
}));
3742
}
3843
if (comment.returns) {
3944
comment.returns = comment.returns.trim();
@@ -94,7 +99,12 @@ for (const filePath of filePaths) {
9499
// New field
95100
pushField();
96101
// token.text === "`Declaration.field`" or "`Declaration#field`"
97-
field = { name: token.text.substring(1 + declaration.name.length + 1, token.text.length - 1) };
102+
field = {
103+
name: token.text.substring(
104+
1 + declaration.name.length + 1,
105+
token.text.length - 1
106+
),
107+
};
98108
continue;
99109
}
100110

@@ -106,7 +116,11 @@ for (const filePath of filePaths) {
106116
}
107117
}
108118

109-
if (field && fieldState === FieldState.Parameters && token.type === "list") {
119+
if (
120+
field &&
121+
fieldState === FieldState.Parameters &&
122+
token.type === "list"
123+
) {
110124
// Field parameters
111125
field.comment ??= { text: "" };
112126
field.comment.params ??= [];

0 commit comments

Comments
 (0)