travis2docker 6.4.27__tar.gz → 7.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. {travis2docker-6.4.27 → travis2docker-7.0.0}/.bumpversion.cfg +1 -1
  2. {travis2docker-6.4.27 → travis2docker-7.0.0}/MANIFEST.in +0 -1
  3. {travis2docker-6.4.27 → travis2docker-7.0.0}/PKG-INFO +58 -30
  4. {travis2docker-6.4.27 → travis2docker-7.0.0}/README.rst +51 -22
  5. {travis2docker-6.4.27 → travis2docker-7.0.0}/docs/conf.py +1 -1
  6. travis2docker-7.0.0/requirements.txt +1 -0
  7. {travis2docker-6.4.27 → travis2docker-7.0.0}/setup.cfg +0 -3
  8. {travis2docker-6.4.27 → travis2docker-7.0.0}/setup.py +10 -9
  9. travis2docker-7.0.0/src/travis2docker/__init__.py +1 -0
  10. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker/cli.py +55 -63
  11. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker/docker_helper/build.py +6 -6
  12. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker/git_run.py +14 -14
  13. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker/templates/build.sh +2 -1
  14. travis2docker-7.0.0/src/travis2docker/travis2docker.py +162 -0
  15. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker.egg-info/PKG-INFO +58 -30
  16. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker.egg-info/SOURCES.txt +0 -16
  17. travis2docker-7.0.0/src/travis2docker.egg-info/requires.txt +1 -0
  18. travis2docker-7.0.0/tests/test_travis2docker.py +170 -0
  19. {travis2docker-6.4.27 → travis2docker-7.0.0}/tox.ini +2 -3
  20. travis2docker-6.4.27/examples/example_1.yml +0 -22
  21. travis2docker-6.4.27/examples/example_2.yml +0 -30
  22. travis2docker-6.4.27/examples/example_3.yml +0 -37
  23. travis2docker-6.4.27/examples/example_4.yml +0 -41
  24. travis2docker-6.4.27/examples/example_5.yml +0 -42
  25. travis2docker-6.4.27/requirements.txt +0 -4
  26. travis2docker-6.4.27/src/travis2docker/__init__.py +0 -1
  27. travis2docker-6.4.27/src/travis2docker/templates/Dockerfile +0 -89
  28. travis2docker-6.4.27/src/travis2docker/templates/entrypoint.sh +0 -10
  29. travis2docker-6.4.27/src/travis2docker/templates/rvm_env.sh +0 -18
  30. travis2docker-6.4.27/src/travis2docker/travis-ci-apt-source-whitelist/.git +0 -1
  31. travis2docker-6.4.27/src/travis2docker/travis-ci-apt-source-whitelist/.gitignore +0 -34
  32. travis2docker-6.4.27/src/travis2docker/travis-ci-apt-source-whitelist/.travis.yml +0 -10
  33. travis2docker-6.4.27/src/travis2docker/travis-ci-apt-source-whitelist/LICENSE +0 -22
  34. travis2docker-6.4.27/src/travis2docker/travis-ci-apt-source-whitelist/README.md +0 -15
  35. travis2docker-6.4.27/src/travis2docker/travis-ci-apt-source-whitelist/add_all.rb +0 -16
  36. travis2docker-6.4.27/src/travis2docker/travis-ci-apt-source-whitelist/bin/travis-add-source +0 -47
  37. travis2docker-6.4.27/src/travis2docker/travis-ci-apt-source-whitelist/ubuntu.json +0 -317
  38. travis2docker-6.4.27/src/travis2docker/travis2docker.py +0 -416
  39. travis2docker-6.4.27/src/travis2docker.egg-info/requires.txt +0 -8
  40. travis2docker-6.4.27/tests/test_travis2docker.py +0 -156
  41. {travis2docker-6.4.27 → travis2docker-7.0.0}/.coveragerc +0 -0
  42. {travis2docker-6.4.27 → travis2docker-7.0.0}/AUTHORS.rst +0 -0
  43. {travis2docker-6.4.27 → travis2docker-7.0.0}/CHANGELOG.rst +0 -0
  44. {travis2docker-6.4.27 → travis2docker-7.0.0}/CONTRIBUTING.rst +0 -0
  45. {travis2docker-6.4.27 → travis2docker-7.0.0}/LICENSE +0 -0
  46. {travis2docker-6.4.27 → travis2docker-7.0.0}/docs/authors.rst +0 -0
  47. {travis2docker-6.4.27 → travis2docker-7.0.0}/docs/changelog.rst +0 -0
  48. {travis2docker-6.4.27 → travis2docker-7.0.0}/docs/contributing.rst +0 -0
  49. {travis2docker-6.4.27 → travis2docker-7.0.0}/docs/index.rst +0 -0
  50. {travis2docker-6.4.27 → travis2docker-7.0.0}/docs/installation.rst +0 -0
  51. {travis2docker-6.4.27 → travis2docker-7.0.0}/docs/readme.rst +0 -0
  52. {travis2docker-6.4.27 → travis2docker-7.0.0}/docs/reference/index.rst +0 -0
  53. {travis2docker-6.4.27 → travis2docker-7.0.0}/docs/reference/travis2docker.rst +0 -0
  54. {travis2docker-6.4.27 → travis2docker-7.0.0}/docs/requirements.txt +0 -0
  55. {travis2docker-6.4.27 → travis2docker-7.0.0}/docs/spelling_wordlist.txt +0 -0
  56. {travis2docker-6.4.27 → travis2docker-7.0.0}/docs/usage.rst +0 -0
  57. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker/__main__.py +0 -0
  58. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker/exceptions.py +0 -0
  59. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker/templates/.coveragerc +0 -0
  60. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker/templates/.vscode/extensions.json +0 -0
  61. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker/templates/.vscode/launch.json +0 -0
  62. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker/templates/.vscode/settings.json +0 -0
  63. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker/templates/10-build.sh +0 -0
  64. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker/templates/20-run.sh +0 -0
  65. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker/templates/Dockerfile_deployv +0 -0
  66. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker/templates/entrypoint_deployv.sh +0 -0
  67. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker.egg-info/dependency_links.txt +0 -0
  68. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker.egg-info/entry_points.txt +0 -0
  69. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker.egg-info/not-zip-safe +0 -0
  70. {travis2docker-6.4.27 → travis2docker-7.0.0}/src/travis2docker.egg-info/top_level.txt +0 -0
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 6.4.27
2
+ current_version = 7.0.0
3
3
  commit = True
