Skip to content

Commit 33a1285

Browse files
authored
Initialize use_uv
0 parents  commit 33a1285

70 files changed

Lines changed: 9632 additions & 0 deletions

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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Pasted from https://github.com/codersforcauses/automated-setups
2+
3+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
4+
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-outside-of-docker
5+
{
6+
"name": "CFC - Devenv",
7+
// You can get the sha256 here https://github.com/codersforcauses/automated-setups/pkgs/container/cfc-devenv
8+
// Pin it to a specific version to avoid unnecessary breaking changes
9+
"image": "ghcr.io/codersforcauses/cfc-devenv-uv@sha256:1450f1ff8be623b5b1f0e00728381af8efb1182e54ef8bbeaa447c7762abb29f",
10+
11+
"features": {},
12+
13+
// Authenticate with GitHub Container Registry
14+
"remoteEnv": {
15+
"WORKSPACE_FOLDER": "${containerWorkspaceFolder}",
16+
// so we don't have to go looking for it
17+
"UV_CACHE_DIR": "${containerWorkspaceFolder}/.uv-cache"
18+
},
19+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
20+
"forwardPorts": [3000, 8000, 5432],
21+
22+
// Use 'postCreateCommand' to run commands after the container is created.
23+
// Note: Useful for when they open it and want everything to just start
24+
"postCreateCommand": "./.devcontainer/setup.sh"
25+
}

.devcontainer/setup.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
# Runs once after devcontainer is created
4+
5+
figlet "1-time Setup"
6+
echo "Running one-time setup for you :)"
7+
8+
# We can set up in global because this only applies to the entire devcontainer
9+
git config --global --add safe.directory /workspaces/* || true
10+
git config --global --add safe.directory /workspace/* || true
11+
git config --global --add --bool push.autoSetupRemote true
12+
13+
# Create .env files if it doesn't exist
14+
if [ ! -f ./client/.env ]; then
15+
cp ./client/.env.example ./client/.env
16+
fi
17+
if [ ! -f ./server/.env ]; then
18+
cp ./server/.env.example ./server/.env
19+
fi
20+
21+
# Make the Django static folder to remove the annoying warning
22+
(cd server && mkdir -p static)
23+
24+
# Install dependencies
25+
(cd server && uv sync)
26+
(cd client && npm install)
27+
28+
# Nuke and migrate db
29+
(cd server && uv run ./nuke.sh)

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**/.venv
2+
**/.pytest_cache
3+
**/__pycache__
4+
**/node_modules

.env.prod.example

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# FRONTEND
2+
APP_ENV=PRODUCTION
3+
NEXT_PUBLIC_BACKEND_URL="https://xxxx.codersforcauses.org/api"
4+
5+
6+
# BACKEND
7+
APP_NAME=DjangoAPI
8+
API_SECRET_KEY= CHANGE THIS TO A RANDOM STRING
9+
API_ALLOWED_HOSTS=".localhost 127.0.0.1 [::1] .codersforcauses.org"
10+
11+
DJANGO_SUPERUSER_PASSWORD= CHANGE THIS TO A RANDOM STRING
12+
DJANGO_SUPERUSER_EMAIL= CHANGE THIS TO A VALID EMAIL
13+
DJANGO_SUPERUSER_USERNAME= CHANGE THIS TO A VALID USERNAME
14+
15+
FRONTEND_URL="https://xxxx.codersforcauses.org/"

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* text=auto eol=lf
2+
3+
*.png binary
4+
*.jpg binary

.github/workflows/cd-pipeline.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build and Push Docker Images
2+
3+
on:
4+
push:
5+
branches: [use_uv]
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}-${{ github.ref_name }}
10+
11+
jobs:
12+
build-and-push-client:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Log in to Container Registry
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ${{ env.REGISTRY }}
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Build and push client image
33+
uses: docker/build-push-action@v5
34+
with:
35+
context: .
36+
file: ./docker/client/Dockerfile
37+
push: ${{ github.event_name != 'pull_request' }}
38+
tags: |
39+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-prod-client:latest
40+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-prod-client:${{ github.sha }}
41+
cache-from: type=gha
42+
cache-to: type=gha,mode=max
43+
platforms: linux/amd64,linux/arm64
44+
build-args: |
45+
NEXT_PUBLIC_BACKEND_URL=http://localhost:8000
46+
- name: Output client image name
47+
if: github.event_name != 'pull_request'
48+
run: |
49+
echo "Client image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-prod-client:latest"
50+
51+
build-and-push-server:
52+
runs-on: ubuntu-latest
53+
permissions:
54+
contents: read
55+
packages: write
56+
57+
steps:
58+
- name: Checkout repository
59+
uses: actions/checkout@v4
60+
61+
- name: Set up Docker Buildx
62+
uses: docker/setup-buildx-action@v3
63+
64+
- name: Log in to Container Registry
65+
uses: docker/login-action@v3
66+
with:
67+
registry: ${{ env.REGISTRY }}
68+
username: ${{ github.actor }}
69+
password: ${{ secrets.GITHUB_TOKEN }}
70+
71+
- name: Build and push server image
72+
uses: docker/build-push-action@v5
73+
with:
74+
context: .
75+
file: ./docker/server/Dockerfile
76+
push: ${{ github.event_name != 'pull_request' }}
77+
tags: |
78+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-prod-server:latest
79+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-prod-server:${{ github.sha }}
80+
cache-from: type=gha
81+
cache-to: type=gha,mode=max
82+
platforms: linux/amd64,linux/arm64
83+
84+
- name: Output server image name
85+
if: github.event_name != 'pull_request'
86+
run: |
87+
echo "Server image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-prod-server:latest"

