Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/cron-main-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,24 @@ jobs:
ref: main

- name: "Build test containers"
run: docker compose build e2e
run: make build

- name: "Create environment file"
run: env | grep -E '^MPT_' > .env
env:
RP_ENDPOINT: ${{ secrets.RP_ENDPOINT }}
RP_API_KEY: ${{ secrets.RP_API_KEY }}
MPT_API_BASE_URL: ${{ secrets.MPT_API_BASE_URL }}
MPT_API_TOKEN: ${{ secrets.MPT_API_TOKEN }}
MPT_API_TOKEN_CLIENT: ${{ secrets.MPT_API_TOKEN_CLIENT }}
MPT_API_TOKEN_OPERATIONS: ${{ secrets.MPT_API_TOKEN_OPERATIONS }}
MPT_API_TOKEN_VENDOR: ${{ secrets.MPT_API_TOKEN_VENDOR }}

- name: "Run E2E test"
run: docker compose run --service-ports e2e bash -c "pytest -v -p no:randomly --no-cov --reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT --junitxml=e2e-report.xml tests/e2e"
run: make e2e args="--reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT"
env:
RP_LAUNCH: github-e2e-cron-${{ github.ref_name }}
RP_ENDPOINT: ${{ secrets.RP_ENDPOINT }}
RP_API_KEY: ${{ secrets.RP_API_KEY }}

- name: "Stop containers"
if: always()
run: docker compose down
run: make down
9 changes: 4 additions & 5 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fetch-depth: 0

- name: "Build test containers"
run: docker compose build app_test e2e
run: make build

- name: "Create environment file"
run: env | grep -E '^MPT_' > .env
Expand All @@ -34,16 +34,15 @@ jobs:
MPT_API_TOKEN_VENDOR: ${{ secrets.MPT_API_TOKEN_VENDOR }}

- name: "Run validation & test"
run: docker compose run --service-ports app_test
run: make check-all

# - name: "Run E2E test"
# run: docker compose run --service-ports e2e bash -c "pytest -v -p no:randomly --no-cov --reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT --junitxml=e2e-report.xml tests/e2e"
# run: make e2e args="--reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT"
# env:
# RP_LAUNCH: github-e2e-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_number }}
# RP_ENDPOINT: ${{ secrets.RP_ENDPOINT }}
# RP_API_KEY: ${{ secrets.RP_API_KEY }}


- name: "Run SonarCloud Scan"
uses: SonarSource/sonarqube-scan-action@master
env:
Expand All @@ -52,4 +51,4 @@ jobs:

- name: "Stop containers"
if: always()
run: docker compose down
run: make down
9 changes: 4 additions & 5 deletions .github/workflows/push-release-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fetch-depth: 0

- name: "Build test containers"
run: docker compose build app_test e2e
run: make build

- name: "Create environment file"
run: env | grep -E '^MPT_' > .env
Expand All @@ -36,16 +36,15 @@ jobs:
MPT_API_TOKEN_VENDOR: ${{ secrets.MPT_API_TOKEN_VENDOR }}

- name: "Run validation & test"
run: docker compose run --service-ports app_test
run: make check-all

- name: "Run E2E test"
run: docker compose run --service-ports e2e bash -c "pytest -v -p no:randomly --no-cov --reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT --junitxml=e2e-report.xml tests/e2e"
run: make e2e args="--reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT"
env:
RP_LAUNCH: github-e2e-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_number }}
RP_ENDPOINT: ${{ secrets.RP_ENDPOINT }}
RP_API_KEY: ${{ secrets.RP_API_KEY }}


- name: "Run SonarCloud Scan"
uses: SonarSource/sonarqube-scan-action@master
env:
Expand All @@ -54,4 +53,4 @@ jobs:

- name: "Stop containers"
if: always()
run: docker compose down
run: make down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fetch-depth: 0

- name: "Build test containers"
run: docker compose build e2e
run: make build

- name: "Create environment file"
run: env | grep -E '^MPT_' > .env
Expand All @@ -35,9 +35,9 @@ jobs:
MPT_API_TOKEN_VENDOR: ${{ secrets.MPT_API_TOKEN_VENDOR }}

- name: "Run E2E test"
run: docker compose run --service-ports e2e bash -c "pytest -v -p no:randomly --no-cov --reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT --junitxml=e2e-report.xml tests/e2e"
run: make e2e args="--reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT"
env:
RP_LAUNCH: github-e2e-cron-main
RP_LAUNCH: github-e2e-release-${{ github.ref_name }}
RP_ENDPOINT: ${{ secrets.RP_ENDPOINT }}
RP_API_KEY: ${{ secrets.RP_API_KEY }}