4
4
  tag = True
5
5
 
@@ -1,5 +1,4 @@
1
1
  graft docs
2
- graft examples
3
2
  graft src
4
3
  graft tests
5
4
 
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: travis2docker
3
- Version: 6.4.27
4
- Summary: Script to generate Dockerfile from .travis.yml file
3
+ Version: 7.0.0
4
+ Summary: Script to generate a development Dockerfile from the deployv image of a repository
5
5
  Home-page: https://github.com/vauxoo/travis2docker
6
6
  Author: Vauxoo
7
7
  Author-email: info@vauxoo.com
@@ -13,22 +13,20 @@ Classifier: Operating System :: POSIX
13
13
  Classifier: Operating System :: Microsoft :: Windows
14
14
  Classifier: Programming Language :: Python
15
15
  Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.8
17
- Classifier: Programming Language :: Python :: 3.9
18
16
  Classifier: Programming Language :: Python :: 3.10
19
17
  Classifier: Programming Language :: Python :: 3.11
20
18
  Classifier: Programming Language :: Python :: 3.12
21
19
  Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: 3.15
22
22
  Classifier: Programming Language :: Python :: Implementation :: CPython
23
23
  Classifier: Programming Language :: Python :: Implementation :: PyPy
24
24
  Classifier: Topic :: Utilities
25
+ Requires-Python: >=3.10
25
26
  Description-Content-Type: text/x-rst
26
27
  License-File: LICENSE
27
28
  License-File: AUTHORS.rst
28
- Requires-Dist: PyYAML==3.12; python_version < "3.7"
29
- Requires-Dist: PyYAML==6.0.*; python_version >= "3.7"
30
- Requires-Dist: Jinja2==2.11.3; python_version < "3.7"
31
- Requires-Dist: Jinja2==3.1.*; python_version >= "3.7"
29
+ Requires-Dist: Jinja2==3.1.*
32
30
  Dynamic: author
33
31
  Dynamic: author-email
34
32
  Dynamic: classifier
@@ -38,6 +36,7 @@ Dynamic: home-page
38
36
  Dynamic: license
39
37
  Dynamic: license-file
40
38
  Dynamic: requires-dist
39
+ Dynamic: requires-python
41
40
  Dynamic: summary
42
41
 
43
42
  ========
@@ -46,7 +45,7 @@ Overview
46
45
 
47
46
 
48
47
 
49
- Script to generate Dockerfile from .travis.yml file
48
+ Script to generate a development Dockerfile from the deployv image of a repository (based on its ``variables.sh`` file)
50
49
 
51
50
  * Free software: BSD license
52
51
 
@@ -74,19 +73,61 @@ Example:
74
73
  `travisfile2dockerfile --root-path=$HOME/t2d git@github.com:Vauxoo/forecast.git 8.0`
