Skip to content

Commit

Permalink
Switch to make targets (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
florimondmanca authored Dec 19, 2021
1 parent 8f27839 commit 0a4b2ae
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 143 deletions.
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# App configuration
DEBUG=true
# EXTRA_CONTENT_DIRS="drafts/"

# Heroku CLI
PYTHONUNBUFFERED=true
PORT=8000
59 changes: 59 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
venv = venv
bin = ${venv}/bin/
python = ${bin}python
pip = ${bin}pip
pysources = server/ tests/

build:
NODE_ENV=production yarn build

check:
${bin}black --check --diff ${pysources}
${bin}flake8 ${pysources}
${bin}mypy ${pysources}
${bin}isort --check --diff ${pysources}
${python} -m server.tools.mdformat --check

deploy:
scripts/deploy $(args)

${venv}:
python3 -m venv ${venv}

install:
make ${venv}
${pip} install -U pip wheel
${pip} install -r requirements-dev.txt
make messagesc
test ${CI} && yarn install || echo skip
make .env

.env:
cp .env.example .env

lint:
${bin}autoflake --in-place --recursive ${pysources}
${bin}isort ${pysources}
${bin}black ${pysources}
${python} -m server.tools.mdformat

messages:
make locale/.init
${bin}pybabel extract -F babel.cfg -o locale/base.pot ./server/
${bin}pybabel update -i locale/base.pot -d locale

locale/.init:
${bin}pybabel init -l fr_FR -i locale/base.pot -d locale
touch locale/.init

messagesc:
${bin}pybabel compile --domain messages -d locale

watch:
NODE_ENV=production yarn watch

serve:
${bin}uvicorn server:app $(args)

test:
${bin}pytest $(args)
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ Development only:
## Install

```bash
scripts/install [--update]
make install
```

## Usage

- Run the website locally:

```bash
scripts/serve [UVICORN_OPTIONS]
make serve

# With options:
make args=[UVICORN_OPTIONS] serve
```

- Run the website as it would run in production:
Expand All @@ -41,13 +44,16 @@ heroku local
- Run the test suite:

```bash
scripts/test [PYTEST_OPTIONS]
make test

# With options:
make args=[PYTEST_OPTIONS] test
```

- Build assets:

```bash
scripts/build
make build
```

## Deployment
Expand All @@ -58,7 +64,7 @@ This website is deployed via [Dokku](http://dokku.viewdocs.io/dokku/).
2. Run the deploy script:

```bash
scripts/deploy
make deploy
```

## Settings
Expand Down
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"scripts": {
"dokku": {
"predeploy": "scripts/compilemessages"
"predeploy": "make messagesc"
}
}
}
6 changes: 3 additions & 3 deletions ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resources:
type: github
endpoint: github
name: florimondmanca/azure-pipelines-templates
ref: refs/tags/4.0
ref: refs/heads/master

trigger:
- master
Expand All @@ -29,7 +29,7 @@ jobs:
parameters:
nodeVersion: "16.x"
- script: yarn install
- bash: scripts/build
- script: make build

- template: job--python-test.yml@templates
parameters:
Expand All @@ -48,4 +48,4 @@ jobs:
inputs:
knownHostsEntry: florimond.dev ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBD7z+We1qSM6E/IJS1qEUT9liHdQdNL96pAqUSTElAjk+NZsMXViY/ThWG4HkuOQeTsIhlzXvg75xJ8JTWbgWVI=
sshKeySecureFile: florimond-dev-deploy-id_rsa
- bash: scripts/deploy
- bash: make deploy
3 changes: 0 additions & 3 deletions scripts/build

This file was deleted.

16 changes: 0 additions & 16 deletions scripts/check

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/clean

This file was deleted.

13 changes: 0 additions & 13 deletions scripts/compilemessages

This file was deleted.

29 changes: 0 additions & 29 deletions scripts/install

This file was deleted.

15 changes: 0 additions & 15 deletions scripts/lint

This file was deleted.

23 changes: 0 additions & 23 deletions scripts/makemessages

This file was deleted.

9 changes: 0 additions & 9 deletions scripts/serve

This file was deleted.

14 changes: 0 additions & 14 deletions scripts/test

This file was deleted.

0 comments on commit 0a4b2ae

Please sign in to comment.