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

Setup #3

Merged
merged 45 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d4f5b1a
initial
SKairinos Sep 11, 2023
1ba8153
initial code
SKairinos Sep 12, 2023
194d50d
quick save
SKairinos Sep 12, 2023
cf5526d
install portal instead
SKairinos Sep 12, 2023
a22d25f
auth backends
SKairinos Sep 13, 2023
3598cae
tidy up auth backends
SKairinos Sep 13, 2023
5f1c537
update auth backends
SKairinos Sep 13, 2023
cc510c8
quick save
SKairinos Sep 13, 2023
a78f098
deploy to gcloud
SKairinos Sep 13, 2023
1b1945b
fix pipeline
SKairinos Sep 13, 2023
ae05f02
don't check migrations
SKairinos Sep 13, 2023
c44c8d0
use correct service name
SKairinos Sep 13, 2023
dcea83a
no pytest
SKairinos Sep 13, 2023
b80dccf
use latest cfl packages
SKairinos Sep 13, 2023
d6230b4
quick save
SKairinos Sep 14, 2023
f5fb6eb
include a base url for service routing
SKairinos Sep 14, 2023
b46d789
set base route
SKairinos Sep 14, 2023
22de360
use cfl package
SKairinos Sep 14, 2023
5bd781a
tests and remove user import
SKairinos Sep 14, 2023
393eb70
session config
SKairinos Sep 14, 2023
14a30e2
quick save
SKairinos Sep 15, 2023
681750f
remove logout endpoint
SKairinos Sep 15, 2023
6ed3e50
login working
SKairinos Sep 15, 2023
3201d5f
set session cookie domain
SKairinos Sep 15, 2023
0d5029f
return invalid form errors
SKairinos Sep 15, 2023
d740dbd
login middleware
SKairinos Sep 15, 2023
51d62d7
simplify code
SKairinos Sep 15, 2023
e688085
remove login middleware
SKairinos Sep 15, 2023
4210534
remove extra white spacing
SKairinos Sep 15, 2023
56ec08a
update launch
SKairinos Sep 18, 2023
d8a6067
use new cfl package
SKairinos Sep 18, 2023
78f5ef0
fix pipeline
SKairinos Sep 18, 2023
fe4edb2
raise validation errors
SKairinos Sep 18, 2023
8e63cef
remove todos
SKairinos Sep 18, 2023
2c3140b
use latest package version
SKairinos Sep 19, 2023
a910e05
use latest cfl package
SKairinos Sep 19, 2023
a86a15b
set secret key
SKairinos Sep 19, 2023
429bd25
new cfl package
SKairinos Sep 19, 2023
c0a223f
fix: set env vars
SKairinos Sep 19, 2023
f2a1a68
use new cfl package
SKairinos Sep 19, 2023
7439dec
user new cfl-common package
SKairinos Sep 19, 2023
006c487
house keeping [skip ci]
SKairinos Sep 19, 2023
ba679e7
use latest cfl package
SKairinos Sep 19, 2023
792fa71
feedback
SKairinos Sep 21, 2023
9131425
remove unnecessary return types
SKairinos Sep 21, 2023
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
102 changes: 102 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Main

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

env:
SERVICE_NAME: 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

# https://mikefarah.gitbook.io/yq/
- name: 🖊️ Configure App Deployment
uses: mikefarah/yq@master
with:
cmd: |
SERVICE_NAME=$(
if [ ${{ github.ref_name }} == "production" ]
then echo ${{ env.SERVICE_NAME }}
else echo ${{ github.ref_name }}-${{ env.SERVICE_NAME }}
fi
)

yq -i '
.service = "${{ github.ref_name }}-${{ env.SERVICE_NAME }}" |
.env_variables.SECRET_KEY = "${{ vars.SECRET_KEY }}" |
.env_variables.SERVICE_NAME = "$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