75
74
 
76
75
  The output is:
77
- `${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/1`
78
- `${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/2`
79
-
80
- The first one is the build for env `TESTS=1`, the second one is for env with `LINT_CHECK=1`
76
+ `${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0`
81
77
 
82
78
  To build image:
83
- `${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/1/10-build.sh`
79
+ `${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/10-build.sh`
84
80
 
85
81
  To create container:
86
- `${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/1/20-run.sh --entrypoint=bash`
82
+ `${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/20-run.sh --entrypoint=bash`
83
+
84
+ The repository needs a ``variables.sh`` file in its root path (the one used by
85
+ the deployv images built from the CI). By default the docker image is built
86
+ from its values as ``DOCKER_IMAGE_REPO:MAIN_APP-VERSION-SHA_SHORT``; use
87
+ ``--docker-image=quay.io/vauxoo/PROJECT:TAG`` to pick the image pushed by the
88
+ ``build_docker`` pipeline instead.
89
+
90
+ Optional tools (``--build-env-args``)
91
+ =====================================
92
+
93
+ Some development tools are **not** installed by default. They are enabled with
94
+ a flag passed as a build environment variable using ``--build-env-args``, which
95
+ generates an ``ENV <FLAG>=TRUE`` line in the Dockerfile. If the flag is not
96
+ defined, the installation step is skipped.
97
+
98
+ .. list-table::
99
+ :widths: 30 70
100
+ :header-rows: 1
101
+
102
+ * - Flag
103
+ - Installs
104
+ * - ``VIM_INSTALL``
105
+ - vim + spf13-vim, vim-openerp, jedi-vim, wakatime and the pylint_odoo/eslint syntastic configuration
106
+ * - ``ZSH_INSTALL``
107
+ - zsh + oh-my-zsh with the ``odoo-shippable`` theme
108
+
109
+ Example enabling more than one::
110
+
111
+ travisfile2dockerfile --build-env-args VIM_INSTALL ZSH_INSTALL \
112
+ git@github.com:Vauxoo/forecast.git 8.0
113
+
114
+ codebase-memory-deployv
115
+ =======================
87
116
 
88
- To run the test (into of container):
89
- `/entrypoint.sh`
117
+ The image ships with `codebase-memory-deployv
118
+ <https://pypi.org/project/codebase-memory-deployv>`__, a wrapper that deploys
119
+ `codebase-memory-mcp <https://github.com/DeusData/codebase-memory-mcp>`__
120
+ (code knowledge graph for AI agents) for instances following this layout.
121
+
122
+ The repository is **not** indexed while building the image. Run inside the
123
+ container::
124
+
125
+ codebase-memory-deployv
126
+
127
+ It installs codebase-memory-mcp if it is missing, derives the project name from
128
+ ``${MAIN_REPO_FULL_PATH}/variables.sh`` (e.g. ``forecast_17.0``), and indexes
129
+ ``/home/odoo/instance`` in batches of modules. Indexing takes a few minutes on
130
+ a big instance, so it is left as an explicit step for the user.
90
131
 
91
132
  Depends
92
133
  =======
@@ -103,19 +144,6 @@ Dockerfile doesn't support a prompt to enter your password, so you need to remov
103
144
  openssl rsa -in ${fname} -out ${fname}_without_pwd
104
145
  cp ${fname}_without_pwd ${fname}
105
146
 
106
- Download the big image
107
- **********************
108
-
109
- Travis2docker uses a default image with many packages pre-installed.
110
-
111
- `docker pull vauxoo/odoo-80-image-shippable-auto`
112
-
113
- Note: You can define a custom image to use with `--docker-image` parameter.
114
-
115
- For example if you want use the original image of travis you can add the following parameters:
116
-
117
- `--docker-image=quay.io/travisci/travis-python --docker-user=travis`
118
-
119
147
  Install docker
120
148
  **************
121
149
 
@@ -53,7 +53,7 @@ Overview
53
53
 
54
54
  .. end-badges
55
55
 
56
- Script to generate Dockerfile from .travis.yml file
56
+ Script to generate a development Dockerfile from the deployv image of a repository (based on its ``variables.sh`` file)
57
57
 
58
58
  * Free software: BSD license
59
59
 
@@ -81,19 +81,61 @@ Example:
81
81
  `travisfile2dockerfile --root-path=$HOME/t2d git@github.com:Vauxoo/forecast.git 8.0`
82
82
 
83
83
  The output is:
84
- `${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/1`
85
- `${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/2`
86
-
87
- The first one is the build for env `TESTS=1`, the second one is for env with `LINT_CHECK=1`
84
+ `${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0`
88
85
 
