-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
copy-pasted the code from another branch (#86)
Added CI pipeline, formatters, and secret management
- Loading branch information
Showing
32 changed files
with
295 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
|
||
**/.DS_Store | ||
**/__pycache__ | ||
**/.pytest_cache | ||
**/.mypy_cache | ||
**/.venv | ||
**/.classpath | ||
**/.dockerignore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
name: CI Pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
branches: | ||
- master | ||
|
||
jobs: | ||
eslint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.x' | ||
|
||
- name: Install Node.js dependencies | ||
run: npm ci | ||
|
||
- name: Run ESLint | ||
run: npm run lint | ||
|
||
black_lint_and_mypy_type_check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install black mypy | ||
pip install fastapi pydantic pydantic-settings sqlalchemy GeoAlchemy2 pytest | ||
- name: Check code formatting with black | ||
run: black --check . | ||
|
||
- name: Type check with mypy | ||
run: mypy --config-file mypy.ini . | ||
|
||
docker_build_test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get Run ID of Most Recent Successful Run | ||
id: get_run_id | ||
run: | | ||
response=$(curl -s -H "Authorization: token ${{ secrets.GH_PAT }}" \ | ||
"https://api.github.com/repos/sfbrigade/datasci-earthquake/actions/workflows/env_vars.yml/runs?status=completed&conclusion=success") | ||
run_id=$(echo $response | jq '.workflow_runs[0].id') | ||
echo "Run ID: $run_id" | ||
echo "run_id=$run_id" >> $GITHUB_ENV | ||
- name: Download .env Artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: env-file | ||
github-token: ${{ secrets.GH_PAT }} | ||
repository: sfbrigade/datasci-earthquake | ||
run-id: ${{ env.run_id }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Build Docker Containers | ||
run: docker compose build | ||
|
||
- name: Start Services | ||
run: docker compose up -d | ||
|
||
- name: Run Backend Tests | ||
run: docker compose run backend pytest backend/database/tests | ||
|
||
- name: Run Frontend Tests | ||
run: docker compose run frontend npm test | ||
|
||
- name: Clean Up | ||
run: docker compose down --volumes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Generate .env File | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
create-envfile: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Make envfile | ||
uses: SpicyPizza/create-envfile@v2.0 | ||
with: | ||
envkey_POSTGRES_USER: ${{ secrets.POSTGRES_USER }} | ||
envkey_POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | ||
envkey_POSTGRES_DB: ${{ secrets.POSTGRES_DB }} | ||
envkey_POSTGIS_VERSION: ${{ secrets.POSTGIS_VERSION }} | ||
|
||
envkey_FRONTEND_HOST: ${{ secrets.FRONTEND_HOST }} | ||
envkey_DATABASE_URL: ${{ secrets.DATABASE_URL }} | ||
envkey_LOCALHOST_DATABASE_URL: ${{ secrets.LOCALHOST_DATABASE_URL }} | ||
envkey_DATABASE_URL_SQLALCHEMY: ${{ secrets.DATABASE_URL_SQLALCHEMY }} | ||
envkey_LOCALHOST_DATABASE_URL_SQLALCHEMY: ${{ secrets.LOCALHOST_DATABASE_URL_SQLALCHEMY }} | ||
envkey_ENVIRONMENT: ${{ secrets.ENVIRONMENT }} | ||
envkey_SECRET_KEY: ${{ secrets.SECRET_KEY }} | ||
|
||
envkey_NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }} | ||
envkey_NEXT_PUBLIC_MAPBOX_TOKEN: ${{ secrets.NEXT_PUBLIC_MAPBOX_TOKEN }} | ||
envkey_NODE_ENV: ${{ secrets.NODE_ENV }} | ||
|
||
file_name: .env | ||
directory: './' | ||
fail_on_empty: false | ||
sort_keys: false | ||
|
||
- name: Upload .env as Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: env-file | ||
include-hidden-files: true | ||
path: ./.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 23.3.0 | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: "v1.13.0" | ||
hooks: | ||
- id: mypy | ||
args: ["--config-file", "mypy.ini"] | ||
additional_dependencies: | ||
- "pydantic>=2.9.0" | ||
- "sqlalchemy>=2.0.35" | ||
- "pydantic-settings>=2.5.2" | ||
- "fastapi>=0.114.0" | ||
- "GeoAlchemy2>=0.15.2" | ||
- "pytest>=8.3.3" | ||
- repo: https://github.com/pre-commit/mirrors-eslint | ||
rev: "v9.14.0" | ||
hooks: | ||
- id: eslint | ||
args: | ||
- "--config=.eslintrc.js" | ||
- "--cache" | ||
- "--ignore-pattern=node_modules/*" | ||
entry: npm run lint | ||
language: node | ||
files: \.[jt]sx?$ | ||
additional_dependencies: | ||
- "eslint" | ||
- "eslint-plugin-prettier" | ||
- "eslint-config-prettier" | ||
- "prettier" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ build | |
api | ||
.github | ||
pull_request_template.md | ||
.mypy_cache/ | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.