Skip to content

Commit e78d8e1

Browse files
authored
Merge pull request #71 from sbidoul/imp-test-cycle
Simplify dev/test cycle
2 parents f280264 + 1c97f13 commit e78d8e1

7 files changed

+73
-11
lines changed

.devcontainer/devcontainer.json

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
3+
{
4+
"name": "Existing Docker Compose (Extend)",
5+
6+
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
7+
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
8+
"dockerComposeFile": [
9+
"../tests/docker-compose.yml",
10+
"docker-compose.yml",
11+
],
12+
13+
// The 'service' property is the name of the service for the container that VS Code should
14+
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
15+
"service": "test",
16+
17+
// The optional 'workspaceFolder' property is the path VS Code should open by default when
18+
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
19+
"workspaceFolder": "/mnt/oca-ci",
20+
21+
"remoteEnv": {
22+
"PATH": "/mnt/oca-ci/bin:${containerEnv:PATH}",
23+
},
24+
25+
// Features to add to the dev container. More info: https://containers.dev/features.
26+
// "features": {},
27+
28+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
29+
// "forwardPorts": [],
30+
31+
// Uncomment the next line if you want start specific services in your Docker Compose config.
32+
// "runServices": [],
33+
34+
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
35+
// "shutdownAction": "none",
36+
37+
// Uncomment the next line to run commands after the container is created.
38+
// "postCreateCommand": "cat /etc/os-release",
39+
40+
// Configure tool-specific properties.
41+
// "customizations": {},
42+
43+
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
44+
// "remoteUser": "devcontainer"
45+
}

.devcontainer/docker-compose.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
services:
2+
test:
3+
command: [sleep, infinity]

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,7 @@ Tune it to your liking, then run:
7575

7676
`docker compose run --build test ./runtests.sh -v`
7777

78+
This docker-compose mounts this project, and `runtests.sh` adds then `bin` directory to
79+
the `PATH` for easier dev/test iteration.
80+
81+
There is also a devcontainer configuration.

pytest.ini

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[pytest]
2+
testpaths =
3+
tests
4+
addopts = --ignore=tests/data

tests/docker-compose.yml

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
services:
22
test:
3-
build:
4-
context: ..
5-
args:
6-
codename: jammy
7-
python_version: "3.10"
8-
odoo_version: "16.0"
3+
image: ghcr.io/oca/oca-ci/py3.10-ocb16.0:latest
4+
# build:
5+
# context: ..
6+
# args:
7+
# codename: jammy
8+
# python_version: "3.10"
9+
# odoo_version: "16.0"
910
volumes:
10-
- .:/mnt/tests
11-
working_dir: /mnt/tests
11+
- ..:/mnt/oca-ci
12+
working_dir: /mnt/oca-ci/tests
1213
depends_on:
1314
- postgres
1415
postgres:
1516
image: postgres
1617
environment:
1718
POSTGRES_USER: odoo
1819
POSTGRES_PASSWORD: odoo
19-
POSTGRES_DB: odoo
20+
POSTGRES_DB: odoo

tests/requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# test requirements
2+
pytest

tests/runtests.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ set -e
66
# which is assumed to be mounted somewhere in the docker image.
77

88
here=$(dirname $0)
9-
testvenv=/tmp/testvenv
109

10+
testvenv=/tmp/testvenv
1111
/usr/bin/python3 -m venv $testvenv
12-
$testvenv/bin/pip install pytest
12+
$testvenv/bin/pip install -r $here/requirements.txt
13+
14+
export PATH=$here/../bin:$PATH
15+
1316
$testvenv/bin/pytest --color=yes --ignore $here/data $here "$@"

0 commit comments

Comments
 (0)