Skip to content

Commit

Permalink
OBS-144: Migrate from socorro-release to obs-common
Browse files Browse the repository at this point in the history
and from make to just
  • Loading branch information
relud committed Nov 19, 2024
1 parent fdeb4bb commit 64be446
Show file tree
Hide file tree
Showing 8 changed files with 411 additions and 131 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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 @@ -36,22 +39,22 @@ 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
- 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
just lint
- name: Run Eliot tests
run: |
docker compose up -d fakesentry statsd
docker compose run --rm test-ci bash ./bin/run_test.sh eliot
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
101 changes: 0 additions & 101 deletions Makefile

This file was deleted.

23 changes: 15 additions & 8 deletions bin/run_lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,45 @@

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

# Usage: bin/run_lint.sh [--fix]
#
# Runs linting and code fixing.
#
# This should be called from inside a container.

set -e
set -euo pipefail

FILES="bin eliot tests"
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

else
echo ">>> ruff (${PYTHON_VERSION})"
cd /app
ruff check $FILES
ruff format --check $FILES

echo ">>> license check (${PYTHON_VERSION})"
if [[ -d ".git" ]]; then
# If the .git directory exists, we can let license-check.py do
# If the .git directory exists, we can let license-check do
# git ls-files.
python bin/license-check.py
license-check
else
# The .git directory doesn't exist, so run it on all the Python
# files in the tree.
python bin/license-check.py .
license-check .
fi
fi
14 changes: 14 additions & 0 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
# version: '2.4'
services:
base:
volumes:
- .:/app

eliot:
volumes:
- $PWD:/app

test:
volumes:
- $PWD:/app
17 changes: 3 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
version: '2.4'
services:
# Base container is used for development tasks like tests, linting,
# and building docs.
Expand Down Expand Up @@ -27,8 +26,6 @@ services:
links:
- fakesentry
- statsd
volumes:
- $PWD:/app
command: ["eliot"]

# Container specifically for running tests.
Expand All @@ -40,17 +37,7 @@ services:
- docker/config/test.env
links:
- fakesentry
volumes:
- $PWD:/app

test-ci:
extends:
service: base
env_file:
- docker/config/local_dev.env
- docker/config/test.env
links:
- fakesentry
- statsd

devcontainer:
extends:
Expand All @@ -63,6 +50,8 @@ services:
image: eliot-devcontainer
entrypoint: ["sleep", "inf"]
stop_signal: SIGKILL # Doesn't seem to respond to anything else
volumes:
- $PWD:/app

# https://github.com/willkg/kent
fakesentry:
Expand Down
66 changes: 66 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

_default:
@just --list

_env:
#!/usr/bin/env sh
if [ ! -f .env ]; then
echo "Copying docker/config/env-dist to .env..."
cp docker/config/env-dist .env
fi
# Build docker images.
build *args='base fakesentry statsd': _env
docker compose --progress plain build {{args}}

# Run the webapp and services.
run *args='--attach=eliot --attach=fakesentry eliot': _env
docker compose up {{args}}

# Stop service containers.
stop *args:
docker compose stop {{args}}

# Remove service containers and networks.
down *args:
docker compose down {{args}}

# Open a shell in the web image.
shell *args='/bin/bash': _env
docker compose run --rm --entrypoint= eliot {{args}}

# Open a shell in the test container.
test-shell *args='/bin/bash': _env
docker compose run --rm --entrypoint= test {{args}}

# Stop and remove docker containers and artifacts.
clean:
docker compose rm -f

# Run tests.
test *args: _env
docker compose run --rm test bash ./bin/run_test.sh {{args}}

# Generate Sphinx HTML documentation.
docs: _env
docker compose run --rm --no-deps eliot bash make -C docs/ clean
docker compose run --rm --no-deps eliot bash make -C docs/ html

# Lint code, or use --fix to reformat and apply auto-fixes for lint.
lint *args: _env
docker compose run --rm --no-deps eliot bash ./bin/run_lint.sh {{args}}

# Rebuild requirements.txt file after requirements.in changes.
rebuild-reqs *args: _env
docker compose run --rm --no-deps eliot bash pip-compile --generate-hashes --strip-extras {{args}}

# Verify that the requirements file is built by the version of Python that runs in the container.
verify-reqs:
docker compose run --rm --no-deps eliot bash ./bin/run_verify_reqs.sh

# Check how far behind different server environments are from main tip.
service-status *args:
docker compose run --rm --no-deps eliot bash service-status {{args}}
3 changes: 3 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ sphinx-rtd-theme==3.0.2
symbolic==12.12.1
urllib3==2.2.3
werkzeug==3.1.3
# Mozilla obs-team libraries that are published to GAR instead of pypi
--extra-index-url https://us-python.pkg.dev/moz-fx-cavendish-prod/cavendish-prod-python/simple/
obs-common==2024.11.7
Loading

0 comments on commit 64be446

Please sign in to comment.