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

[WIP] Autogenerate repos.yaml for missing addons #86

Merged
merged 2 commits into from
Sep 14, 2018
Merged

[WIP] Autogenerate repos.yaml for missing addons #86

merged 2 commits into from
Sep 14, 2018

Conversation

PCatinean
Copy link
Contributor

…r automatic dependency resolution

if len(parts) > 2:
branch = parts[2]
else:
branch = os.environ.get('VERSION', '10.0')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This env var is called ODOO_VERSION, and you should not default to any value. It is considered an error if it is not available. Just use brackets and let the proper KeyError bubble up if it ever happens.


# Method from maintainer-quality-tools
def parse_depfile(depfile, owner='OCA'):
deps = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a set, to avoid possible duplicates.


def process_dependencies(dep_list):
for dep in dep_list:
if dep in processed_dependencies:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declare this in the method?

return True

addons_yaml = yaml.load(open('%s/addons.yaml' % CUSTOM_DIR, 'r'))
repos_yaml = yaml.load(open('%s/repos.yaml' % CUSTOM_DIR, 'r'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get these from odoobaselib

addons_yaml = yaml.load(open('%s/addons.yaml' % CUSTOM_DIR, 'r'))
repos_yaml = yaml.load(open('%s/repos.yaml' % CUSTOM_DIR, 'r'))

branch = os.environ.get('VERSION', '10.0')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, no .get!


branch = os.environ.get('VERSION', '10.0')
processed_dependencies = set()
base_url = 'https://raw.githubusercontent.com/OCA'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a constant at the top of the file

base_url = 'https://raw.githubusercontent.com/OCA'

# Find all dependency files after initial aggregation
dep_files = glob.glob('%s/**/oca_dependencies.txt' % CUSTOM_DIR)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use iglob

process_dependencies(initial_dependencies)

auto_addons_yaml = open('%s/addons.yaml' % ADDONS_DIR, 'w')
auto_repos_yaml = open('%s/repos.yaml' % ADDONS_DIR, 'w')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declare these at odoobaselib

'target': {'origin': '$ODOO_VERSION'},
'merges': [{'origin': '$ODOO_VERSION'}],
}
repos_yaml[dep[0]] = {'./%s' % dep[0]: repo_vals}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the ./ please

@yajo yajo force-pushed the master branch 7 times, most recently from 635050e to e88faa0 Compare October 5, 2017 07:20
Copy link
Contributor

@lasley lasley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM outside of @yajo comments

@PCatinean PCatinean changed the title [WIP - skip ci] Translating oca_dependencies to addons/repos .yaml fo… [WIP] Translating oca_dependencies to addons/repos .yaml fo… Oct 8, 2017
@PCatinean
Copy link
Contributor Author

PCatinean commented Oct 8, 2017

@yajo added the mentioned changes. However in local tests it fails, i need to debug to fix the issues (one being it should not run if AGGREGATE env var is not defined). It also has to start the second aggregation once everything worked.

yajo
yajo previously requested changes Oct 9, 2017
@@ -0,0 +1 @@
devel.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this file.


# Find all dependency files after initial aggregation
dep_files = glob.glob('%s/**/oca_dependencies.txt' % CUSTOM_DIR)
dep_files = iglob('%s/**/oca_dependencies.txt' % CUSTOM_DIR)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for double asterisk, I think the file can only be found at repo root

if len(parts) > 1:
url = parts[1]
else:
url = 'https://github.com/%s/%s.git' % (owner, repo)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add to the dockerfile ONBUILD ARG DEFAULT_REPO_PATTERN="https://github.com/OCA/%s.git" and rely on that env variable instead.

repo_vals = {
'defaults': {'depth': '$DEPTH_DEFAULT'},
'remotes': {'origin': dep[1]},
'target': {'origin': '$ODOO_VERSION'},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I checked the output of this and it made the proper output i.e:

target: origin $ODOO_VERSION

Isn't that right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the proper output, although I'd be surprised if it gets there like that. I'd expect this line to be 'target': 'origin $ODOO_VERSION', instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, because in the link you gave and in the default repos yaml it's not as a string


# Generate auto_addons and auto_repos yaml files
for dep in dependencies:
ADDONS_YAML[dep[0]] = ['*']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ADDONS_YAML only contains the string of the file location. The actual parsing is done at odoobaselib.addons_config()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah so I need to use the result from that method to find out the actual addons instead of just using the file itself. Any idea how I can debug easier maybe even use PDB to save time and not build everything from scratch to test the python script?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try running a project with scaffolding and everything, and mounting this script as a volume under it. Then run it manually inside the container.

'target': {'origin': '$ODOO_VERSION'},
'merges': [{'origin': '$ODOO_VERSION'}],
}
REPOS_YAML[dep[0]] = {'%s' % dep[0]: repo_vals}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REPOS_YAML contains only the file string. Its actual parsing is done by git-aggregator itself by using the autoaggregate script. Possibly you'll need to add an argument to that string that lets you specify the file you are aggregating (from custom or from auto).

@PCatinean
Copy link
Contributor Author

I will resume work on this when I get a bit more time. I couldn't follow every reply on the mailing list regarding the pip installing method vs Doodba. This is still needed right?

@yajo
Copy link
Contributor

yajo commented Oct 24, 2017

Yes, as explained in OCA/runbot-addons#144 (comment), I still see many benefits on addons.yaml system, I don't think it will fade away soon (although pip installing support is still there, of course)

@yajo
Copy link
Contributor

yajo commented Nov 2, 2017

According to OCA/runbot-addons#144 (comment) (and mostly to the whole conversation) it seems OCA is not interested in this project, so please @PCatinean could you split this PR in 2?

  1. Autofill auto/repos.yaml when a repo is declared in custom/src/addons.yaml but not in custom/src/repos.yaml by using $DEFAULT_REPO_PATTERN.
  2. Implement oca_dependencies.txt recursive translation to this image's systems.

... Or otherwise just do step 1. Step 2 was a step needed to use Doodba in OCA. Since that's not going to happen, most likely it means that it goes to the collection of stuff that we just won't need. 🤔

@PCatinean
Copy link
Contributor Author

@yajo I see, so basically in step 1 whenever an addon is declared in addons.yaml but it's not present in repos.yaml assume it's an oca repo and update repos.yaml accordingly?

@yajo
Copy link
Contributor

yajo commented Nov 3, 2017

yep!

@yajo yajo changed the title [WIP] Translating oca_dependencies to addons/repos .yaml fo… [WIP] Autogenerate repos.yaml for missing addons Sep 13, 2018
@yajo yajo self-assigned this Sep 13, 2018
@yajo yajo dismissed their stale review September 13, 2018 11:30

It should be OK now

With this change, definitely we can have a Doodba scaffolding without `repos.yaml` file. It will do this:

1. Download all git code from repos in `repos.yaml`, if any.
2. Get the list of expected code repos from `addons.yaml`.
3. Autogenerate a `repos.yaml` file for all expected but absent repos, based on the provided patterns.
4. Download all of that missing code.
5. Continue normal operation.

As a 🎁, we now download git code in parallel if the building machine has more than 1 CPU.

Some tests have been modified to ensure they still pass with this new feature.
@yajo yajo merged commit 070323c into Tecnativa:master Sep 14, 2018
yajo added a commit that referenced this pull request Sep 18, 2018
yajo added a commit to Tecnativa/doodba-scaffolding that referenced this pull request Feb 25, 2019
- `l10n-spain` was never a good sample, since only Spanish projects would have it. Since Tecnativa/doodba#86 it's simply not needed in most cases. Devs can check the docs to know the structure. Thus, it can be removed from here.
- `checksumdir` is not used anymore in `module_auto_update` since OCA/server-tools#1190.
- `xlsxwriter` is included in Odoo 10+.
- `requests` is included in Odoo 8+.
yajo added a commit to Tecnativa/doodba-scaffolding that referenced this pull request Feb 26, 2019
- `l10n-spain` was never a good sample, since only Spanish projects would have it. Since Tecnativa/doodba#86 it's simply not needed in most cases. Devs can check the docs to know the structure, and a vscode snippet has been added. Thus, it can be removed from here.
- `checksumdir` is not used anymore in `module_auto_update` since OCA/server-tools#1190.
- `xlsxwriter` is included in Odoo 10+.
- `requests` is included in Odoo 8+.
yajo added a commit to Tecnativa/doodba-scaffolding that referenced this pull request Feb 26, 2019
- `l10n-spain` was never a good sample, since only Spanish projects would have it. Since Tecnativa/doodba#86 it's simply not needed in most cases. Devs can check the docs to know the structure, and a vscode snippet has been added. Thus, it can be removed from here.
- `checksumdir` is not used anymore in `module_auto_update` since OCA/server-tools#1190.
- `xlsxwriter` is included in Odoo 10+.
- `requests` is included in Odoo 8+.
yajo added a commit to Tecnativa/doodba-scaffolding that referenced this pull request Feb 26, 2019
- `l10n-spain` was never a good sample, since only Spanish projects would have it. Since Tecnativa/doodba#86 it's simply not needed in most cases. Devs can check the docs to know the structure, and a vscode snippet has been added. Thus, it can be removed from here.
- `checksumdir` is not used anymore in `module_auto_update` since OCA/server-tools#1190.
- `xlsxwriter` is included in Odoo 10+.
- `requests` is included in Odoo 8+.
yajo added a commit to Tecnativa/doodba-scaffolding that referenced this pull request Feb 26, 2019
- `l10n-spain` was never a good sample, since only Spanish projects would have it. Since Tecnativa/doodba#86 it's simply not needed in most cases. Devs can check the docs to know the structure, and a vscode snippet has been added. Thus, it can be removed from here.
- `checksumdir` is not used anymore in `module_auto_update` since OCA/server-tools#1190.
- `xlsxwriter` is included in Odoo 10+.
- `requests` is included in Odoo 8+.
yajo added a commit to Tecnativa/doodba-scaffolding that referenced this pull request Apr 23, 2019
Since Tecnativa/doodba#86, no addons or repos are required. This comment is an old true that is today a lie, so it's better away from here.
yajo added a commit to Tecnativa/doodba-scaffolding that referenced this pull request Apr 23, 2019
Since Tecnativa/doodba#86, no addons or repos are required. This comment is an old true that is today a lie, so it's better away from here.
mtelahun pushed a commit to trevi-software/doodba-scaffolding that referenced this pull request Jul 15, 2019
Since Tecnativa/doodba#86, no addons or repos are required. This comment is an old true that is today a lie, so it's better away from here.
mtelahun pushed a commit to trevi-software/doodba-scaffolding that referenced this pull request Jul 15, 2019
Since Tecnativa/doodba#86, no addons or repos are required. This comment is an old true that is today a lie, so it's better away from here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants