Skip to content

Commit 342e8e5

Browse files
authored
Merge pull request #392 from SageSeekerSociety/dev
Release: 0.10.0
2 parents 9347b14 + 69962eb commit 342e8e5

261 files changed

Lines changed: 43706 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/devcontainer.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"dockerComposeFile": ["../docker-compose.yml", "../docker-compose.dev.yml"],
3+
"service": "backend",
4+
"workspaceFolder": "/app",
5+
"shutdownAction": "stopCompose",
6+
"customizations": {
7+
"vscode": {
8+
"extensions": [
9+
"ajmnz.prisma-import",
10+
"donjayamanne.git-extension-pack",
11+
"AndrewButson.vscode-openapi-viewer"
12+
]
13+
}
14+
},
15+
"features": {
16+
"ghcr.io/devcontainers/features/common-utils:2": {
17+
"installZsh": true,
18+
"configureZshAsDefaultShell": true,
19+
"installOhMyZsh": true,
20+
"installOhMyZshConfig": true
21+
}
22+
},
23+
"postCreateCommand": "bash .devcontainer/setup.sh"
24+
}

.devcontainer/setup.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -e
3+
4+
pnpm prisma migrate deploy
5+
6+
# put customize content in customize.sh, which won't
7+
# be tracked by git
8+
# remember to grant execute permission to the script
9+
customize_file=".devcontainer/customize.sh"
10+
if [ -f "$customize_file" ]; then
11+
echo "executing $customize_file"
12+
bash "$customize_file"
13+
echo "done"
14+
else
15+
echo "no customize file found, done"
16+
fi

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* text eol=lf
2+
src/materials/resources/* binary
3+
src/avatars/resources/* binary
4+
test/resources/* binary

.github/dependabot.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: 'docker'
4+
directory: '/'
5+
schedule:
6+
interval: 'weekly'
7+
8+
- package-ecosystem: 'npm'
9+
directory: '/'
10+
schedule:
11+
interval: 'weekly'
12+
13+
- package-ecosystem: 'github-actions'
14+
directory: '/'
15+
schedule:
16+
interval: 'weekly'
17+
18+
- package-ecosystem: 'devcontainers'
19+
directory: '/'
20+
schedule:
21+
interval: 'weekly'
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build and Push Product Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
workflow_dispatch:
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: SageSeekerSociety/cheese-backend
13+
14+
jobs:
15+
build-and-push-image:
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
contents: read
20+
packages: write
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Login to docker registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Docker meta
34+
id: meta
35+
uses: docker/metadata-action@v5
36+
with:
37+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38+
39+
- name: Set up Docker Buildx
40+
uses: docker/setup-buildx-action@v3
41+
42+
- name: Build and push
43+
uses: docker/build-push-action@v6
44+
with:
45+
context: .
46+
target: prod
47+
push: true
48+
tags: ${{ steps.meta.outputs.tags }}
49+
labels: ${{ steps.meta.outputs.labels }}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Build and Test Dev Docker
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
pull_request:
8+
branches:
9+
- dev
10+
workflow_dispatch:
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: SageSeekerSociety/cheese-backend-dev
15+
16+
jobs:
17+
build-and-push-image:
18+
runs-on: ubuntu-latest
19+
20+
permissions:
21+
contents: read
22+
packages: write
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Login to docker registry
29+
uses: docker/login-action@v3
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Docker meta
36+
id: meta
37+
uses: docker/metadata-action@v5
38+
with:
39+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
40+
41+
- name: Set up Docker Buildx
42+
uses: docker/setup-buildx-action@v3
43+
44+
- name: Build
45+
uses: docker/build-push-action@v6
46+
with:
47+
context: .
48+
target: dev
49+
push: ${{ github.event_name != 'pull_request' }}
50+
tags: ${{ steps.meta.outputs.tags }}
51+
labels: ${{ steps.meta.outputs.labels }}
52+
cache-from: type=gha
53+
cache-to: type=gha,mode=max
54+
load: true
55+
56+
- name: Create env file
57+
run: cp sample.env .env
58+
59+
- name: set backend image tag
60+
run: echo "BACKEND_DEV_VERSION=${{ steps.meta.outputs.version }}" >> "$GITHUB_ENV"
61+
62+
- name: Start compose
63+
run: docker compose -f docker-compose.yml -f docker-compose.dev.yml up --no-build -d
64+
65+
# See: https://remarkablemark.org/blog/2022/05/12/github-actions-postgresql-increase-max-connections-and-shared-buffers/
66+
# See: https://stackoverflow.com/questions/70673766/how-to-increase-max-connection-in-github-action-postgres
67+
- name: Increase PostgreSQL max_connections
68+
run: |
69+
docker exec -i cheese-backend-database-1 bash << EOF
70+
sed -i -e 's/max_connections = 100/max_connections = 1000/' /var/lib/postgresql/data/postgresql.conf
71+
sed -i -e 's/shared_buffers = 128MB/shared_buffers = 2GB/' /var/lib/postgresql/data/postgresql.conf
72+
EOF
73+
docker restart --time 0 cheese-backend-database-1
74+
75+
- name: Check Schema up to Date
76+
run: |
77+
docker compose exec backend cp prisma/schema.prisma prisma/schema.prisma.origin
78+
docker compose exec backend pnpm build-prisma
79+
docker compose exec backend diff prisma/schema.prisma prisma/schema.prisma.origin
80+
81+
- name: Deploy migrations to Database
82+
run: docker compose exec backend pnpm prisma migrate deploy
83+
84+
- name: Check Prisma Structures Sync With Database
85+
run: |
86+
docker compose exec backend pnpm prisma migrate diff \
87+
--from-schema-datasource prisma/schema.prisma \
88+
--to-schema-datamodel prisma/schema.prisma \
89+
--exit-code
90+
91+
- name: Try to Start Application
92+
run: |
93+
docker compose exec backend bash -c "
94+
pnpm start | tee output &
95+
while true; do
96+
sleep 1
97+
if grep -q \"Nest application successfully started\" output; then
98+
echo \"Detected 'Nest application successfully started'. Stopping pnpm...\"
99+
pid=$(netstat -nlp | grep 3000 | awk '{print $7}' | awk -F'/' '{print $1}')
100+
kill $pid
101+
break
102+
fi
103+
if grep -q \"Command failed\" output; then
104+
echo \"Nest application failed to start.\"
105+
exit -1
106+
fi
107+
done
108+
"
109+
110+
- name: Run Test
111+
run: docker compose exec backend pnpm run test:cov

.github/workflows/code-ql.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
pull_request:
17+
branches: [ "main", "dev" ]
18+
schedule:
19+
- cron: '0 0 * * *'
20+
21+
jobs:
22+
analyze:
23+
name: Analyze
24+
# Runner size impacts CodeQL analysis time. To learn more, please see:
25+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
26+
# - https://gh.io/supported-runners-and-hardware-resources
27+
# - https://gh.io/using-larger-runners
28+
# Consider using larger runners for possible analysis time improvements.
29+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
30+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
31+
permissions:
32+
# required for all workflows
33+
security-events: write
34+
35+
# only required for workflows in private repositories
36+
actions: read
37+
contents: read
38+
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
language: [ 'javascript-typescript' ]
43+
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
44+
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
45+
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
46+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
47+
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
52+
# Initializes the CodeQL tools for scanning.
53+
- name: Initialize CodeQL
54+
uses: github/codeql-action/init@v3
55+
with:
56+
languages: ${{ matrix.language }}
57+
# If you wish to specify custom queries, you can do so here or in a config file.
58+
# By default, queries listed here will override any specified in a config file.
59+
# Prefix the list here with "+" to use these queries and those in the config file.
60+
61+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
62+
# queries: security-extended,security-and-quality
63+
64+
65+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
66+
# If this step fails, then you should remove it and run the build manually (see below)
67+
- name: Autobuild
68+
uses: github/codeql-action/autobuild@v3
69+
70+
# ℹ️ Command-line programs to run using the OS shell.
71+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
72+
73+
# If the Autobuild fails above, remove it and uncomment the following three lines.
74+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
75+
76+
# - run: |
77+
# echo "Run, Build Application using script"
78+
# ./location_of_script_within_repo/buildscript.sh
79+
80+
- name: Perform CodeQL Analysis
81+
uses: github/codeql-action/analyze@v3
82+
with:
83+
category: "/language:${{matrix.language}}"

0 commit comments

Comments
 (0)