Skip to content

Commit

Permalink
Merge pull request #18 from CrowdJustice/sorting-out-versioning
Browse files Browse the repository at this point in the history
Sorting out versioning
  • Loading branch information
phil-bell authored Mar 1, 2022
2 parents 1e25cdc + 05a3c1a commit cb79dc6
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 14 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: release

on:
push:
branches:
- "main"

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build
run: |
python3 -m pip install --upgrade build
python3 -m build
echo "VERSION=$(python setup.py --version)" >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v1
with:
body: |
### Install with
```
pip install git+https://github.com/CrowdJustice/legl-dev.git@${{ env.VERSION }}
```
files: dist/*
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.VERSION }}
63 changes: 50 additions & 13 deletions legl_dev/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#!/usr/bin/env python3
from os import environ
import os

import pkg_resources
import typer

from legl_dev.command import Command, Steps

app = typer.Typer()
app = typer.Typer(invoke_without_command=True)

os.environ["COMPOSE_DOCKER_CLI_BUILD"] = "1"
os.environ["DOCKER_BUILDKIT"] = "1"


@app.command(help="Start the dev enviroment")
Expand Down Expand Up @@ -36,16 +40,22 @@ def build(
[
Command(command=f"docker compose up -d"),
Command(command=(f"docker compose exec backend python manage.py migrate")),
Command(command=(f"docker compose exec backend python manage.py flush --noinput")),
Command(command=(f"docker compose exec backend python manage.py run_factories")),
Command(command=(f"docker compose exec backend python manage.py seed_emails")),
Command(
command=(
f"docker compose exec backend python manage.py flush --noinput"
)
),
Command(
command=(f"docker compose exec backend python manage.py run_factories")
),
Command(
command=(f"docker compose exec backend python manage.py seed_emails")
),
Command(command=f"docker compose stop"),
]
)
steps.run()

print("Build complete 🚀")


@app.command(help="Run the local pytest unit tests")
def pytest(
Expand Down Expand Up @@ -155,19 +165,31 @@ def cypress():
def migrate(
merge: bool = typer.Option(False, help="Run a migration merge first"),
make: bool = typer.Option(False, help="Run makemigrations before migrating"),
run: bool = typer.Option(True, help="use --no-run to prevent migrations from running"),
run: bool = typer.Option(
True, help="use --no-run to prevent migrations from running"
),
):

steps = Steps()
if merge:
steps.add(
Command(
command=(f"docker compose " "exec backend python manage.py makemigrations --merge")
command=(
f"docker compose "
"exec backend python manage.py makemigrations --merge"
)
),
)
if make:
steps.add(
(Command(command=(f"docker compose " "exec backend python manage.py makemigrations"))),
(
Command(
command=(
f"docker compose "
"exec backend python manage.py makemigrations"
)
)
),
)
if run:
steps.add(
Expand All @@ -183,13 +205,21 @@ def factories(

steps = Steps(
steps=[
Command(command=(f"docker compose exec backend python manage.py flush --noinput")),
Command(command=(f"docker compose exec backend python manage.py run_factories")),
Command(
command=(
f"docker compose exec backend python manage.py flush --noinput"
)
),
Command(
command=(f"docker compose exec backend python manage.py run_factories")
),
],
)
if emails:
steps.add(
Command(command=(f"docker compose exec backend python manage.py seed_emails")),
Command(
command=(f"docker compose exec backend python manage.py seed_emails")
),
)
steps.run()

Expand Down Expand Up @@ -225,5 +255,12 @@ def jstest():
steps.run()


@app.callback()
def main(version: bool = False):
if version:
typer.echo(f"v{pkg_resources.require('legl_dev')[0].version}")
raise typer.Exit()


if __name__ == "__main__":
app()
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup_kwargs = {
"name": "legl-dev",
"version": "1.0.4",
"version": "1.0.6",
"description": "",
"long_description": '# `legl-dev`\n\n**Usage**:\n\n```console\n$ legl-dev [OPTIONS] COMMAND [ARGS]...\n```\n\n**Options**:\n\n* `--install-completion`: Install completion for the current shell.\n* `--show-completion`: Show completion for the current shell, to copy it or customize the installation.\n* `--help`: Show this message and exit.\n\n**Commands**:\n\n* `build`: Rebuild the local enviroment\n* `cypress`: Open Cpyress e2e tests\n* `factories`: Clean out and create new factories\n* `format`: Format the code with black and prettier\n* `gitclean`: Cleans out git branches\n* `jstest`: Run JS unit tests\n* `migrate`: Create and run migrations\n* `pytest`: Run the local pytest unit tests\n* `start`: Start the dev enviroment\n* `update`: Update dependancies\n\n## `legl-dev build`\n\nRebuild the local enviroment\n\n**Usage**:\n\n```console\n$ legl-dev build [OPTIONS]\n```\n\n**Options**:\n\n* `--verbose / --no-verbose`: Run the command in verbose mode [default: False]\n* `--create-db / --no-create-db`: Drop the database and create a fresh one [default: False]\n* `--help`: Show this message and exit.\n\n## `legl-dev cypress`\n\nOpen Cpyress e2e tests\n\n**Usage**:\n\n```console\n$ legl-dev cypress [OPTIONS]\n```\n\n**Options**:\n\n* `--verbose / --no-verbose`: Run the command in verbose mode [default: True]\n* `--help`: Show this message and exit.\n\n## `legl-dev factories`\n\nClean out and create new factories\n\n**Usage**:\n\n```console\n$ legl-dev factories [OPTIONS]\n```\n\n**Options**:\n\n* `--verbose / --no-verbose`: Run the command in verbose mode [default: False]\n* `--help`: Show this message and exit.\n\n## `legl-dev format`\n\nFormat the code with black and prettier\n\n**Usage**:\n\n```console\n$ legl-dev format [OPTIONS]\n```\n\n**Options**:\n\n* `--verbose / --no-verbose`: Run the command in verbose mode [default: False]\n* `--push / --no-push`: Also push the changes to the repo [default: False]\n* `--help`: Show this message and exit.\n\n## `legl-dev gitclean`\n\nCleans out git branches\n\n**Usage**:\n\n```console\n$ legl-dev gitclean [OPTIONS]\n```\n\n**Options**:\n\n* `--verbose / --no-verbose`: Run the command in verbose mode [default: False]\n* `--help`: Show this message and exit.\n\n## `legl-dev jstest`\n\nRun JS unit tests\n\n**Usage**:\n\n```console\n$ legl-dev jstest [OPTIONS]\n```\n\n**Options**:\n\n* `--verbose / --no-verbose`: Run the command in verbose mode [default: True]\n* `--help`: Show this message and exit.\n\n## `legl-dev migrate`\n\nCreate and run migrations\n\n**Usage**:\n\n```console\n$ legl-dev migrate [OPTIONS]\n```\n\n**Options**:\n\n* `--verbose / --no-verbose`: Run the command in verbose mode [default: False]\n* `--merge / --no-merge`: Run a migration merge first [default: False]\n* `--help`: Show this message and exit.\n\n## `legl-dev pytest`\n\nRun the local pytest unit tests\n\n**Usage**:\n\n```console\n$ legl-dev pytest [OPTIONS] [PATH]\n```\n\n**Arguments**:\n\n* `[PATH]`: path for specific test in the format "<file path>::<class name>::<function name>" [default: ]\n\n**Options**:\n\n* `--verbose / --no-verbose`: Run the command in verbose mode [default: False]\n* `--full-diff / --no-full-diff`: Show full diff in errors [default: False]\n* `--create-db / --no-create-db`: Recreates the test database [default: False]\n* `--last-failed / --no-last-failed`: Run the last failed tests [default: False]\n* `--warnings / --no-warnings`: Toggle warnings in output [default: True]\n* `--gui / --no-gui`: Toggle the output gui [default: True]\n* `--help`: Show this message and exit.\n\n## `legl-dev start`\n\nStart the dev enviroment\n\n**Usage**:\n\n```console\n$ legl-dev start [OPTIONS]\n```\n\n**Options**:\n\n* `--verbose / --no-verbose`: Run the command in verbose mode [default: True]\n* `--help`: Show this message and exit.\n\n## `legl-dev update`\n\nUpdate dependancies\n\n**Usage**:\n\n```console\n$ legl-dev update [OPTIONS]\n```\n\n**Options**:\n\n* `--verbose / --no-verbose`: Run the command in verbose mode [default: False]\n* `--help`: Show this message and exit.\n',
"author": "phil-bell",
Expand Down

0 comments on commit cb79dc6

Please sign in to comment.