Skip to content

Commit

Permalink
Merge pull request #27 from yxx4c/feat/cacheContext
Browse files Browse the repository at this point in the history
Feat/cache context
  • Loading branch information
yxx4c authored Dec 2, 2024
2 parents d7f9419 + 96c0bdd commit 58f9db0
Show file tree
Hide file tree
Showing 30 changed files with 1,875 additions and 203 deletions.
133 changes: 133 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: CI/CD Pipeline

on:
push:
branches:
- main

permissions:
contents: write
issues: write
pull-requests: write

jobs:
install_dependencies:
name: Install Project Dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set Up Bun Package Manager
uses: oven-sh/setup-bun@v2

- name: Install Project Dependencies
run: bun install

- name: Cache Node Modules
uses: actions/cache@v3
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-node-modules-
build_library:
name: Build Project Library
runs-on: ubuntu-latest
needs: install_dependencies
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set Up Bun Package Manager
uses: oven-sh/setup-bun@v2

- name: Cache Node Modules
uses: actions/cache@v3
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Cache Build Output Directory
uses: actions/cache@v3
with:
path: |
dist
key: ${{ runner.os }}-dist-${{ github.sha }}
restore-keys: |
${{ runner.os }}-dist-
- name: Build the Project
run: bun run build

run_tests:
name: Execute Test Suite
runs-on: ubuntu-latest
needs: build_library
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set Up Bun Package Manager
uses: oven-sh/setup-bun@v2

- name: Cache Node Modules
uses: actions/cache@v3
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Cache Build Output Directory
uses: actions/cache@v3
with:
path: |
dist
key: ${{ runner.os }}-dist-${{ github.sha }}
restore-keys: |
${{ runner.os }}-dist-
- name: Install Dependencies for Example Project
run: |
cd example
rm -rf node_modules
bun install
- name: Generate Prisma Client
run: |
cd example
bunx prisma generate
- name: Run Test Suite
env:
REDIS_SERVICE_URI: ${{ secrets.REDIS_SERVICE_URI }}
POSTGRES_SERVICE_URI: ${{ secrets.POSTGRES_SERVICE_URI }}
run: bun test

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

# publish_to_npm:
# name: Publish Package to NPM
# runs-on: ubuntu-latest
# needs: run_tests
# steps:
# - name: Checkout Repository
# uses: actions/checkout@v4

# - name: Set Up Bun Package Manager
# uses: oven-sh/setup-bun@v2

# - name: Publish Package to NPM
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
# run: bun publish
56 changes: 56 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: test

on: push

jobs:
test:
name: test
runs-on: ubuntu-latest
services:
dragonfly:
image: "docker.dragonflydb.io/dragonflydb/dragonfly"
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 3
volumes:
- dragonfly:/data
postgres:
image: postgres:alpine
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U user"
--health-interval 10s
--health-timeout 5s
--health-retries 3
env:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: testdb
volumes:
- postgres:/var/lib/postgresql/data

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set Up Bun Package Manager
uses: oven-sh/setup-bun@v2

- name: Install Project Dependencies
run: bun install

- name: Run Test Suite
env:
REDIS_SERVICE_URI: redis://localhost:6379
POSTGRES_SERVICE_URI: postgres://user:password@localhost:5432/testdb
run: bun run test

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.env
coverage
dist
node_modules
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

# Prisma Extension Redis

[![test](https://github.com/yxx4c/prisma-extension-redis/actions/workflows/test.yml/badge.svg)](https://github.com/yxx4c/prisma-extension-redis/actions/workflows/test.yml)
[![codecov](https://codecov.io/github/yxx4c/prisma-extension-redis/graph/badge.svg?token=G7O92H6I7T)](https://codecov.io/github/yxx4c/prisma-extension-redis)
![NPM License](https://img.shields.io/npm/l/prisma-extension-redis)
![NPM Version](https://img.shields.io/npm/v/prisma-extension-redis)
![NPM Downloads](https://img.shields.io/npm/dw/prisma-extension-redis)
Expand Down
36 changes: 36 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

# Security Policy for prisma-extension-redis

## Reporting a Vulnerability

If a security vulnerability is discovered in `prisma-extension-redis`, please report it responsibly. Your assistance in keeping this project secure is greatly appreciated.

To report a vulnerability, please follow these steps:

1. **Do not disclose the vulnerability publicly** until it has been addressed.
2. **Email the maintainer** at mail.yxx4c+security@gmail.com with the following information:
- A description of the vulnerability
- Steps to reproduce the issue
- Any relevant code snippets or configurations

Reports will be acknowledged as soon as possible, typically within a few days, depending on the complexity of the issue.

## Supported Versions

The latest version of `prisma-extension-redis` is currently supported. Users are encouraged to use the most recent version to benefit from any security updates.

## Security Best Practices

To enhance the security of applications using `prisma-extension-redis`, consider the following best practices:

1. **Keep Dependencies Updated**: Regularly check for updates to `prisma-extension-redis` and its dependencies.
2. **Use Environment Variables**: Store sensitive information, such as Redis connection strings and credentials, in environment variables instead of hardcoding them in the application.
3. **Limit Redis Access**: Configure the Redis instance to allow access only from trusted sources.
4. **Monitor Logs**: Regularly review application logs for any unusual activity.

## Additional Resources

- [OWASP Top Ten](https://owasp.org/www-project-top-ten/) - A list of the top ten security risks for web applications.
- [Redis Security](https://redis.io/topics/security) - Best practices for securing Redis instances.

Thank you for helping to keep `prisma-extension-redis` secure!
Binary file modified bun.lockb
Binary file not shown.
4 changes: 4 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[test]

coverage = true
coverageReporter = ["text", "lcov"]
2 changes: 0 additions & 2 deletions example/.env

This file was deleted.

49 changes: 40 additions & 9 deletions example/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: prisma
services:
dragonfly:
image: 'docker.dragonflydb.io/dragonflydb/dragonfly'
image: "docker.dragonflydb.io/dragonflydb/dragonfly"
hostname: dragonfly
container_name: dragonfly
restart: always
Expand All @@ -10,19 +10,19 @@ services:
ulimits:
memlock: -1
ports:
- '6379:6379'
- "6379:6379"
volumes:
- dragonfly:/data
command:
[
'--default_lua_flags',
'allow-undeclared-keys',
'--cluster_mode',
'emulated',
'--lock_on_hashtags',
"--default_lua_flags",
"allow-undeclared-keys",
"--cluster_mode",
"emulated",
"--lock_on_hashtags",
]
insight:
image: 'redis/redisinsight'
image: "redis/redisinsight"
hostname: insight
container_name: insight
restart: always
Expand All @@ -31,9 +31,40 @@ services:
ulimits:
memlock: -1
ports:
- '5540:5540'
- "5540:5540"
volumes:
- insight:/data
postgres:
image: postgres:alpine
hostname: postgres
container_name: postgres
restart: always
mem_limit: 512m
cpus: 1
ulimits:
memlock: -1
ports:
- "5432:5432"
volumes:
- postgres:/var/lib/postgresql/data
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: testdb
# To disable the simulation of network latency, comment out the code below.
latency:
image: alpine:latest
container_name: latency
cap_add:
- NET_ADMIN
command: >
sh -c 'apk add --no-cache iproute2 &&
tc qdisc add dev eth0 root netem delay 100ms &&
sleep 3600' # Keep the container running
network_mode: "service:postgres"
depends_on:
- postgres
volumes:
dragonfly:
insight:
postgres:
Loading

0 comments on commit 58f9db0

Please sign in to comment.