Skip to content

Commit 67fe877

Browse files
authored
MPT-16714 Update docker-compose and use make (#182)
2 parents ca4fb9a + 2520b77 commit 67fe877

File tree

9 files changed

+84
-63
lines changed

9 files changed

+84
-63
lines changed

.github/workflows/cron-main-e2e.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,24 @@ jobs:
1414
ref: main
1515

1616
- name: "Build test containers"
17-
run: docker compose build e2e
17+
run: make build
1818

1919
- name: "Create environment file"
2020
run: env | grep -E '^MPT_' > .env
2121
env:
22-
RP_ENDPOINT: ${{ secrets.RP_ENDPOINT }}
23-
RP_API_KEY: ${{ secrets.RP_API_KEY }}
2422
MPT_API_BASE_URL: ${{ secrets.MPT_API_BASE_URL }}
2523
MPT_API_TOKEN: ${{ secrets.MPT_API_TOKEN }}
2624
MPT_API_TOKEN_CLIENT: ${{ secrets.MPT_API_TOKEN_CLIENT }}
2725
MPT_API_TOKEN_OPERATIONS: ${{ secrets.MPT_API_TOKEN_OPERATIONS }}
2826
MPT_API_TOKEN_VENDOR: ${{ secrets.MPT_API_TOKEN_VENDOR }}
2927

3028
- name: "Run E2E test"
31-
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"
29+
run: make e2e args="--reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT"
3230
env:
3331
RP_LAUNCH: github-e2e-cron-${{ github.ref_name }}
3432
RP_ENDPOINT: ${{ secrets.RP_ENDPOINT }}
3533
RP_API_KEY: ${{ secrets.RP_API_KEY }}
3634

3735
- name: "Stop containers"
3836
if: always()
39-
run: docker compose down
37+
run: make down

.github/workflows/pull-request.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fetch-depth: 0
2121

2222
- name: "Build test containers"
23-
run: docker compose build app_test e2e
23+
run: make build
2424

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

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

3939
# - name: "Run E2E test"
40-
# 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"
40+
# run: make e2e args="--reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT"
4141
# env:
4242
# RP_LAUNCH: github-e2e-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_number }}
4343
# RP_ENDPOINT: ${{ secrets.RP_ENDPOINT }}
4444
# RP_API_KEY: ${{ secrets.RP_API_KEY }}
4545

46-
4746
- name: "Run SonarCloud Scan"
4847
uses: SonarSource/sonarqube-scan-action@master
4948
env:
@@ -52,4 +51,4 @@ jobs:
5251

5352
- name: "Stop containers"
5453
if: always()
55-
run: docker compose down
54+
run: make down

.github/workflows/push-release-branch.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fetch-depth: 0
2323

2424
- name: "Build test containers"
25-
run: docker compose build app_test e2e
25+
run: make build
2626

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

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

4141
- name: "Run E2E test"
42-
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"
42+
run: make e2e args="--reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT"
4343
env:
4444
RP_LAUNCH: github-e2e-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_number }}
4545
RP_ENDPOINT: ${{ secrets.RP_ENDPOINT }}
4646
RP_API_KEY: ${{ secrets.RP_API_KEY }}
4747

48-
4948
- name: "Run SonarCloud Scan"
5049
uses: SonarSource/sonarqube-scan-action@master
5150
env:
@@ -54,4 +53,4 @@ jobs:
5453

5554
- name: "Stop containers"
5655
if: always()
57-
run: docker compose down
56+
run: make down

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
fetch-depth: 0
2222

2323
- name: "Build test containers"
24-
run: docker compose build e2e
24+
run: make build
2525

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

3737
- name: "Run E2E test"
38-
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"
38+
run: make e2e args="--reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT"
3939
env:
40-
RP_LAUNCH: github-e2e-cron-main
40+
RP_LAUNCH: github-e2e-release-${{ github.ref_name }}
4141
RP_ENDPOINT: ${{ secrets.RP_ENDPOINT }}
4242
RP_API_KEY: ${{ secrets.RP_API_KEY }}
4343

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
1+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS base
22

3-
COPY . /mpt_api_client
4-
WORKDIR /mpt_api_client
3+
WORKDIR /extension
54

65
RUN uv venv /opt/venv
76

87
ENV VIRTUAL_ENV=/opt/venv
98
ENV PATH=/opt/venv/bin:$PATH
109

10+
FROM base AS build
11+
12+
COPY . /extension
13+
1114
RUN uv sync --frozen --no-cache --all-groups --active
1215

16+
FROM build AS dev
17+
1318
CMD ["bash"]

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,13 @@ uv add -r requirements.txt
5353
Run all validations with:
5454

5555
```bash
56-
docker compose run --rm app_test
56+
make test-all
5757
```
5858

5959
Run pytest with:
6060

6161
```bash
62-
pytest tests/unit
63-
pytest tests/e2e
64-
pytest tests/seed
62+
make test-all
6563
```
6664
## License
6765

compose.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
services:
2+
app:
3+
container_name: mtp_api_client
4+
build:
5+
context: .
6+
target: dev
7+
dockerfile: Dockerfile
8+
working_dir: /mpt_api_client
9+
volumes:
10+
- .:/mpt_api_client
11+
env_file:
12+
- .env

docker-compose.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

makefile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.PHONY: bash build check check-all down format review test help
2+
3+
DC = docker compose -f compose.yaml
4+
5+
help:
6+
@echo "Available commands:"
7+
@echo " make bash - Open a bash shell in the app container."
8+
@echo " make build - Build images."
9+
@echo " make check - Check code quality with ruff."
10+
@echo " make check-all - Run check and tests."
11+
@echo " make down - Stop and remove containers."
12+
@echo " make e2e - Run e2e test."
13+
@echo " make format - Format code."
14+
@echo " make review - Check the code in the cli by running CodeRabbit."
15+
@echo " make test - Run tests."
16+
@echo " make help - Display this help message."
17+
18+
bash:
19+
$(DC) run --rm -it app bash
20+
21+
build:
22+
$(DC) build
23+
24+
check:
25+
$(DC) run --rm app bash -c "ruff format --check . && ruff check . && flake8 . && mypy . && uv lock --check"
26+
27+
check-all:
28+
make check
29+
make test
30+
31+
down:
32+
$(DC) down
33+
34+
format:
35+
$(DC) run --rm app bash -c "ruff check --select I --fix . && ruff format ."
36+
37+
review:
38+
coderabbit review --prompt-only
39+
40+
test:
41+
$(DC) run --rm app pytest $(args) tests/unit
42+
43+
test-all:
44+
make test
45+
make e2e
46+
47+
e2e:
48+
$(DC) run --rm app pytest -p no:randomly --junitxml=e2e-report.xml $(args) tests/e2e

0 commit comments

Comments
 (0)