Skip to content
Draft
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
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ repos:
rev: v2.2.4
hooks:
- id: codespell

- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.18.1
hooks:
- id: markdownlint-cli2
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ It takes care of:

Run `otools-release release --help` to know more about the options.


### otools-addon

NOTE: this tool is meant to be used mostly for future project versions
Expand Down
4 changes: 2 additions & 2 deletions Releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ Run
git push --tags && git push
python3 -m build


then create a release on https://github.com/camptocamp/odoo-project-tools/releases and upload the wheel you will find in the [dist](dist/) directory to the release.
Then [create a release](https://github.com/camptocamp/odoo-project-tools/releases)
and upload the wheel you will find in the [dist](dist/) directory to the release.
68 changes: 46 additions & 22 deletions docs/otools-ba.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# otools-ba

`otools-ba` is a part of the odoo project tools set designed to to help non technical persons manage the complexity of some of the tricky command lines that are needed to work with our odoo projects.
`otools-ba` is a part of the odoo project tools set designed to to help non
technical persons manage the complexity of some of the tricky command lines
that are needed to work with our odoo projects.

Please report issues and feature requests on https://github.com/camptocamp/odoo-project-tools/issues
Please report issues and feature requests on
[the Issues page](https://github.com/camptocamp/odoo-project-tools/issues)

## Installing

`otools-ba` is installed together with the rest of odoo-project-tools. The easiest way is to use pipx as an installer. If that command is not available on your laptop, you can run:
`otools-ba` is installed together with the rest of odoo-project-tools. The
easiest way is to use pipx as an installer. If that command is not available
on your laptop, you can run:

sudo apt update
sudo apt install pipx git libpq-dev gcc python3-dev
Expand All @@ -17,7 +22,6 @@ Then

pipx install -f git+https://github.com/camptocamp/odoo-project-tools.git


Run a quick test:

otools-ba --help
Expand All @@ -32,7 +36,6 @@ This should print a help summary such as:
Commands:
run Run a standard odoo version locally, for a customer demo or...


If you get an error message such as:

otools-ba: command not found
Expand All @@ -41,23 +44,27 @@ Then you need to perform a simple operation to fix the configuration:

echo -e '\nexport PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc


Then logout of your session and reauthenticate for the configuration to be taken into account.

Then logout of your session and reauthenticate for the configuration to be
taken into account.

## Docker configuration

Some of the commands are going to use docker images, and these are often on private repositories, so you need to be authenticated to access them.
Some of the commands are going to use docker images, and these are often on
private repositories, so you need to be authenticated to access them.

To test if this configuration has been done already, you can run the following command:
To test if this configuration has been done already, you can run the following
command:

docker pull ghcr.io/camptocamp/odoo-enterprise:18.0-latest

If the download starts, you're good. If you get an error message saying "unauthorized" then you need to perform the following steps:
If the download starts, you're good. If you get an error message saying
"unauthorized" then you need to perform the following steps:

1. Open your [lastpass vault](https://lastpass.com/vault/), and search for "Read only token to access docker images on ghcr.io"
1. Open your [lastpass vault](https://lastpass.com/vault/), and search for
"Read only token to access docker images on ghcr.io"

2. Open the entry, it should feature an expiration date. If that date is in the past, ask on slack to get a new token generated.
2. Open the entry, it should feature an expiration date. If that date is in the
past, ask on slack to get a new token generated.

3. Run the commands which are in the note, which should look like:

Expand All @@ -74,35 +81,52 @@ which should now work.
## Commands


There are (or will be) different commands available. You can get a list of all the commands by running in a shell:
There are (or will be) different commands available. You can get a list of all
the commands by running in a shell:

odools-ba --help

For a given command, using `otools-ba commandname --help` will give you a short summary.
For a given command, using `otools-ba commandname --help` will give you a
short summary.


### otools-ba run

The first command available is `otools-ba run`. That command can be used to start an Odoo Enterprise version with version starting from 14.0 to the latest stable release.
The first command available is `otools-ba run`. That command can be used to start
an Odoo Enterprise version with version starting from 14.0 to the latest stable
release.

The simplest way to use it is to pass the version number on the command line. So to start Odoo 18.0 you can run:
The simplest way to use it is to pass the version number on the command line.
So to start Odoo 18.0 you can run:

otools-ba run 18.0

This will download a docker image for the specified version (depending on the speed of your connection, this can take a few minutes the first time), and then start the instance, and when the instance is ready, launch a web browser connected to the instance.
This will download a docker image for the specified version (depending on the
speed of your connection, this can take a few minutes the first time), and then
start the instance, and when the instance is ready, launch a web browser connected
to the instance.

When you are done, you can shut down the instance by typing `Ctrl-c` in the terminal from which you started `otools-ba`. This will terminate the Odoo. The database is kept on your laptop. If you restart the same version, you will get the data you configured back again.
When you are done, you can shut down the instance by typing `Ctrl-c` in the
terminal from which you started `otools-ba`. This will terminate the Odoo.
The database is kept on your laptop. If you restart the same version, you will
get the data you configured back again.

If you want to start with a fresh empty database, you can pass the `--empty-db` option:
If you want to start with a fresh empty database, you can pass the `--empty-db`
option:

otools-ba run --empty-db 18.0

This will drop any previously existing database for 18.0 and create a new one.

If you want to work on two versions in parallel, to compare them, you will need to use a custom port on one of the instances. The default port is `8080`, but you can set a different one with the `--port` option, like this:
If you want to work on two versions in parallel, to compare them, you will
need to use a custom port on one of the instances. The default port is `8080`,
but you can set a different one with the `--port` option, like this:

otools-ba run --port 8081 18.0

As a final note, the images used are updated on a regular basis with the latest version of the source code of Odoo. In order to preserve bandwidth, `otools-ba run` will reuse an image it has already downloaded. If you want to refresh the image, you can use the `--force-image-pull` option:
As a final note, the images used are updated on a regular basis with the
latest version of the source code of Odoo. In order to preserve bandwidth,
`otools-ba run` will reuse an image it has already downloaded. If you want
to refresh the image, you can use the `--force-image-pull` option:

otools-ba run --force-image-pull 18.0
73 changes: 52 additions & 21 deletions docs/otools-pr.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# otools-pr

`otools-pr` is a helper tool for testing pull requests, hiding some of the tricky command line commands.
`otools-pr` is a helper tool for testing pull requests, hiding some of the tricky
command line commands.


## Installing
Expand All @@ -15,7 +16,8 @@ You will need to have git installed and configured on your workstation:

sudo apt install git

Normally, the setup should have been taken care of during your onboarding. If not check with your mentor to get this fixed before you go on.
Normally, the setup should have been taken care of during your onboarding. If
not check with your mentor to get this fixed before you go on.

To check if this setup was done you can run:

Expand All @@ -25,27 +27,35 @@ If everything goes well, you can clean up the created directory:

rm -rf celebrimbor-cli

However, if you have an error message saying you don't have permission, then there are some parts of the configuration of your workstation that is missing. This is beyond this document's scope, get in touch with the helpdesk for assistance.
However, if you have an error message saying you don't have permission, then
there are some parts of the configuration of your workstation that is missing.
This is beyond this document's scope, get in touch with the helpdesk for
assistance.

### Celebrimbor

You need to be able to download a database dump of the project to your laptop. This is done with the `celebrimbor_cli` command line utility. If it is not installed, you can run:
You need to be able to download a database dump of the project to your laptop.
This is done with the `celebrimbor_cli` command line utility. If it is not
installed, you can run:

mkdir -p ~/.config/celebrimbor-cli
pipx install -f git+ssh://git@github.com/camptocamp/celebrimbor-cli#egg=celebrimbor_cli
pipx install -f git+ssh://git@github.com/camptocamp/celebrimbor-cli


Open your [lastpass vault](https://lastpass.com/vault/), look for "Celebrimbor CLI configuration parameters". In a shell, type:
Open your [lastpass vault](https://lastpass.com/vault/), look for
"Celebrimbor CLI configuration parameters". In a shell, type:

gnome-text-editor ~/.config/celebrimbor-cli/platforms.conf

Then in the window that opens, copy paste the content of the note, save and exit the text editor.
Then in the window that opens, copy paste the content of the note, save and
exit the text editor.



### Git autoshare

If you start working a lot with projects, having git autoshare installed and configured will save you a tremendous amount of time.
If you start working a lot with projects, having git autoshare installed and
configured will save you a tremendous amount of time.

pipx install git-autoshare
if [ ! -e ~/.config/git-autoshare/repos.yml ]
Expand Down Expand Up @@ -73,14 +83,16 @@ If you start working a lot with projects, having git autoshare installed and con

We are almost there!

First get the source code of the project of your customer. Different things depend on the name of the customer, so you can create a variable to help you in copy-pasting the commands:
First get the source code of the project of your customer. Different things
depend on the name of the customer, so you can create a variable to help you in
copy-pasting the commands:

export CUSTOMER=customername

Then:

cd work/projects
git clone git@github.com:camptocamp/${CUSTOMER}_odoo # change this with the real name
git clone git@github.com:camptocamp/${CUSTOMER}_odoo
cd ${CUSTOMER}_odoo
otools-submodule update
docker compose build odoo
Expand All @@ -89,55 +101,74 @@ Then:

### Getting a database dump

Then download a database dump of the project. The command depends on the platform (CH or FR) of your project.
Then download a database dump of the project. The command depends on the platform
(CH or FR) of your project.

**⚠️ Important**

Most of the time, the name of the customer on the hosting platform and on the github project are the same, but not always. In the commands below, we use the same variable `CUSTOMER` for the name of the project on the platform as in the name of the project. If you get errors, it can be because the names are different. Ask a dev in your team, they will be able to help.
Most of the time, the name of the customer on the hosting platform and on the
github project are the same, but not always. In the commands below, we use the
same variable `CUSTOMER` for the name of the project on the platform as in the
name of the project. If you get errors, it can be because the names are
different. Ask a dev in your team, they will be able to help.


For the Swiss platform:


celebrimbor_cli -p ch download -e prod -c ${CUSTOMER} # change with the real name
celebrimbor_cli -p ch download -e prod -c ${CUSTOMER}

For the French platform:

celebrimbor_cli -p fr download -e prod -c ${CUSTOMER} # change with the real name
celebrimbor_cli -p fr download -e prod -c ${CUSTOMER}

This will, after some time, get you a file. To get the name of the file, use:

ls -rt *.pg | tail -1

### Testing the pull request

The developers have made a pull request, which is at https://github.com/camptocamp/customername_odoo/pull/1234 The important for is the number of the PR, here "1234". If you want to test the PR using the dump you just downloaded, you can run:
The developers have made a pull request, which is at
`https://github.com/camptocamp/customername_odoo/pull/1234` The important part is
the number of the PR, here "1234". If you want to test the PR using the dump
you just downloaded, you can run:

otools-pr test --database-dump nameofthedump.pg 1234

Then you can point your browser to http://localhost:8069/web and start testing.
Then you can point your browser to (http://localhost:8069/web)[http://localhost:8069/web]
and start testing.

### Special cases: large databases

If the database dump is large, and restoring it takes ages, and you need to restart your test from scratch multiple time and waiting is driving you crazy, you can use this trick. On the first time, run:
If the database dump is large, and restoring it takes ages, and you need to
restart your test from scratch multiple time and waiting is driving you crazy,
you can use this trick. On the first time, run:

otools-pr test --create-template --database-dump nameofthedump.pg 1234

This will create a "template database" and clone it for you to run your tests. Then if you want to start again with the same dump, just run:
This will create a "template database" and clone it for you to run your tests.
Then if you want to start again with the same dump, just run:

otools-pr test 1234

The tool will find the template and use it to recreate the test database.

This cannot be used for enormous database because it doubles the disk usage. Yes you know which project I mean;
This cannot be used for enormous database because it doubles the disk usage.
Yes you know which project I mean.

### Special cases: migrations

When a customer project is under migration, the `master` branch of the project will be used for the production, but you will want to test a Pull Request targeting a different branch. Check with the dev team what the name of the migration branch is. Let's assume it is `mig-18.0` for the example below. You will need to use the `--base-branch` option to pass the name of the migration branch:
When a customer project is under migration, the `master` branch of the project
will be used for the production, but you will want to test a Pull Request
targeting a different branch. Check with the dev team what the name of the
migration branch is. Let's assume it is `mig-18.0` for the example below. You
will need to use the `--base-branch` option to pass the name of the migration
branch:

otools-pr test --base-branch mig-18.0 --database-dump nameofthedump.pg 1234

(of course you will also need to use a database dump from the migration lab or the integration, not from the production).
(of course you will also need to use a database dump from the migration lab
or the integration, not from the production).

## Cleaning up

Expand Down
Loading