Refactor Discord bot to use dedicated service with profiles #33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lint and Test | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| ci: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # --- Fast fail-first: lint + format + types (native, no Docker) --- | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: packages/django-app/uv.lock | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: packages/django-app/pyproject.toml | |
| - name: Install Python dependencies | |
| working-directory: ./packages/django-app | |
| run: uv sync --frozen | |
| - name: Check Python formatting (Ruff) | |
| working-directory: ./packages/django-app | |
| run: uv run ruff format --check app | |
| - name: Lint Python code (Ruff) | |
| working-directory: ./packages/django-app | |
| run: uv run ruff check app | |
| - name: Type check (Pyright) | |
| working-directory: ./packages/django-app | |
| run: uv run pyright app | |
| # --- Docker-based: build + migrate + django check + tests --- | |
| - name: Install Just | |
| uses: extractions/setup-just@v2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Copy environment file | |
| working-directory: ./packages/django-app | |
| run: just copy-env | |
| - name: Generate secret key | |
| working-directory: ./packages/django-app | |
| run: | | |
| SECRET_KEY=$(python3 -c 'import secrets, string; chars = string.ascii_letters + string.digits + "!@#$%^&*(-_=+)"; print("".join(secrets.choice(chars) for _ in range(50)))') | |
| sed -i "s|SECRET_KEY_GOES_HERE|${SECRET_KEY}|" .env | |
| sed -i "s|^DISCORD_TOKEN=.*|DISCORD_TOKEN=ci-test-token|" .env | |
| sed -i "s|^PGCRYPTO_KEY=.*|PGCRYPTO_KEY=ci-test-pgcrypto-key-32chars|" .env | |
| - name: Build web image (with GHA layer cache) | |
| uses: docker/bake-action@v5 | |
| with: | |
| workdir: ./packages/django-app | |
| files: docker-compose.yml | |
| targets: web | |
| load: true | |
| set: | | |
| web.tags=oscarr-web:latest | |
| web.cache-from=type=gha | |
| web.cache-to=type=gha,mode=max | |
| - name: Create volumes | |
| working-directory: ./packages/django-app | |
| run: docker volume create --name=oscarr_postgres | |
| - name: Start database | |
| working-directory: ./packages/django-app | |
| run: | | |
| docker compose up -d db | |
| ./bin/wait-for-it.sh localhost:5432 -- echo "db is up" | |
| - name: Run migrations | |
| working-directory: ./packages/django-app | |
| run: just dcp-migrate | |
| - name: Run Django system checks | |
| working-directory: ./packages/django-app | |
| run: ./bin/dcp-django-admin.sh check --deploy | |
| - name: Run tests | |
| working-directory: ./packages/django-app | |
| run: just dcp-run-tests |