Connect code repository¶
o‑o works with Git repositories, transparently copying code before run execution, so you can easily run commands with your own source code.
Example Python code¶
To demonstrate using o‑o with a Git repository, create the following
simple Python source file, print.py
Then initialize a new Git repository, add print.py, and commit
Now configure o‑o to use the source code in this repository by adding
sourcecode: true to our .ooconfig file. Since this is Python code, we also
add a new environment (my-python-env) with Python installed:
project: test-project
sourcecode: true
environments:
- name: my-simple-env
provider: Scaleway
image: docker.io/debian:stable-slim
machinetype: STARDUST1-S
region: fr-par-1
default: true
- name: my-python-env
provider: Scaleway
image: docker.io/python:3-slim
machinetype: STARDUST1-S
region: fr-par-1
datastores:
- name: my-datastore
provider: Scaleway
bucket: o-o-data
region: fr-par
default: true
project: test-project
sourcecode: true
environments:
- name: my-simple-env
provider: gcp
image: docker.io/debian:stable-slim
machinetype: e2-highcpu-2
region: northamerica-northeast1-b
default: true
- name: my-python-env
provider: gcp
image: docker.io/python:3-slim
machinetype: e2-highcpu-2
region: northamerica-northeast1-b
datastores:
- name: my-datastore
provider: gcp
bucket: o-o-data
default: true
Now run the checked in code with the new Python environment:
o‑o copied the current commit to our Python environment and ran the given command. Nice! Let's go a bit further and make changes to our source code
We can now re-run the script with our new changes. You can commit your changes,
but it isn't necessary at this stage. As a convenience, add the --dirty flag
and your uncommitted working tree changes are copied to the environment.
$ o-o run --dirty --environment my-python-env --message "second example" -- \
python print.py Hello!
Message: Hello!
Show code changes¶
By connecting a repository to your o‑o runs, the source used for the
run is versioned and stored in your configured datastore. The o-o diff command
will show differences in the code between runs. For example, if we take the two runs
from above
We can see the code changes that occurred between these runs