Skip to content

Commit

Permalink
fix: Add Github Actions and fix type errors(#18)
Browse files Browse the repository at this point in the history
History of this squashed commit:
* Fix a test and type error

* Add github action tests

* Pass test in both node 18 and 20

* Remove some unused imports

* Add typecheck and build to CI

* Mute some type errors

* chore: fix type issues found after upgrading dependencies, see: cloudflare/workerd#1298

* Remove ts-nocheck

* Still disable threads for vitest to fix timeouts

* fix: simplify manifest upload by copying into a text

Locally in unit tests manifest upload could hang sometimes.

* Remove `threads: false` in vitest config

* Set pool to forks in vitest config

* Avoid pool option and avoid pining node types

---------

Co-authored-by: Gabi Villalonga Simon <gvillalongasimon@cloudflare.com>
Co-authored-by: Gabriel Villalonga Simón <gabitriqui@gmail.com>
  • Loading branch information
3 people committed Mar 4, 2024
1 parent b74093a commit 81a7219
Show file tree
Hide file tree
Showing 14 changed files with 2,745 additions and 410 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test

on:
push:
pull_request:

jobs:
test:
name: Unit Tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- run: npm ci
- run: npm run typecheck
- run: npm test
5 changes: 2 additions & 3 deletions index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { afterAll, afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import { afterAll, beforeEach, describe, expect, test } from "vitest";
import { SHA256_PREFIX_LEN, getSHA256 } from "./src/user";
import v2Router, { TagsList } from "./src/router";
import { Env } from ".";
Expand Down Expand Up @@ -269,8 +269,7 @@ test("registries configuration", async () => {
{
configuration: "bla bla bla no json",
expected: [],
error:
"Error parsing registries JSON: error SyntaxError: Unexpected token b in JSON at position 0: undefined: SyntaxError: Unexpected token b in JSON at position 0\n",
error: "Error parsing registries JSON: error SyntaxError: Unexpected token",
partialError: true,
},
{
Expand Down
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ router.all("/v2/*", v2Router.handle);
router.all("*", () => new Response("Not Found.", { status: 404 }));

export default {
async fetch(request: Request, env: Env, context: ExecutionContext) {
async fetch(request: Request, env: Env, context?: ExecutionContext) {
if (!ensureConfig(env)) {
return new AuthErrorResponse(request);
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"wrangler": "^3.29.0"
},
"engines": {
"node": ">=16.13"
"node": ">=18"
},
"author": "",
"license": "Apache-2.0"
Expand Down
Loading

0 comments on commit 81a7219

Please sign in to comment.