diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..06cf8ee --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,39 @@ +Reviewer: +Estimate: + +--- + +## Ticket + +Fixes: JIRA_TICKET_LINK + +## Description + +### Goal + +### Changes + +### Future Tasks (optional) + +## How has this been tested? + +## To-do before merge (optional) + +## Checklist + +Fill with `x` for completed. + +- [ ] My code follows the style guidelines of this project +- [ ] I have reviewed my own code to ensure good quality +- [ ] I have tested the functionality of my code to ensure it works as intended +- [ ] I have resolved merge conflicts + +(Delete any items below that are not relevant) +- [ ] I have updated the automated tests +- [ ] I have updated the scripts in `scripts/` +- [ ] I have updated the requirements +- [ ] I have updated the README file +- [ ] I have updated affected documentation +- [ ] I have added a blogpost in Latest Updates +- [ ] I have updated the CI/CD scripts in `.github/workflows/` +- [ ] I have updated the Terraform code diff --git a/.github/workflows/linting.yaml b/.github/workflows/linting.yaml new file mode 100644 index 0000000..8f9330f --- /dev/null +++ b/.github/workflows/linting.yaml @@ -0,0 +1,42 @@ +name: Python Linting +on: + workflow_dispatch: + push: + branches: + - "**" + paths: + - "**.py" + +jobs: + python-lint-check: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.12" + cache: "pip" + cache-dependency-path: | + backend/requirements.txt + requirements-dev.txt + - run: | + python -m pip install --upgrade pip + pip install -r backend/requirements.txt + pip install -r requirements-dev.txt + + - name: Run MyPy + run: | + mypy backend/app + + - name: Run ruff + run: | + ruff check --exclude "backend/migrations" . + + - name: Check code formatting with Black + run: | + cd backend + black --check . diff --git a/.github/workflows/unit_tests.yaml b/.github/workflows/unit_tests.yaml new file mode 100644 index 0000000..b8573fe --- /dev/null +++ b/.github/workflows/unit_tests.yaml @@ -0,0 +1,63 @@ +name: Unit Tests +on: + workflow_dispatch: + push: + branches: + - "**" + paths: + - "**.py" + - ".github/workflows/tests.yaml" +env: + POSTGRES_PASSWORD: postgres-test-pw + POSTGRES_USER: postgres-test-user + POSTGRES_DB: postgres-test-db + REDIS_HOST: redis://redis:6379 +jobs: + container-job: + runs-on: ubuntu-20.04 + container: node:20.7-bullseye + services: + postgres: + image: postgres:16.4 + env: + POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} + POSTGRES_USER: ${{ env.POSTGRES_USER }} + POSTGRES_DB: ${{ env.POSTGRES_DB }} + options: >- + --health-cmd pg_isready + --health-interval 5s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + redis: + image: redis:6.0-alpine + options: >- + --health-cmd "redis-cli ping || exit 1" + --health-interval 5s + --health-timeout 5s + --health-retries 5 + ports: + - 6379:6379 + steps: + - name: install dependencies + run: apt-get update && apt-get install -y lsb-release && apt-get clean all + - name: Check out repository code + uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: "3.12" + - name: Install Python libraries + run: | + python -m pip install -r backend/requirements.txt + python -m pip install -r requirements-dev.txt + - name: Run Unit Tests + env: + PROMETHEUS_MULTIPROC_DIR: /tmp + REDIS_HOST: ${{ env.REDIS_HOST }} + run: | + cd backend + export POSTGRES_HOST=postgres POSTGRES_USER=$POSTGRES_USER \ + POSTGRES_PASSWORD=$POSTGRES_PASSWORD POSTGRES_DB=$POSTGRES_DB \ + python -m alembic upgrade head + python -m pytest -m "not slow" tests