Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify dev/test cycle #71

Merged
merged 7 commits into from
Mar 17, 2024
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
45 changes: 45 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
"name": "Existing Docker Compose (Extend)",

// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": [
"../tests/docker-compose.yml",
"docker-compose.yml",
],

// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "test",

// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/mnt/oca-ci",

"remoteEnv": {
"PATH": "/mnt/oca-ci/bin:${containerEnv:PATH}",
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],

// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
3 changes: 3 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
services:
test:
command: [sleep, infinity]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ Tune it to your liking, then run:

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

This docker-compose mounts this project, and `runtests.sh` adds then `bin` directory to
the `PATH` for easier dev/test iteration.

There is also a devcontainer configuration.
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
testpaths =
tests
addopts = --ignore=tests/data
19 changes: 10 additions & 9 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
services:
test:
build:
context: ..
args:
codename: jammy
python_version: "3.10"
odoo_version: "16.0"
image: ghcr.io/oca/oca-ci/py3.10-ocb16.0:latest
# build:
# context: ..
# args:
# codename: jammy
# python_version: "3.10"
# odoo_version: "16.0"
volumes:
- .:/mnt/tests
working_dir: /mnt/tests
- ..:/mnt/oca-ci
working_dir: /mnt/oca-ci/tests
depends_on:
- postgres
postgres:
image: postgres
environment:
POSTGRES_USER: odoo
POSTGRES_PASSWORD: odoo
POSTGRES_DB: odoo
POSTGRES_DB: odoo
2 changes: 2 additions & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# test requirements
pytest
7 changes: 5 additions & 2 deletions tests/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ set -e
# which is assumed to be mounted somewhere in the docker image.

here=$(dirname $0)
testvenv=/tmp/testvenv

testvenv=/tmp/testvenv
/usr/bin/python3 -m venv $testvenv
$testvenv/bin/pip install pytest
$testvenv/bin/pip install -r $here/requirements.txt

export PATH=$here/../bin:$PATH

$testvenv/bin/pytest --color=yes --ignore $here/data $here "$@"
Loading