.github/workflows/ci-backend.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Backend code checks
2+
3+
on:
4+
push:
5+
branches: [use_uv]
6+
pull_request:
7+
types: ["opened", "synchronize", "reopened", "edited"]
8+
workflow_dispatch:
9+
10+
jobs:
11+
lint:
12+
name: Run Flake8
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: "Set up Python"
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: 3.12
21+
22+
- name: "Install flake8 and plugins"
23+
run: |
24+
pip install flake8 flake8-django
25+
26+
- name: "Run flake8"
27+
uses: liskin/gh-problem-matcher-wrap@v1
28+
with:
29+
linters: flake8
30+
run: flake8 --max-line-length 150 server/
31+
32+
build:
33+
name: Build and test
34+
runs-on: ubuntu-latest
35+
36+
defaults:
37+
run:
38+
working-directory: server
39+
40+
services:
41+
db:
42+
image: postgres
43+
env:
44+
POSTGRES_USER: postgres
45+
POSTGRES_PASSWORD: password
46+
POSTGRES_DB: github-actions
47+
ports:
48+
- 5432:5432
49+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
50+
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
55+
- name: Set up Python
56+
uses: actions/setup-python@v5
57+
with:
58+
python-version: "3.12"
59+
60+
- name: Install uv
61+
run: pip install uv
62+
63+
- name: Install dependencies 👨🏻‍💻
64+
run: uv sync --frozen
65+
66+
- name: Run Migrations 🕊️
67+
env:
68+
API_SECRET_KEY: o!v%_v0zjvc5+_)e!r+o!_uefr2a&)lfgv17$ex=a!ei%!y-_o
69+
POSTGRES_HOST: localhost
70+
POSTGRES_PASSWORD: password
71+
POSTGRES_PORT: 5432
72+
EMAIL_PORT: 1025
73+
FRONTEND_URL: http://localhost:3000
74+
run: uv run python manage.py migrate
75+
76+
- name: Run tests 🧪
77+
env:
78+
API_SECRET_KEY: o!v%_v0zjvc5+_)e!r+o!_uefr2a&)lfgv17$ex=a!ei%!y-_o
79+
JWT_SIGNING_KEY: NjMgNmYgNmQgNmQgNzUgNmUgNjkgNzQgNzkgNzMgNzAgNjkgNzIgNjkgNzQgNjYgNmYgNzUgNmUgNjQgNjEgNzQgNjkgNmYgNmU=
80+
POSTGRES_HOST: localhost
81+
POSTGRES_PASSWORD: password
82+
POSTGRES_PORT: 5432
83+
EMAIL_PORT: 1025
84+
FRONTEND_URL: http://localhost:3000
85+
run: |
86+
uv run coverage run manage.py test
87+
uv run coverage xml
88+
89+
- name: Upload Coverage ☂️
90+
uses: codecov/codecov-action@v3
91+
with:
92+
flags: backend
93+
files: ./server/coverage.xml

.github/workflows/ci-frontend.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Frontend code checks
2+
3+
on:
4+
push:
5+
branches: [use_uv]
6+
pull_request:
7+
types: ["opened", "synchronize", "reopened", "edited"]
8+
workflow_dispatch:
9+
10+
jobs:
11+
format:
12+
name: Run Prettier
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
working-directory: client
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: actions/setup-node@v3
20+
with:
21+
node-version: "20"
22+
cache: "npm"
23+
cache-dependency-path: client/package-lock.json
24+
25+
- name: Install dependencies
26+
run: npm i
27+
- name: Run Prettier
28+
run: npm run format:check
29+
lint:
30+
name: Run ESLint
31+
runs-on: ubuntu-latest
32+
defaults:
33+
run:
34+
working-directory: client
35+
steps:
36+
- uses: actions/checkout@v3
37+
- uses: actions/setup-node@v3
38+
with:
39+
node-version: "20"
40+
cache: "npm"
41+
cache-dependency-path: client/package-lock.json
42+
43+
- name: Install dependencies
44+
run: npm i
45+
- name: Run Eslint
46+
run: npm run lint:strict && npm run lint
47+
typecheck:
48+
name: Check types
49+
runs-on: ubuntu-latest
50+
defaults:
51+
run:
52+
working-directory: client
53+
steps:
54+
- uses: actions/checkout@v3
55+
- uses: actions/setup-node@v3
56+
with:
57+
node-version: "20"
58+
cache: "npm"
59+
cache-dependency-path: client/package-lock.json
60+
61+
- name: Install dependencies
62+
run: npm i
63+
- name: Run tsc
64+
run: npm run typecheck
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Create Branch from Issue
2+
3+
on:
4+
issues:
5+
types: [assigned]
6+
7+
jobs:
8+
create_issue_branch_job:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Create Issue Branch
12+
uses: robvanderleek/create-issue-branch@main
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: "Issue Autolink"
2+
on:
3+
pull_request:
4+
types: [opened]
5+
6+
jobs:
7+
issue-links:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: tkt-actions/add-issue-links@v1.8.2
11+
with:
12+
repo-token: ${{ secrets.GITHUB_TOKEN }}
13+
branch-prefix: "issue-"
14+
resolve: "true"

0 commit comments

Comments
 (0)