89
86
  To build image:
90
- `${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/1/10-build.sh`
87
+ `${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/10-build.sh`
91
88
 
92
89
  To create container:
93
- `${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/1/20-run.sh --entrypoint=bash`
90
+ `${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/20-run.sh --entrypoint=bash`
91
+
92
+ The repository needs a ``variables.sh`` file in its root path (the one used by
93
+ the deployv images built from the CI). By default the docker image is built
94
+ from its values as ``DOCKER_IMAGE_REPO:MAIN_APP-VERSION-SHA_SHORT``; use
95
+ ``--docker-image=quay.io/vauxoo/PROJECT:TAG`` to pick the image pushed by the
96
+ ``build_docker`` pipeline instead.
97
+
98
+ Optional tools (``--build-env-args``)
99
+ =====================================
100
+
101
+ Some development tools are **not** installed by default. They are enabled with
102
+ a flag passed as a build environment variable using ``--build-env-args``, which
103
+ generates an ``ENV <FLAG>=TRUE`` line in the Dockerfile. If the flag is not
104
+ defined, the installation step is skipped.
105
+
106
+ .. list-table::
107
+ :widths: 30 70
108
+ :header-rows: 1
109
+
110
+ * - Flag
111
+ - Installs
112
+ * - ``VIM_INSTALL``
113
+ - vim + spf13-vim, vim-openerp, jedi-vim, wakatime and the pylint_odoo/eslint syntastic configuration
114
+ * - ``ZSH_INSTALL``
115
+ - zsh + oh-my-zsh with the ``odoo-shippable`` theme
116
+
117
+ Example enabling more than one::
118
+
119
+ travisfile2dockerfile --build-env-args VIM_INSTALL ZSH_INSTALL \
120
+ git@github.com:Vauxoo/forecast.git 8.0
121
+
122
+ codebase-memory-deployv
123
+ =======================
94
124
 
95
- To run the test (into of container):
96
- `/entrypoint.sh`
125
+ The image ships with `codebase-memory-deployv
126
+ <https://pypi.org/project/codebase-memory-deployv>`__, a wrapper that deploys
127
+ `codebase-memory-mcp <https://github.com/DeusData/codebase-memory-mcp>`__
128
+ (code knowledge graph for AI agents) for instances following this layout.
129
+
130
+ The repository is **not** indexed while building the image. Run inside the
131
+ container::
132
+
133
+ codebase-memory-deployv
134
+
135
+ It installs codebase-memory-mcp if it is missing, derives the project name from
136
+ ``${MAIN_REPO_FULL_PATH}/variables.sh`` (e.g. ``forecast_17.0``), and indexes
137
+ ``/home/odoo/instance`` in batches of modules. Indexing takes a few minutes on
138
+ a big instance, so it is left as an explicit step for the user.
97
139
 
98
140
  Depends
99
141
  =======
@@ -110,19 +152,6 @@ Dockerfile doesn't support a prompt to enter your password, so you need to remov
110
152
  openssl rsa -in ${fname} -out ${fname}_without_pwd
111
153
  cp ${fname}_without_pwd ${fname}
112
154
 
113
- Download the big image
114
- **********************
115
-
116
- Travis2docker uses a default image with many packages pre-installed.
117
-
118
- `docker pull vauxoo/odoo-80-image-shippable-auto`
119
-
120
- Note: You can define a custom image to use with `--docker-image` parameter.
121
-
122
- For example if you want use the original image of travis you can add the following parameters:
123
-
124
- `--docker-image=quay.io/travisci/travis-python --docker-user=travis`
125
-
126
155
  Install docker
127
156
  **************
128
157
 
@@ -26,7 +26,7 @@ project = u'travis2docker'
26
26
  year = '2016'
27
27
  author = u'Vauxoo'
28
28
  copyright = '{0}, {1}'.format(year, author)
29
- version = release = u'6.4.27'
29
+ version = release = u'7.0.0'
30
30
 
31
31
  pygments_style = 'trac'
32
32
  templates_path = ['.']
@@ -0,0 +1 @@
1
+ Jinja2==3.1.*
@@ -1,6 +1,3 @@
1
- [bdist_wheel]
2
- universal = 1
3
-
4
1
  [flake8]
5
2
  max-line-length = 140
