Skip to content

Commit 78d8fa6

Browse files
authored
Merge pull request #28 from softwareone-platform/MPT-17883-add-uv-commands
MPT-17833: add uv commands to makefile
2 parents 1ce2e83 + 0ba385e commit 78d8fa6

File tree

3 files changed

+54
-26
lines changed

3 files changed

+54
-26
lines changed

Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@ FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS base
22

33
WORKDIR /extension
44

5-
RUN uv venv /opt/venv
6-
7-
ENV VIRTUAL_ENV=/opt/venv
8-
ENV PATH=/opt/venv/bin:$PATH
5+
ENV UV_LINK_MODE=copy
6+
ENV PATH=/extension/.venv/bin:$PATH
97

108
FROM base AS build
119

1210
COPY . .
1311

14-
RUN uv sync --frozen --no-cache --all-groups --active
12+
RUN uv sync --frozen --no-cache --no-dev
1513

1614
FROM build AS dev
1715

16+
RUN uv sync --frozen --no-cache --dev
1817

1918
CMD ["swoext", "run"]
2019

2120
FROM build AS prod
2221

2322
RUN groupadd -r appuser && useradd -r -g appuser appuser && \
24-
chown -R appuser:appuser /extension /opt/venv
23+
chown -R appuser:appuser /extension
2524

2625
USER appuser
2726

README.md

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ Playground Extension with the SoftwareONE Marketplace
1414

1515
- Docker and Docker Compose plugin (`docker compose` CLI)
1616
- `make`
17-
- Valid `.env` file
18-
- Adobe credentials and authorizations JSON files in the project root
1917
- [CodeRabbit CLI](https://www.coderabbit.ai/cli) (optional. Used for running review check locally)
2018

2119

@@ -38,45 +36,61 @@ The project uses a modular Makefile structure that organizes commands into logic
3836
You can extend the Makefile with your own custom commands creating a `local.mk` file inside make folder. This file is
3937
automatically ignored by git, so your personal commands won't affect other developers or appear in version control.
4038

41-
## Running tests
4239

43-
Tests run inside Docker using the dev configuration.
40+
### Setup
4441

45-
Run the full test suite:
42+
Follow these steps to set up the development environment:
43+
44+
#### 1. Clone the repository
4645

4746
```bash
48-
make test
47+
git clone <repository-url>
48+
```
49+
```bash
50+
cd swo-extension-playground
4951
```
5052

51-
Pass additional arguments to pytest using the `args` variable:
53+
#### 2. Create environment configuration
54+
55+
Copy the sample environment file and update it with your values:
5256

5357
```bash
54-
make test args="-k test_playground -vv"
55-
make test args="tests/test_steps.py"
58+
cp .env.sample .env
5659
```
5760

58-
## Running the service
61+
Edit the `.env` file with your actual configuration values. See the [Configuration](#configuration) section for details on available variables.
5962

60-
### 1. Configuration files
63+
#### 3. Build the Docker images
6164

62-
In the project root, create and configure the following files.
65+
Build the development environment:
6366

64-
#### Environment files
67+
```bash
68+
make build
69+
```
70+
71+
This will create the Docker images with all required dependencies and the virtualenv.
72+
73+
> **Note on local development without Docker:**
74+
> Docker is the primary development environment, the default setup and Makefile commands are designed to work only with Docker.
75+
> `.venv` is used as the default virtualenv, and the project folder is mounted as a volume in docker-compose.
76+
> If you want to run the project locally (without Docker), use a different virtualenv name to avoid confusion
77+
> (e.g., `.venv_local`, `env/`, `venv`, `ENV/` - it will be ignored from docker and gitignore)
78+
> You can also set the `UV_PROJECT_ENVIRONMENT` in your .env file to point `uv` to your local environment.
79+
80+
#### 4. Verify the setup
6581

66-
Start from the sample file:
82+
Run the test suite to ensure everything is configured correctly:
6783

6884
```bash
69-
cp .env.sample .env
85+
make test
7086
```
7187

72-
Update `.env` with your values. This file is used by all Docker Compose configurations and the `make run` target.
88+
You're now ready to start developing! See [Running the service](#running-the-service) for next steps.
7389

74-
### 2. Running
7590

76-
Run the service against real SoftwareONE Marketplace APIs. It uses `compose.yaml` and reads environment from `.env`.
91+
## Running the service
7792

78-
Ensure:
79-
- `.env` is populated with real endpoints and tokens.
93+
Before running, ensure your `.env` file is populated with real endpoints and tokens.
8094

8195
Start the app:
8296

make/common.mk

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ bash: ## Open a bash shell
77

88
build: ## Build images
99
$(DC) build
10+
$(RUN) uv sync
1011

1112
check: ## Check code quality with ruff
1213
$(RUN) bash -c "ruff format --check . && ruff check . && flake8 . && uv lock --check"
@@ -27,3 +28,17 @@ shell: ## Open Django shell
2728

2829
test: ## Run test
2930
$(RUN) pytest $(if $(args),$(args),.)
31+
32+
uv-add: ## Add a production dependency (pkg=<package_name>)
33+
$(call require,pkg)
34+
$(RUN) bash -c "uv add $(pkg)"
35+
$(MAKE) build
36+
37+
uv-add-dev: ## Add a dev dependency (pkg=<package_name>)
38+
$(call require,pkg)
39+
$(RUN) bash -c "uv add --dev $(pkg)"
40+
$(MAKE) build
41+
42+
uv-upgrade: ## Upgrade all packages or a specific package (use pkg="package_name" to target one)
43+
$(RUN) bash -c "uv lock $(if $(pkg),--upgrade-package $(pkg),--upgrade) && uv sync"
44+
$(MAKE) build

0 commit comments

Comments
 (0)