Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge dev into staging #6

Merged
merged 3 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Main

on:
push:
paths-ignore:
- "README.md"
- "CHANGELOG.md"
- "LICENSE"
- ".gitignore"
- ".vscode"
workflow_dispatch:

env:
SERVICE: sso
PYTHON_VERSION: 3.8

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: 🛫 Checkout
uses: actions/checkout@v3

- name: 🐍 Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Python Packages
working-directory: ./backend
run: |
python -m pip install --upgrade pip
python -m pip install pipenv
pipenv install --dev

- name: Check Code Format
working-directory: ./backend
run: if ! pipenv run black --check .; then exit 1; fi

- name: Check Migrations
working-directory: ./backend
run: pipenv run python manage.py makemigrations --check --dry-run

# TODO: assert code coverage target.
- name: Test Code Units
working-directory: ./backend
run: pipenv run pytest

build-and-deploy:
runs-on: ubuntu-latest
needs: [test]
if: github.ref_name == 'production' || github.ref_name == 'development' || github.ref_name == 'staging'
environment: ${{ github.ref_name }}
steps:
- name: 🛫 Checkout
uses: actions/checkout@v3

- name: 🐍 Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: 🗝 Authenticate with GCloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}

- name: 🤖 Set up GCloud SDK
uses: google-github-actions/setup-gcloud@v1

- name: 🛠 Install Backend Dependencies
working-directory: ./backend
run: |
python -m pip install --upgrade pip
python -m pip install pipenv
pipenv install

- name: 🛠 Generate requirements.txt
working-directory: ./backend
run: pipenv requirements > requirements.txt

- name: ⚙️ Set Service Name
run: |
echo "SERVICE_NAME=$(
if [ ${{ github.ref_name }} == 'production' ]
then echo ${{ env.SERVICE }}
else echo ${{ github.ref_name }}-${{ env.SERVICE }}
fi
)" >> $GITHUB_ENV

# https://mikefarah.gitbook.io/yq/
- name: 🖊️ Configure App Deployment
uses: mikefarah/yq@master
with:
cmd: |
yq -i '
.service = "${{ github.ref_name }}-${{ env.SERVICE }}" |
.env_variables.SECRET_KEY = "${{ secrets.SECRET_KEY }}" |
.env_variables.SERVICE_NAME = "${{ env.SERVICE_NAME }}"
' backend/app.yaml

- name: 🚀 Deploy App on GCloud
working-directory: ./backend
run: gcloud app deploy
190 changes: 183 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,184 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

#IDE files
/.idea
# ------------------------------------------------------------------------------
# Backend
# ------------------------------------------------------------------------------

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

# ------------------------------------------------------------------------------
# Frontend
# ------------------------------------------------------------------------------

# dependencies
*/node_modules
/.pnp
.pnp.js

# testing
/coverage
coverage

# production
/build

# misc
.DS_Store
Expand All @@ -22,11 +191,18 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

# custom

# files generated by the Django bundler and settings
# Custom
.nyc_output
cypress/videos
cypress/screenshots
/backend/.python-version
/backend/*/static/react
/backend/*/templates/my_app_react.html
/backend/*/templates/portal.html
/backend/static
*.sqlite3
/frontend/build
node_modules
.cache
package-lock.json
/package.json
/yarn.lock
13 changes: 0 additions & 13 deletions .vscode/extensions.json

This file was deleted.

27 changes: 23 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,30 @@
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"name": "Django Server",
"type": "python",
"request": "launch",
"name": "Launch Chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}/src"
"django": true,
"justMyCode": false,
"program": "${workspaceFolder}/backend/manage.py",
"args": [
"runserver",
"localhost:8001"
],
"preLaunchTask": "migrate-db",
"env": {
"SERVICE_NAME": "sso",
"SERVICE_PORT": "8001"
}
},
{
"name": "Pytest",
"type": "python",
"request": "test",
"justMyCode": false,
"presentation": {
"hidden": true
}
}
]
}
13 changes: 10 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"editor.tabSize": 2,
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single"
"black-formatter.args": [
"--config",
"backend/pyproject.toml"
],
"python.testing.pytestArgs": [
"-c=backend/pyproject.toml",
"backend"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
Loading