build: tooling clean-up (#14)
* build(backend): requirements-locks to use venv directly to avoid needing to activate * build(backend): taskfile cleaning, no more sourcing * build(frontend): remove unneeded syntax, cmds>cmd for one-liners * docs: instructors on local setup * ci: hoisted default working directory settings
This commit is contained in:
parent
da2bf786d5
commit
fbba07cbdc
6 changed files with 52 additions and 52 deletions
13
.github/workflows/backend-pipeline.yml
vendored
13
.github/workflows/backend-pipeline.yml
vendored
|
@ -10,13 +10,14 @@ on:
|
||||||
env:
|
env:
|
||||||
ROTINI_CI: 1
|
ROTINI_CI: 1
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: backend
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
setup:
|
setup:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Setup
|
name: Setup
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: backend
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: get-python-version
|
- name: get-python-version
|
||||||
|
@ -38,9 +39,6 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Lint
|
name: Lint
|
||||||
needs: setup
|
needs: setup
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: backend
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: get-python-version
|
- name: get-python-version
|
||||||
|
@ -66,9 +64,6 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Test
|
name: Test
|
||||||
needs: setup
|
needs: setup
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: backend
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: get-python-version
|
- name: get-python-version
|
||||||
|
|
19
.github/workflows/frontend-pipeline.yml
vendored
19
.github/workflows/frontend-pipeline.yml
vendored
|
@ -11,13 +11,14 @@ env:
|
||||||
NODE_VERSION: lts/hydrogen
|
NODE_VERSION: lts/hydrogen
|
||||||
CI: 1
|
CI: 1
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: frontend
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
setup:
|
setup:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Setup
|
name: Setup
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: frontend
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
|
@ -35,9 +36,6 @@ jobs:
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Lint
|
name: Lint
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: frontend
|
|
||||||
needs: setup
|
needs: setup
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
@ -60,9 +58,6 @@ jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Test
|
name: Test
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: frontend
|
|
||||||
needs: setup
|
needs: setup
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
@ -85,9 +80,6 @@ jobs:
|
||||||
typecheck:
|
typecheck:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Typecheck
|
name: Typecheck
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: frontend
|
|
||||||
needs: setup
|
needs: setup
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
@ -110,9 +102,6 @@ jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Build App
|
name: Build App
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: frontend
|
|
||||||
needs: setup
|
needs: setup
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
19
README.md
19
README.md
|
@ -3,5 +3,20 @@ An unnamed cloud storage app
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
Run `. script/bootstrap` to enable `task` commands that make everything else simpler. Then, `task -l` will list out
|
### Tooling
|
||||||
available utilities.
|
|
||||||
|
Utility commands are managed by [go-task](https://github.com/go-task/task) and can be called from anywhere. Running `.
|
||||||
|
script/bootstrap` installs `go-task` within the project and gets everything ready. From there, `task -l` provides a
|
||||||
|
breakdown of available tools.
|
||||||
|
|
||||||
|
Note that this is the preferred way to running any tooling-related task within the repository, regardless of
|
||||||
|
environment.
|
||||||
|
|
||||||
|
### Running locally
|
||||||
|
|
||||||
|
The application requires a Postgres database instance to be made available to the backend. This can be done for you via
|
||||||
|
`task be:start-db`.
|
||||||
|
|
||||||
|
Starting the backend and frontend applications can be done via `task be:start` and `task fe:start`.
|
||||||
|
|
||||||
|
See the README files of each of those environments ([backend](./backend/README.md), [frontend](./frontend/README.md)) for specific requirements (i.e. environment dotfiles).
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
VENV_ACTIVATE: "/{{ .TASKFILE_DIR }}/backend/.venv/bin/activate"
|
VENV_PATH: "/{{ .TASKFILE_DIR }}/backend/.venv"
|
||||||
|
VENV_BIN: "{{ .VENV_PATH }}/bin"
|
||||||
|
VENV_ACTIVATE: "{{ .VENV_BIN }}/activate"
|
||||||
|
DOTENV: "/{{ .TASKFILE_DIR }}/backend/.env"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
bootstrap:
|
bootstrap:
|
||||||
|
@ -12,12 +15,16 @@ tasks:
|
||||||
lint:
|
lint:
|
||||||
desc: "Lints /backend using black + pylint."
|
desc: "Lints /backend using black + pylint."
|
||||||
deps: [bootstrap]
|
deps: [bootstrap]
|
||||||
cmd: source {{ .VENV_ACTIVATE }} && black . --check && pylint ./rotini
|
cmds:
|
||||||
|
- "{{ .VENV_BIN }}/black . --check"
|
||||||
|
- "{{ .VENV_BIN }}/pylint ./rotini"
|
||||||
dir: backend
|
dir: backend
|
||||||
lintfix:
|
lintfix:
|
||||||
desc: "Lints and fixes /backend using black + pylint."
|
desc: "Lints and fixes /backend using black + pylint."
|
||||||
deps: [bootstrap]
|
deps: [bootstrap]
|
||||||
cmd: source {{ .VENV_ACTIVATE }} && black . && pylint ./rotini
|
cmds:
|
||||||
|
- "{{ .VENV_BIN }}/black ."
|
||||||
|
- "{{ .VENV_BIN }}/pylint ./rotini"
|
||||||
dir: backend
|
dir: backend
|
||||||
test:
|
test:
|
||||||
desc: "Run the test suites."
|
desc: "Run the test suites."
|
||||||
|
@ -28,27 +35,25 @@ tasks:
|
||||||
desc: "Starts the backend application."
|
desc: "Starts the backend application."
|
||||||
deps: [bootstrap]
|
deps: [bootstrap]
|
||||||
dotenv:
|
dotenv:
|
||||||
- "../.env"
|
- "{{ .DOTENV }}"
|
||||||
cmd: source {{ .VENV_ACTIVATE }} && python -m uvicorn main:app
|
cmd: "{{ .VENV_BIN }}/python -m uvicorn main:app"
|
||||||
dir: backend/rotini
|
dir: backend/rotini
|
||||||
start-db:
|
start-db:
|
||||||
desc: "Provisions a local Postgres database."
|
desc: "Provisions a local Postgres database."
|
||||||
dotenv:
|
dotenv:
|
||||||
- ".env"
|
- "{{ .DOTENV }}"
|
||||||
cmd: . script/provision-db
|
cmd: . script/provision-db
|
||||||
dir: backend
|
dir: backend
|
||||||
migrate:
|
migrate:
|
||||||
desc: "Applies migrations. Usage: be:migrate -- <up|down>"
|
desc: "Applies migrations. Usage: be:migrate -- <up|down>"
|
||||||
deps: [bootstrap]
|
deps: [bootstrap]
|
||||||
dotenv:
|
dotenv:
|
||||||
- "../../.env"
|
- "{{ .DOTENV }}"
|
||||||
cmds:
|
cmd: "{{ .VENV_BIN }}/python migrate.py {{ .CLI_ARGS }}"
|
||||||
- source {{ .VENV_ACTIVATE }} && python migrate.py {{.CLI_ARGS}}
|
|
||||||
dir: backend/rotini/migrations
|
dir: backend/rotini/migrations
|
||||||
lock-deps:
|
lock-deps:
|
||||||
desc: "Locks production and development dependencies"
|
desc: "Locks production and development dependencies"
|
||||||
deps: [bootstrap]
|
deps: [bootstrap]
|
||||||
cmds:
|
cmd: . script/requirements-lock
|
||||||
- source {{ .VENV_ACTIVATE }} && . script/requirements-lock
|
|
||||||
dir: backend
|
dir: backend
|
||||||
|
|
||||||
|
|
|
@ -3,42 +3,35 @@ version: '3'
|
||||||
tasks:
|
tasks:
|
||||||
bootstrap:
|
bootstrap:
|
||||||
internal: true
|
internal: true
|
||||||
cmds:
|
cmd: . script/bootstrap
|
||||||
- . script/bootstrap
|
|
||||||
dir: frontend
|
dir: frontend
|
||||||
start:
|
start:
|
||||||
desc: "Starts the frontend application."
|
desc: "Starts the frontend application."
|
||||||
deps: [bootstrap]
|
deps: [bootstrap]
|
||||||
cmds:
|
cmd: yarn start
|
||||||
- yarn start
|
|
||||||
dir: frontend
|
dir: frontend
|
||||||
build:
|
build:
|
||||||
desc: "Build the app."
|
desc: "Build the app."
|
||||||
deps: [bootstrap]
|
deps: [bootstrap]
|
||||||
cmds:
|
cmd: yarn build
|
||||||
- yarn build
|
|
||||||
dir: frontend
|
dir: frontend
|
||||||
test:
|
test:
|
||||||
desc: "Runs the frontend test suite."
|
desc: "Runs the frontend test suite."
|
||||||
deps: [bootstrap]
|
deps: [bootstrap]
|
||||||
cmds:
|
cmd: yarn test
|
||||||
- yarn test
|
|
||||||
dir: frontend
|
dir: frontend
|
||||||
lint:
|
lint:
|
||||||
desc: "Checks lint and formatting."
|
desc: "Checks lint and formatting."
|
||||||
deps: [bootstrap]
|
deps: [bootstrap]
|
||||||
cmds:
|
cmd: yarn lint
|
||||||
- yarn lint
|
|
||||||
dir: frontend
|
dir: frontend
|
||||||
lintfix:
|
lintfix:
|
||||||
desc: "Fixes lint and formatting."
|
desc: "Fixes lint and formatting."
|
||||||
deps: [bootstrap]
|
deps: [bootstrap]
|
||||||
cmds:
|
cmd: yarn lint:fix
|
||||||
- yarn lint:fix
|
|
||||||
dir: frontend
|
dir: frontend
|
||||||
typecheck:
|
typecheck:
|
||||||
desc: "Validates types."
|
desc: "Validates types."
|
||||||
deps: [bootstrap]
|
deps: [bootstrap]
|
||||||
cmds:
|
cmd: yarn typecheck
|
||||||
- yarn typecheck
|
|
||||||
dir: frontend
|
dir: frontend
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
pip-compile requirements.in --no-header && pip-compile requirements_dev.in --no-header
|
PIP_COMPILE=.venv/bin/pip-compile
|
||||||
|
|
||||||
|
$PIP_COMPILE requirements.in --no-header \
|
||||||
|
&& $PIP_COMPILE requirements_dev.in --no-header
|
||||||
|
|
Reference in a new issue