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

CI/CD Improvements #170

Merged
merged 10 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from 9 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
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
10 changes: 10 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"linked": [],
"access": "restricted",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": []
}
11 changes: 11 additions & 0 deletions .changeset/proud-ways-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@cloudflare/workers-types": patch
---

CI/CD Improvements:

- Added Changeset PR creation & publish Workflows
- Added Typechecking workflow
- Consolidated old workflows as jobs in new workflows
- Added configuration for Changeset CLI
- Installing Changeset bot for non-blocking PR support
15 changes: 0 additions & 15 deletions .github/workflows/lint.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/overrides.yml

This file was deleted.

53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release

on:
push:
branches:
- main

jobs:
release:
if: ${{ github.repository_owner == 'cloudflare' }}
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Node.js 16.7
uses: actions/setup-node@v2
with:
node-version: 16.7

- uses: actions/cache@v2
id: node-modules-cache
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

- name: Install NPM
run: npm install

- name: Check Docs
run: npm run export:docs
- name: Check Overrides
run: npm run export:overrides

- name: Run Prettier
run: npm run prettier:check

- name: Run Type Checking
run: tsc

- name: Create Version PR or Publish to NPM
id: changesets
uses: changesets/action@v1
with:
publish: npx changeset publish --tag beta
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/typechecks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Tests, Linter & Typecheck

on: pull_request

jobs:
test:
name: "Typechecking"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Use Node.js 16.7
uses: actions/setup-node@v2
with:
node-version: 16.7

- name: Install NPM dependencies
run: npm install

- uses: actions/cache@v2
id: node-modules-cache
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

- name: Run Prettier
run: npm run prettier:check

- name: Run Type Checking
run: tsc
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.DS_Store
.vscode
node_modules
docs.json
overrides.json
3 changes: 1 addition & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"printWidth": 120,
"proseWrap": "always"
"proseWrap": "preserve"
}
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["esbenp.prettier-vscode"]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
26 changes: 14 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

## 3.2.0

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

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

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

- **Add metadata typings for KV - [@GregBrimble], [pull/54]**
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.

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

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

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

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

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

### Bugfixes
Expand Down Expand Up @@ -153,7 +153,7 @@
Remove this from your code:

```typescript
import {} from '@cloudflare/workers-types'
import {} from "@cloudflare/workers-types";
```

And instead include the types explicitly in your TypeScript configuration compiler options:
Expand All @@ -178,10 +178,12 @@

```typescript
// Force response to be cached for 300 seconds.
fetch(event.request, { cf: { cacheTtl: 300 } })
fetch(event.request, { cf: { cacheTtl: 300 } });

// Force response to be cached for 86400 seconds for 200 status codes, 1 second for 404, and do not cache 500 errors
fetch(request, { cf: { cacheTtlByStatus: { '200-299': 86400, '404': 1, '500-599': 0 } } })
fetch(request, {
cf: { cacheTtlByStatus: { "200-299": 86400, "404": 1, "500-599": 0 } },
});
```

Read more about these properties in the [`Request` docs](https://developers.cloudflare.com/workers/reference/apis/request/).
Expand All @@ -195,7 +197,7 @@
The Workers runtime exposes a default global cache as `caches.default`, accessed like:

```typescript
let cache = caches.default
let cache = caches.default;
```

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.
Expand Down Expand Up @@ -238,7 +240,7 @@
Previously, this pattern wasn't allowed:

```typescript
new Request(parsedUrl.toString(), request)
new Request(parsedUrl.toString(), request);
```

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.
Expand All @@ -247,7 +249,7 @@

```typescript
interface RequestInit {
cf?: RequestInitCfProperties | IncomingRequestCfProperties
cf?: RequestInitCfProperties | IncomingRequestCfProperties;
}
```

Expand Down Expand Up @@ -291,7 +293,7 @@
Previously, the `KVNamespace` interface required that callers provide an empty options object when listing all the keys in a namespace, like so:

```typescript
await NAMESPACE.list({})
await NAMESPACE.list({});
```

However, this argument is not actually required. This change updates the interface to match the runtime.
Expand Down
2 changes: 1 addition & 1 deletion docs/kv.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Returns a `Promise` that you should `await` on in order to verify a successful u
#### Examples

```js
await NAMESPACE.put(key, value)
await NAMESPACE.put(key, value);
```
22 changes: 18 additions & 4 deletions export/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ interface CommentedDeclaration {

// Get files to build docs from
const docsDir = path.join(__dirname, "..", "docs");
const filePaths = fs.readdirSync(docsDir).map((fileName) => path.join(docsDir, fileName));
const filePaths = fs
.readdirSync(docsDir)
.map((fileName) => path.join(docsDir, fileName));

// Maps fenced code-block languages to those recognised by declaration renderers
const exampleLangRenames = {
Expand All @@ -33,7 +35,10 @@ function trimComment(comment?: Comment) {
if (comment === undefined) return;
comment.text = comment.text.trim();
if (comment.params) {
comment.params = comment.params.map(({ name, text }) => ({ name, text: text.trim() }));
comment.params = comment.params.map(({ name, text }) => ({
name,
text: text.trim(),
}));
}
if (comment.returns) {
comment.returns = comment.returns.trim();
Expand Down Expand Up @@ -94,7 +99,12 @@ for (const filePath of filePaths) {
// New field
pushField();
// token.text === "`Declaration.field`" or "`Declaration#field`"
field = { name: token.text.substring(1 + declaration.name.length + 1, token.text.length - 1) };
field = {
name: token.text.substring(
1 + declaration.name.length + 1,
token.text.length - 1
),
};
continue;
}

Expand All @@ -106,7 +116,11 @@ for (const filePath of filePaths) {
}
}

if (field && fieldState === FieldState.Parameters && token.type === "list") {
if (
field &&
fieldState === FieldState.Parameters &&
token.type === "list"
) {
// Field parameters
field.comment ??= { text: "" };
field.comment.params ??= [];
Expand Down
Loading