Skip to content

Commit

Permalink
bug-1945509: switch from make to just (#3116)
Browse files Browse the repository at this point in the history
This switches from make to just. While doing that, this also fixes a
couple of other things:

1. fixes running the Django webapp using `manage.py runserver` when in a
   local dev environment; I think I broke this in 2023 when I switched
   the container to use Honcho to run the web and disk manager processes
2. removes the test-ci and frontend-ci services and instead uses
   docker-compose.override.yml to add volume mounts

Tecken should work like other crash ingestion services now.
  • Loading branch information
willkg authored Feb 3, 2025
1 parent 7a8ba71 commit dbb176e
Show file tree
Hide file tree
Showing 16 changed files with 181 additions and 222 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Build, test and push a Docker image

on:
Expand All @@ -19,7 +20,10 @@ jobs:
contents: read
deployments: write
id-token: write
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
env:
# Disable docker compose volume mounts in docker-compose.override.yml
COMPOSE_FILE: docker-compose.yml
steps:
- uses: actions/checkout@v4
- name: Get info
Expand All @@ -37,22 +41,24 @@ jobs:
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" > version.json
- name: Output version.json
run: cat version.json
- name: Install just
run: sudo apt-get update && sudo apt-get install -y just
- name: Build Docker images
run: make build
run: |
just build
docker compose images
- name: Verify requirements.txt contains correct dependencies
run: |
docker compose run --rm --no-deps test-ci bash ./bin/run_verify_reqs.sh
just verify-reqs
- name: Run lint check
run: |
make .env
docker compose run --rm --no-deps test-ci bash ./bin/run_lint.sh
docker compose run --rm --no-deps frontend-ci lint
just lint
- name: Run tests
run: |
docker compose run --rm test-ci bash ./bin/run_test.sh
just test
- name: Build docs
run: |
docker compose run --rm --no-deps test-ci bash make -C docs/ html
just docs
- name: Set Docker image tag to "latest" for updates of the main branch
if: github.ref == 'refs/heads/main'
Expand Down
134 changes: 0 additions & 134 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ shift

case ${SERVICE} in
web) ## Run Tecken web service
exec honcho -f /app//Procfile --no-prefix start
exec honcho -f /app/Procfile --no-prefix start
;;
bash) ## Open a bash shell or run something else
if [ -z "$*" ]; then
Expand Down
14 changes: 12 additions & 2 deletions bin/run_lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ FILES="bin tecken smoketests systemtests"
PYTHON_VERSION=$(python --version)


if [[ $1 == "--fix" ]]; then
if [[ "${1:-}" == "--help" ]]; then
echo "Usage: $0 [OPTIONS]"
echo
echo " Lint code"
echo
echo "Options:"
echo " --help Show this message and exit."
echo " --fix Reformat code."

elif [[ $1 == "--fix" ]]; then
echo ">>> ruff fix (${PYTHON_VERSION})"
ruff format $FILES
ruff check --fix $FILES
Expand All @@ -38,5 +47,6 @@ else
license-check .
fi

# NOTE(willkg): linting frontend files is done in another script
# NOTE(willkg): linting frontend files is done in another script because
# it has to run in the frontend container
fi
2 changes: 1 addition & 1 deletion bin/run_web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

export PROCESS_NAME=webapp

if [ "$1" == "--dev" ]; then
if [ "$LOCAL_DEV_ENV" == "true" ]; then
python manage.py migrate --noinput
python manage.py runserver 0.0.0.0:${PORT}

Expand Down
15 changes: 15 additions & 0 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# define volumes in docker-compose.override.yml so that can be ignored in CI
---
services:
base:
volumes:
- .:/app
web:
volumes:
- .:/app
test:
volumes:
- .:/app
frontend:
volumes:
- ./frontend:/app
34 changes: 2 additions & 32 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,8 @@ services:
localstack: *condition_service_healthy
oidcprovider: *condition_service_healthy
statsd: *condition_service_healthy
volumes:
- $PWD:/app
command: ["web", "--dev"]

# Container specifically for running tests.
test-ci:
extends:
service: base
env_file:
- docker/config/local_dev.env
- docker/config/test.env
depends_on:
db: *condition_service_healthy
gcs-emulator: *condition_service_healthy
fakesentry: *condition_service_healthy
redis-cache: *condition_service_healthy
localstack: *condition_service_healthy
oidcprovider: *condition_service_healthy
statsd: *condition_service_healthy
command: ["web"]

# TODO(2024-01-30): This configuration can be simplified using `extends: test-ci` once the fix for
# https://github.com/docker/compose/issues/11413 is available in all relevant environments.
test:
extends:
service: base
Expand All @@ -65,8 +45,6 @@ services:
localstack: *condition_service_healthy
oidcprovider: *condition_service_healthy
statsd: *condition_service_healthy
volumes:
- $PWD:/app

# Dev container https://containers.dev/, e.g. for VS Code
devcontainer:
Expand Down Expand Up @@ -105,25 +83,17 @@ services:
redis-cache: *condition_service_healthy
command: web

# Same as 'frontend' but no volumes or command
frontend-ci:
frontend:
build:
context: .
dockerfile: frontend/Dockerfile
args:
userid: ${USE_UID:-10001}
groupid: ${USE_GID:-10001}

frontend:
extends:
frontend-ci
environment:
- NODE_ENV=development
ports:
- "3000:3000"
- "35729:35729"
volumes:
- $PWD/frontend:/app
command: start

# https://hub.docker.com/_/postgres/
Expand Down
9 changes: 3 additions & 6 deletions docker/config/slick.sh-dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ FAKETOKEN="c7c1f8cab79545b6a06bc4122f0eb3cb"
FAKETOKEN_TRY="ebc447f574924b099e1be15527b62436"

# Build Tecken
make build

# Start services
docker compose up -d --remove-orphans db redis-cache statsd localstack oidcprovider fakesentry
just build

# Run setup
make setup
just setup

# Set up user
docker compose exec oidcprovider /code/manage.py createuser "${FAKEUSERNAME}" "${FAKEPASSWORD}" "${FAKEEMAIL}"
Expand All @@ -39,4 +36,4 @@ docker compose run --rm web bash python manage.py createtoken "--try-upload" "${
curl -X POST http://localhost:8090/api/flush/

# Reset Redis
make clear-cache
just clear-cache
Loading

0 comments on commit dbb176e

Please sign in to comment.