Expand Down
11 changes: 8 additions & 3 deletions dev.Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS base

COPY . /mpt_api_client
WORKDIR /mpt_api_client
WORKDIR /extension

RUN uv venv /opt/venv

ENV VIRTUAL_ENV=/opt/venv
ENV PATH=/opt/venv/bin:$PATH

FROM base AS build

COPY . /extension

RUN uv sync --frozen --no-cache --all-groups --active
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

The --active flag has no effect in Docker RUN context.

The --active flag requires an active virtual environment (VIRTUAL_ENV set before the command), but in a Docker RUN layer, no venv is active. The flag is effectively a no-op here.

♻️ Proposed fix
-RUN uv sync --frozen --no-cache --all-groups --active
+RUN uv sync --frozen --no-cache --all-groups
🤖 Prompt for AI Agents
In @Dockerfile at line 14, The RUN instruction uses the --active flag which is a
no-op in a Docker RUN layer because no virtualenv is active; update the command
in the Dockerfile (the RUN uv sync --frozen --no-cache --all-groups --active
line) to remove the --active flag, or if you intended to sync into a specific
virtual environment, ensure the VIRTUAL_ENV is exported and the venv is
activated before running uv sync; prefer removing the --active flag for
simplicity in the container build.


FROM build AS dev

CMD ["bash"]
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,13 @@ uv add -r requirements.txt
Run all validations with:

```bash
docker compose run --rm app_test
make test-all
```

Run pytest with:

```bash
pytest tests/unit
pytest tests/e2e
pytest tests/seed
make test-all
```
## License

Expand Down
12 changes: 12 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
app:
container_name: mtp_api_client
build:
context: .
target: dev
dockerfile: Dockerfile
working_dir: /mpt_api_client
volumes:
- .:/mpt_api_client
env_file:
- .env
38 changes: 0 additions & 38 deletions docker-compose.yml

This file was deleted.

48 changes: 48 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.PHONY: bash build check check-all down format review test help

DC = docker compose -f compose.yaml

help:
@echo "Available commands:"
@echo " make bash - Open a bash shell in the app container."
@echo " make build - Build images."
@echo " make check - Check code quality with ruff."
@echo " make check-all - Run check and tests."
@echo " make down - Stop and remove containers."
@echo " make e2e - Run e2e test."
@echo " make format - Format code."
@echo " make review - Check the code in the cli by running CodeRabbit."
@echo " make test - Run tests."
@echo " make help - Display this help message."

bash:
$(DC) run --rm -it app bash

build:
$(DC) build

check:
$(DC) run --rm app bash -c "ruff format --check . && ruff check . && flake8 . && mypy . && uv lock --check"

check-all:
make check
make test

down:
$(DC) down

format:
$(DC) run --rm app bash -c "ruff check --select I --fix . && ruff format ."

review:
coderabbit review --prompt-only

test:
$(DC) run --rm app pytest $(args) tests/unit

test-all:
make test
make e2e

e2e:
$(DC) run --rm app pytest -p no:randomly --junitxml=e2e-report.xml $(args) tests/e2e
Comment on lines +47 to +48
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check all make e2e invocations in workflows with context
rg -n -A2 -B2 'make e2e' .github/workflows/ --type yaml

Repository: softwareone-platform/mpt-api-python-client

Length of output: 1848


Add missing pytest flags to the e2e target or ensure they are passed via workflows.

The e2e target is missing the -v (verbose) and --no-cov (no coverage) flags that should be passed to pytest. None of the workflow files (release.yml, push-release-branch.yml, cron-main-e2e.yml) pass these flags via the args parameter, meaning e2e tests will no longer run with verbose output or coverage collection disabled.

Either add these flags directly to the Makefile target or ensure all workflows pass them via args="...".

🤖 Prompt for AI Agents
In @makefile around lines 47 - 48, The e2e Makefile target currently runs pytest
without the desired -v and --no-cov flags; update the e2e target (the line that
invokes "$(DC) run --rm app pytest -p no:randomly --junitxml=e2e-report.xml
$(args) tests/e2e") to include -v and --no-cov (or alternatively ensure every
workflow sets args to include "-v --no-cov"); modify the pytest invocation so it
always passes -v and --no-cov unless explicitly overridden via $(args).