Skip to content

Commit

Permalink
Merge branch 'integration/2024-evolution' into feature/twe-19-just-li…
Browse files Browse the repository at this point in the history
…nks-block
  • Loading branch information
SharmaineLim committed Jan 16, 2025
2 parents ba59321 + 5d7ccb5 commit e8288e6
Show file tree
Hide file tree
Showing 25 changed files with 1,109 additions and 1,027 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/flightpath.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: '3.13'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/flightpath_status_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: '3.13'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
python-version: '3.13'
cache: 'pip'

- name: Install dependencies
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: '3.13'
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: '3.13'
cache: 'poetry'
- uses: actions/download-artifact@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
default_language_version:
node: system
python: python3.11
python: python3.13
repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.10.0
hooks:
- id: black
language_version: python3.11
language_version: python3.13
exclude: .+/migrations
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20 as frontend
FROM node:20 AS frontend

# Make build & post-install scripts behave as if we were in a CI environment (e.g. for logging verbosity purposes).
ARG CI=true
Expand All @@ -16,7 +16,7 @@ RUN npm run build:prod
# ones becase they use a different C compiler. Debian images also come with
# all useful packages required for image manipulation out of the box. They
# however weight a lot, approx. up to 1.5GiB per built image.
FROM python:3.11 as production
FROM python:3.13 as production

ARG POETRY_INSTALL_ARGS="--no-dev"

Expand Down Expand Up @@ -71,7 +71,7 @@ USER tbx
# Install your app's Python requirements.
RUN python -m venv $VIRTUAL_ENV
COPY --chown=tbx pyproject.toml poetry.lock ./
RUN pip install --no-cache --upgrade pip && poetry install ${POETRY_INSTALL_ARGS} --no-root --extras gunicorn && rm -rf $HOME/.cache
RUN pip install --no-cache --upgrade pip && poetry install ${POETRY_INSTALL_ARGS} --no-root && rm -rf $HOME/.cache

COPY --chown=tbx --from=frontend ./tbx/static_compiled ./tbx/static_compiled

Expand All @@ -91,10 +91,10 @@ COPY ./docker/bashrc.sh /home/tbx/.bashrc

# Run the WSGI server. It reads GUNICORN_CMD_ARGS, PORT and WEB_CONCURRENCY
# environment variable hence we don't specify a lot options below.
CMD gunicorn tbx.wsgi:application
CMD ["gunicorn", "tbx.wsgi:application"]

# These steps won't be run on production
FROM production as dev
FROM production AS dev

# Swap user, so the following tasks can be run as root
USER root
Expand All @@ -117,4 +117,4 @@ RUN curl https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh
COPY --chown=tbx --from=frontend ./node_modules ./node_modules

# do nothing forever - exec commands elsewhere
CMD tail -f /dev/null
CMD ["tail", "-f", "/dev/null"]
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.7'
services:
web:
build:
Expand Down
1 change: 0 additions & 1 deletion docker/docker-compose-frontend.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# A custom compose file for $FRONTEND=docker, which also binds frontend ports

version: '3.7' # NB synchronise with /docker-compose.yml
services:
web:
ports:
Expand Down
47 changes: 23 additions & 24 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Process .env file
if os.path.exists(".env"):
with open(".env", "r") as f:
with open(".env") as f:
for line in f.readlines():
if not line or line.startswith("#") or "=" not in line:
continue
Expand Down Expand Up @@ -36,9 +36,7 @@


def dexec(cmd, service="web"):
return local(
"docker-compose exec -T {} bash -c {}".format(quote(service), quote(cmd))
)
return local(f"docker compose exec -T {quote(service)} bash -c {quote(cmd)}")


@task
Expand All @@ -51,11 +49,11 @@ def build(c):

group = subprocess.check_output(["id", "-gn"], encoding="utf-8").strip()
local("mkdir -p " + directories_arg)
local("chown -R $USER:{} {}".format(group, directories_arg))
local(f"chown -R $USER:{group} {directories_arg}")
local("chmod -R 775 " + directories_arg)

local("docker-compose pull")
local("docker-compose build")
local("docker compose pull", pty=True)
local("docker compose build", pty=True)


@task
Expand All @@ -64,10 +62,11 @@ def start(c):
Start the development environment
"""
if FRONTEND == "local":
local("docker-compose up -d")
local("docker compose up --detach", pty=True)
else:
local(
"docker-compose -f docker-compose.yml -f docker/docker-compose-frontend.yml up -d"
"docker compose -f docker-compose.yml -f docker/docker-compose-frontend.yml up -d",
pty=True,
)


Expand All @@ -76,7 +75,7 @@ def stop(c):
"""
Stop the development environment
"""
local("docker-compose stop")
local("docker compose stop", pty=True)


@task
Expand All @@ -93,23 +92,23 @@ def destroy(c):
"""
Destroy development environment containers (database will lost!)
"""
local("docker-compose down")
local("docker compose down --volumes", pty=True)


@task
def sh(c, service="web"):
"""
Run bash in a local container
"""
subprocess.run(["docker-compose", "exec", service, "bash"])
subprocess.run(["docker", "compose", "exec", service, "bash"])


@task
def sh_root(c, service="web"):
"""
Run bash as root in the local web container.
"""
subprocess.run(["docker-compose", "exec", "--user=root", "web", "bash"])
subprocess.run(["docker", "compose", "exec", "--user=root", "web", "bash"])


@task
Expand All @@ -118,7 +117,8 @@ def psql(c, command=None):
Connect to the local postgres DB using psql
"""
cmd_list = [
"docker-compose",
"docker",
"compose",
"exec",
"db",
"psql",
Expand Down Expand Up @@ -265,9 +265,7 @@ def dev_shell(c):


def delete_local_database(c, local_database_name=LOCAL_DATABASE_NAME):
local(
"dropdb --if-exists {database_name}".format(database_name=LOCAL_DATABASE_NAME)
)
local(f"dropdb --if-exists {LOCAL_DATABASE_NAME}")


####
Expand Down Expand Up @@ -389,7 +387,7 @@ def open_heroku_shell(c, app_instance, shell_command="bash"):


def make_bold(msg):
return "\033[1m{}\033[0m".format(msg)
return f"\033[1m{msg}\033[0m"


@task
Expand Down Expand Up @@ -439,16 +437,14 @@ def dellar_list(c):
def dellar_remove(c, filename):
"""Remove database snapshots"""
dexec(
"rm {filename}.psql".format(filename=filename),
f"rm {filename}.psql",
service="db",
),
print(f"Snapshot {filename} removed")


def get_heroku_variable(c, app_instance, variable):
return local(
"heroku config:get {var} --app {app}".format(app=app_instance, var=variable)
).stdout.strip()
return local(f"heroku config:get {variable} --app {app_instance}").stdout.strip()


@task
Expand All @@ -458,7 +454,8 @@ def run_test(c):
"""
subprocess.call(
[
"docker-compose",
"docker",
"compose",
"exec",
"web",
"python",
Expand All @@ -475,4 +472,6 @@ def migrate(c):
"""
Run database migrations
"""
subprocess.run(["docker-compose", "run", "--rm", "web", "./manage.py", "migrate"])
subprocess.run(
["docker", "compose", "run", "--rm", "web", "./manage.py", "migrate"]
)
Loading

0 comments on commit e8288e6

Please sign in to comment.