6
3
  exclude = tests/*,*/migrations/*,*/south_migrations/*
@@ -1,25 +1,25 @@
1
1
  #!/usr/bin/env python
2
2
 
3
+ import pathlib
3
4
  import re
4
5
  from glob import glob
5
- from os.path import basename, dirname, join, splitext
6
6
 
7
7
  from setuptools import find_packages, setup
8
8
 
9
9
 
10
10
  def read(*names, **kwargs):
11
- return open(join(dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8")).read()
11
+ return pathlib.Path(__file__).parent.joinpath(*names).read_text(encoding=kwargs.get("encoding", "utf8"))
12
12
 
13
13
 
14
14
  setup(
15
15
  name="travis2docker",
16
- version="6.4.27",
16
+ version="7.0.0",
17
17
  license="BSD-3-Clause",
18
- description="Script to generate Dockerfile from .travis.yml file",
18
+ description="Script to generate a development Dockerfile from the deployv image of a repository",
19
19
  long_description="%s\n%s"
20
20
  % (
21
- re.compile("^.. start-badges.*^.. end-badges", re.M | re.S).sub("", read("README.rst")),
22
- re.sub(":[a-z]+:`~?(.*?)`", r"``\1``", read("CHANGELOG.rst")),
21
+ re.compile(r"^.. start-badges.*^.. end-badges", re.MULTILINE | re.DOTALL).sub("", read("README.rst")),
22
+ re.sub(r":[a-z]+:`~?(.*?)`", r"``\1``", read("CHANGELOG.rst")),
23
23
  ),
24
24
  long_description_content_type="text/x-rst",
25
25
  author="Vauxoo",
@@ -27,7 +27,7 @@ setup(
27
27
  url="https://github.com/vauxoo/travis2docker",
28
28
  packages=find_packages("src"),
29
29
  package_dir={"": "src"},
30
- py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")],
30
+ py_modules=[pathlib.Path(path).stem for path in glob("src/*.py")],
31
31
  include_package_data=True,
32
32
  zip_safe=False,
33
33
  classifiers=[
@@ -39,12 +39,12 @@ setup(
39
39
  "Operating System :: Microsoft :: Windows",
40
40
  "Programming Language :: Python",
41
41
  "Programming Language :: Python :: 3",
42
- "Programming Language :: Python :: 3.8",
43
- "Programming Language :: Python :: 3.9",
44
42
  "Programming Language :: Python :: 3.10",
45
43
  "Programming Language :: Python :: 3.11",
46
44
  "Programming Language :: Python :: 3.12",
47
45
  "Programming Language :: Python :: 3.13",
46
+ "Programming Language :: Python :: 3.14",
47
+ "Programming Language :: Python :: 3.15",
48
48
  "Programming Language :: Python :: Implementation :: CPython",
49
49
  "Programming Language :: Python :: Implementation :: PyPy",
50
50
  # uncomment if you test on these interpreters:
@@ -56,6 +56,7 @@ setup(
56
56
  keywords=[
57
57
  # eg: 'keyword1', 'keyword2', 'keyword3',
58
58
  ],
59
+ python_requires=">=3.10",
59
60
  install_requires=read("requirements.txt").split("\n"),
60
61
  extras_require={
61
62
  # eg:
@@ -0,0 +1 @@
1
+ __version__ = "7.0.0"
@@ -15,7 +15,7 @@ Why does this file exist, and why not put this in __main__?
15
15
 
16
16
  import argparse
17
17
  import os
18
- from os.path import expanduser, expandvars, isdir, isfile, join
18
+ import pathlib
19
19
  from sys import stdout
20
20
 
21
21
  from . import __version__
@@ -24,12 +24,20 @@ from .git_run import GitRun
24
24
  from .travis2docker import Travis2Docker
25
25
 
26
26
 
27
+ def variables_sh_read(variables_sh_path):
28
+ variables_sh_path = pathlib.Path(variables_sh_path).expanduser()
29
+ if variables_sh_path.is_dir():
30
+ variables_sh_path /= "variables.sh"
31
+ if not variables_sh_path.is_file():
32
+ return None
33
+ return variables_sh_path.read_text()
34
+
35
+
27
36
  def get_git_data(project, path, revision):
28
37
  git_obj = GitRun(project, path, path_prefix_repo=True)
29
38
  git_obj.update()
30
39
  data = {
31
40
  "sha": git_obj.get_sha(revision),
32
- "content": git_obj.show_file(".travis.yml", revision) or git_obj.show_file(".t2d.yml", revision),
33
41
  "variables_sh": git_obj.show_file("variables.sh", revision),
34
42
  "repo_owner": git_obj.owner,
35
43
  "repo_project": git_obj.repo,
@@ -41,28 +49,13 @@ def get_git_data(project, path, revision):
41
49
  return data
42
50
 
43
51
 
44
- def yml_read(yml_path):
45
- yml_path_expanded = expandvars(expanduser(yml_path))
46
- alt_yml_path_expanded = None
47
- if isdir(yml_path_expanded):
48
- yml_path_expanded = join(yml_path_expanded, ".travis.yml")
49
- alt_yml_path_expanded = join(yml_path_expanded, ".t2d.yml")
50
- if not isfile(yml_path_expanded):
51
- if alt_yml_path_expanded and isfile(alt_yml_path_expanded):
52
- yml_path_expanded = alt_yml_path_expanded
53
- else:
54
- return
55
- with open(yml_path_expanded) as f_yml:
56
- return f_yml.read()
57
-
58
-
59
52
  def main(return_result=False):
60
53
  parser = argparse.ArgumentParser()
61
54
  parser.add_argument(
62
55
  "git_repo_url",
63
56
  help="Specify repository git of work."
64
57
  "\nThis is used to clone it "
65
- "and get file .travis.yml or .shippable.yml"
58
+ "and get the variables.sh file of the deployv image"
66
59
  "\nIf your repository is private, "
67
60
  "don't use https url, "
68
61
  "use ssh url",
@@ -78,21 +71,19 @@ def main(return_result=False):
78
71
  parser.add_argument(
79
72
  "--docker-user",
80
73
  dest="docker_user",
81
- help="User of work into Dockerfile." "\nBased on your docker image." "\nDefault: root",
74
+ help="User of work into Dockerfile.\nBased on your docker image.\nDefault: odoo",
82
75
  )
83
76
  parser.add_argument(
84
77
  "--docker-image",
85
78
  dest="default_docker_image",
86
79
  help="Docker image to use by default in Dockerfile."
87
- "\nUse this parameter if don't "
88
- "exists value: 'build_image: IMAGE_NAME' "
89
- "in .travis.yml"
90
- "\nDefault: 'vauxoo/odoo-80-image-shippable-auto'",
80
+ "\nDefault: built from variables.sh as "
81
+ "'DOCKER_IMAGE_REPO:MAIN_APP-VERSION-SHA_SHORT'",
91
82
  )
92
83
  default_root_path = os.environ.get("TRAVIS2DOCKER_ROOT_PATH")
93
84
  if not default_root_path:
94
- default_root_path = os.path.expanduser("~")
95
- default_root_path = join(default_root_path, ".t2d")
85
+ default_root_path = pathlib.Path("~").expanduser()
86
+ default_root_path = str(pathlib.Path(default_root_path) / ".t2d")
96
87
  parser.add_argument(
97
88
  "--root-path",
98
89
  dest="root_path",
@@ -102,14 +93,14 @@ def main(return_result=False):
102
93
  parser.add_argument(
103
94
  "--add-remote",
104
95
  dest="remotes",
105
- help="Add git remote to git of build path, separated by a comma." "\nUse remote name. E.g. 'Vauxoo,moylop260'",
96
+ help="Add git remote to git of build path, separated by a comma.\nUse remote name. E.g. 'Vauxoo,moylop260'",
106
97
  )
107
98
  parser.add_argument(
108
99
  "--exclude-after-success",
109
100
  dest="exclude_after_success",
110
101
  action="store_true",
111
102
  default=False,
112
- help="Exclude `travis_after_success` section to entrypoint",
103
+ help="Deprecated. Ignored: the travis_after_success section does not exist anymore",
113
104
  )
114
105
  parser.add_argument(
115
106
  "--run-extra-args",
@@ -137,20 +128,27 @@ def main(return_result=False):
137
128
  dest="build_extra_cmds",
138
129
  nargs="*",
139
130
  default="",
140
- help='Extra commands to run after "build" script. ' "Note: You can use \\$IMAGE escaped environment variable.",
131
+ help='Extra commands to run after "build" script. Note: You can use \\$IMAGE escaped environment variable.',
141
132
  )
142
133
  parser.add_argument(
143
134
  "--travis-yml-path",
144
135
  dest="travis_yml_path",
145
- help="Optional path of file .travis.yml to use.\n" "Default: Extracted from git repo and git revision.",
146
136
  default=None,
137
+ help="Deprecated. Ignored: the .travis.yml file is not used anymore",
138
+ )
139
+ parser.add_argument(
140
+ "--variables-sh-path",
141
+ dest="variables_sh_path",
142
+ default=None,
143
+ help="Optional path of the variables.sh file (or the directory containing it) to use.\n"
144
+ "Default: Extracted from git repo and git revision.",
147
145
  )
148
146
  parser.add_argument(
149
147
  "--no-clone",
150
148
  dest="no_clone",
151
149
  action="store_true",
152
- help="Avoid clone the repository. It will require travis-yml-path",
153
150
  default=False,
151
+ help="Avoid cloning the repository. It requires --variables-sh-path",
154
152
  )
155
153
  parser.add_argument(
156
154
  "--add-rcfile",
@@ -165,7 +163,7 @@ def main(return_result=False):
165
163
  dest="runs_at_the_end_script",
166
164
  nargs="*",
167
165
  default="",
168
- help='Extra commands to run after "script" file. ' "Note: You can use \\$IMAGE escaped environment variable.",
166
+ help="Deprecated. Ignored: the script section of .travis.yml does not exist anymore",
169
167
  )
170
168
  parser.add_argument(
171
169
  "--build-env-args",
@@ -183,8 +181,8 @@ def main(return_result=False):
183
181
  "--deployv",
184
182
  dest="deployv",
185
183
  action="store_true",
186
- default=False,
187
- help="Use the image generated from the CI and used in deployV",
184
+ default=True,
185
+ help="Deprecated. The deployv image is now the only supported mode",
188
186
  )
189
187
  parser.add_argument(
190
188
  "--build-extra-steps",
@@ -195,6 +193,14 @@ def main(return_result=False):
195
193
  )
196
194
 
197
195
  args = parser.parse_args()
196
+ deprecated_args = {
197
+ "--exclude-after-success": args.exclude_after_success,
198
+ "--travis-yml-path": args.travis_yml_path,
199
+ "--runs-at-the-end-script": args.runs_at_the_end_script,
200
+ }
201
+ for deprecated_arg, value in deprecated_args.items():
202
+ if value:
203
+ stdout.write("WARNING: %s is deprecated and its value will be ignored\n" % deprecated_arg)
198
204
  revision = args.git_revision
199
205
  git_repo = args.git_repo_url
200
206
  git_base = GitRun.get_data_url(git_repo, False)[0]
@@ -202,19 +208,16 @@ def main(return_result=False):
202
208
  root_path = args.root_path
203
209
  default_docker_image = args.default_docker_image
204
210
  remotes = args.remotes and args.remotes.split(",")
205
- exclude_after_success = args.exclude_after_success
206
211
  run_extra_args = args.run_extra_args
207
212
  build_extra_args = args.build_extra_args
208
- travis_yml_path = args.travis_yml_path
209
213
  build_extra_cmds = "\n".join(args.build_extra_cmds)
210
214
  run_extra_cmds = "\n".join(args.run_extra_cmds)
211
- no_clone = args.no_clone
212
- deployv = args.deployv
213
215
  rcfiles_args = args.add_rcfile and args.add_rcfile.split(",")
214
- runs_at_the_end_script = args.runs_at_the_end_script or None
215
216
  build_env_args = [build_env_args[0] for build_env_args in args.build_env_args]
216
- rcfiles = [(expanduser(rc_file), os.path.join("$HOME", os.path.basename(rc_file))) for rc_file in rcfiles_args]
217
- if no_clone:
217
+ rcfiles = [
218
+ (pathlib.Path(rc_file).expanduser(), "$HOME/%s" % pathlib.Path(rc_file).name) for rc_file in rcfiles_args
219
+ ]
220
+ if args.no_clone:
218
221
  os_kwargs = {
219
222
  "repo_owner": "local_file",
220
223
  "repo_project": "local_file",
@@ -223,42 +226,31 @@ def main(return_result=False):
223
226
  "project": git_repo,
224
227
  }
225
228
  else:
226
- os_kwargs = get_git_data(git_repo, join(root_path, "repo"), revision)
227
-
228
- if travis_yml_path:
229
- yml_content = yml_read(travis_yml_path)
230
- else:
231
- yml_content = os_kwargs["content"]
229
+ os_kwargs = get_git_data(git_repo, pathlib.Path(root_path) / "repo", revision)
232
230
 
233
- if not yml_content and os_kwargs.get("variables_sh"):
234
- deployv = True
235
- yml_content = "deployv: True"
236
- if not default_docker_image and not deployv:
237
- default_docker_image = "vauxoo/odoo-80-image-shippable-auto"
231
+ if args.variables_sh_path:
232
+ os_kwargs["variables_sh"] = variables_sh_read(args.variables_sh_path)
238
233
 
239
- if not yml_content:
234
+ if not os_kwargs.get("variables_sh"):
240
235
  msg = (
241
- "The file %s is empty." % travis_yml_path
242
- if travis_yml_path
236
+ "The file %s is empty or does not exist." % args.variables_sh_path
237
+ if args.variables_sh_path
243
238
  else "The repo or the branch is incorrect value, because "
244
- + "It can not got the .travis.yml or variables.sh content from %s %s. " % (git_repo, revision)
239
+ + "It can not got the variables.sh content from %s %s. " % (git_repo, revision)
245
240
  + "\nPlease, verify access repository,"
246
241
  + "\nverify exists url and revision, "
247
- + "\nverify exists .travis.yml"
242
+ + "\nverify exists variables.sh"
248
243
  )
249
244
  raise InvalidRepoBranchError(msg)
250
245
  os_kwargs.update({"remotes": remotes, "git_base": git_base})
251
246
  if docker_user:
252
247
  os_kwargs.update({"user": docker_user})
253
248
  t2d = Travis2Docker(
254
- yml_buffer=yml_content,
255
- work_path=join(root_path, "script", GitRun.url2dirname(git_repo), revision),
249
+ work_path=pathlib.Path(root_path) / "script" / GitRun.url2dirname(git_repo) / revision,
256
250
  image=default_docker_image,
257
251
  os_kwargs=os_kwargs,
258
- copy_paths=[(expanduser("~/.ssh"), "$HOME/.ssh")] + rcfiles,
259
- runs_at_the_end_script=runs_at_the_end_script,
252
+ copy_paths=[(pathlib.Path("~/.ssh").expanduser(), "$HOME/.ssh")] + rcfiles,
260
253
  build_env_args=build_env_args,
261
- deployv=deployv,
262
254
  build_extra_steps=args.build_extra_steps,
263
255
  )
264
256
  t2d.build_extra_params = {
@@ -269,11 +261,11 @@ def main(return_result=False):
269
261
  "extra_params": run_extra_args,
270
262
  "extra_cmds": run_extra_cmds,
271
263
  }
272
- fname_scripts = t2d.compute_dockerfile(skip_after_success=exclude_after_success)
264
+ fname_scripts = t2d.compute_dockerfile()
273
265
  if fname_scripts:
274
266
  fname_list = "- " + "\n- ".join(fname_scripts)
275
267
  stdout.write("\nGenerated scripts:\n%s\n" % fname_list)
276
- if deployv and not default_docker_image:
268
+ if not default_docker_image:
277
269
  stdout.write("=" * 80)
278
270
  # TODO: Add the URL to open the pipelines
279
271
  stdout.write(
@@ -2,7 +2,7 @@
2
2
  # pylint: disable=print-used
3
3
 
4
4
  import glob
5
- import os
5
+ import pathlib
6
6
  import re
7
7
  import subprocess
8
8
  import sys
@@ -11,7 +11,7 @@ import sys
11
11
  def ssh_keyscan2known_hosts(url, known_hosts_path=None):
12
12
  # python3 -c "import build;build.ssh_keyscan2known_hosts('url')"
13
13
  if known_hosts_path is None:
14
- known_hosts_path = os.path.join(os.path.expanduser("~"), ".ssh", "known_hosts")
14
+ known_hosts_path = pathlib.Path("~/.ssh/known_hosts").expanduser()
15
15
 
16
16
  # Clear current known hosts
17
17
  cmd = ["ssh-keygen", "-R", url]
@@ -22,7 +22,7 @@ def ssh_keyscan2known_hosts(url, known_hosts_path=None):
22
22
  cmd = ["ssh-keyscan", "-p", "22", url]
23
23
  print(" ".join(cmd))
24
24
  keys_scanned = subprocess.check_output(cmd).decode(sys.stdout.encoding).strip()
25
- with open(known_hosts_path, "r+") as known_hosts_f:
25
+ with pathlib.Path(known_hosts_path).open("r+") as known_hosts_f:
26
26
  known_hosts_f.write("\n" + keys_scanned)
27
27
 
28
28
 
@@ -31,14 +31,14 @@ def git_set_remote(path=None):
31
31
  if path is None:
32
32
  # /home/odoo/instance/odoo spends a lot of time
33
33
  path = "/home/odoo/instance/extra_addons"
34
- git_re = re.compile("([^/|@]+)/([^/]+)/([^/.]+(.git)?)")
34
+ git_re = re.compile(r"([^/|@]+)/([^/]+)/([^/.]+(.git)?)")
35
35
  # TODO: Support ssh url
36
- path = os.path.join(path, "*", "**", ".git")
36
+ path = str(pathlib.Path(path) / "*" / "**" / ".git")
37
37
  hosts_scanned = set()
38
38
  for git_dir in glob.glob(path, recursive=True):
39
39
  git_cmd = [
40
40
  "git",
41
- "--work-tree=%s" % os.path.dirname(git_dir),
41
+ "--work-tree=%s" % pathlib.Path(git_dir).parent,
42
42
  "--git-dir=%s" % git_dir,
43
43
  ]
44
44
  cmd = git_cmd + ["remote", "get-url", "--push", "origin"]