From 146f1ac215a14e702d213181547aefa24d5f554e Mon Sep 17 00:00:00 2001 From: Joel Lefkowitz Date: Thu, 27 Jun 2024 14:26:58 +0100 Subject: [PATCH] Add CI test containers --- .github/PULL_REQUEST_TEMPLATE.md | 5 ---- .github/workflows/docs.yml | 2 +- .github/workflows/publish.yml | 2 +- .github/workflows/review.yml | 11 ++++++-- .husky/pre-commit | 4 +-- .trufflehog3.yml | 1 + README.md | 44 +++++++++++++++----------------- tsconfig.json | 3 ++- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 9aeb722..6453dd1 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,8 +1,3 @@ ---- -name: "Pull Request" -about: Open a pull request ---- - # Pull Request ## Description diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 891bb61..bb2dd38 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,7 +23,7 @@ jobs: uses: actions/configure-pages@v4 - name: Build the docs - run: npm run docs + run: yarn docs - name: Upload the artifacts uses: actions/upload-pages-artifact@v3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ecd4153..564dbd6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,7 +16,7 @@ jobs: uses: ./.github/actions/install - name: Build the package - run: npm run build + run: yarn build - name: Publish the package uses: JS-DevTools/npm-publish@v1 diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml index 41902dc..7f8ebf1 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -13,10 +13,17 @@ jobs: uses: ./.github/actions/install - name: Run linters - run: npm run lint + run: yarn lint - name: Run tests - run: npm run test + run: | + docker run --rm -d -p 5432:5432 -e POSTGRES_DB=db -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password postgres:13 + docker run --rm -d -p 11211:11211 memcached:1.6.9 + yarn prisma generate + yarn prisma migrate dev --schema ./test/prisma/schema.prisma + yarn test + env: + DATABASE_URL: postgresql://user:password@localhost:5432/db - name: Publish test coverage uses: codacy/codacy-coverage-reporter-action@v1 diff --git a/.husky/pre-commit b/.husky/pre-commit index ab4c119..7607676 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,2 +1,2 @@ -npm run lint -npm run test +yarn lint +yarn test diff --git a/.trufflehog3.yml b/.trufflehog3.yml index d15fcc1..72d3bad 100644 --- a/.trufflehog3.yml +++ b/.trufflehog3.yml @@ -18,6 +18,7 @@ exclude: - message: Tooling outputs paths: + - coverage - docs/dist - package-lock.json - yarn-error.log diff --git a/README.md b/README.md index d211774..9944c0c 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ model User { ``` Create a database. In this example we create a postgres container. You can -switch db, user and password for your environment. +switch the db, user and password for your environment. ```bash docker run --rm -d \ @@ -177,13 +177,19 @@ After any of the following state mutating methods we flush the cache: - updateMany - upsert -## Running locally +## Tooling + +### Dependencies + +To install dependencies: ```bash -git clone https://github.com/joellefkowitz/cached-prisma.git +yarn install ``` -To start up a postgres and memcached container: +### Tests + +To run tests: ```bash docker run --rm -d \ @@ -193,29 +199,19 @@ docker run --rm -d \ -e POSTGRES_PASSWORD=password \ postgres:13 -docker run -d --rm -p 11211:11211 memcached:1.6.9 -``` - -```bash -npx prisma migrate dev --schema ./test/prisma/schema.prisma +docker run --rm -d \ + -p 11211:11211 \ + memcached:1.6.9 ``` -## Tooling - -### Dependencies - -To install dependencies: - ```bash -yarn install +export DATABASE_URL=postgresql://user:password@localhost:5432/db +yarn prisma generate +yarn prisma migrate dev --schema ./test/prisma/schema.prisma ``` -### Tests - -To run tests: - ```bash -npm run test +yarn test ``` ### Documentation @@ -223,7 +219,7 @@ npm run test To generate the documentation locally: ```bash -npm run docs +yarn docs ``` ### Linters @@ -231,7 +227,7 @@ npm run docs To run linters: ```bash -npm run lint +yarn lint ``` ### Formatters @@ -239,7 +235,7 @@ npm run lint To run formatters: ```bash -npm run format +yarn format ``` ## Contributing diff --git a/tsconfig.json b/tsconfig.json index 9e6472e..50b3bcd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,11 +20,12 @@ "outDir": "dist", "module": "CommonJS", "moduleResolution": "node", + "target": "ES5", "resolveJsonModule": true, "declaration": true, "importHelpers": false, "removeComments": true, - "sourceMap": true, + "sourceMap": false, "allowJs": false, "esModuleInterop": true, "forceConsistentCasingInFileNames": true,