brock 0.1.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.
- brock-0.1.0/.brock.yml +20 -0
- brock-0.1.0/.codeclimate.yml +27 -0
- brock-0.1.0/.gitignore +16 -0
- brock-0.1.0/.gitlab-ci.yml +188 -0
- brock-0.1.0/.pre-commit-config.yaml +32 -0
- brock-0.1.0/.style.yapf +7 -0
- brock-0.1.0/LICENSE +19 -0
- brock-0.1.0/PKG-INFO +261 -0
- brock-0.1.0/README.md +194 -0
- brock-0.1.0/example_brock.yml +100 -0
- brock-0.1.0/pyproject.toml +87 -0
- brock-0.1.0/setup.cfg +4 -0
- brock-0.1.0/src/brock/__init__.py +5 -0
- brock-0.1.0/src/brock/__main__.py +13 -0
- brock-0.1.0/src/brock/__version__.py +16 -0
- brock-0.1.0/src/brock/cli/__init__.py +0 -0
- brock-0.1.0/src/brock/cli/analytics.py +47 -0
- brock-0.1.0/src/brock/cli/commands.py +162 -0
- brock-0.1.0/src/brock/cli/main.py +179 -0
- brock-0.1.0/src/brock/cli/state.py +53 -0
- brock-0.1.0/src/brock/config/__init__.py +0 -0
- brock-0.1.0/src/brock/config/config.py +202 -0
- brock-0.1.0/src/brock/exception.py +17 -0
- brock-0.1.0/src/brock/executors/__init__.py +74 -0
- brock-0.1.0/src/brock/executors/docker.py +465 -0
- brock-0.1.0/src/brock/executors/host.py +65 -0
- brock-0.1.0/src/brock/executors/ssh.py +70 -0
- brock-0.1.0/src/brock/log.py +189 -0
- brock-0.1.0/src/brock/project.py +285 -0
- brock-0.1.0/src/brock.egg-info/PKG-INFO +261 -0
- brock-0.1.0/src/brock.egg-info/SOURCES.txt +36 -0
- brock-0.1.0/src/brock.egg-info/dependency_links.txt +1 -0
- brock-0.1.0/src/brock.egg-info/entry_points.txt +2 -0
- brock-0.1.0/src/brock.egg-info/requires.txt +14 -0
- brock-0.1.0/src/brock.egg-info/top_level.txt +1 -0
- brock-0.1.0/tests/config/test_config.py +103 -0
- brock-0.1.0/tests/conftest.py +0 -0
- brock-0.1.0/tests/system/test_options.py +339 -0
brock-0.1.0/.brock.yml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
version: 0.1.0
|
|
2
|
+
project: brock
|
|
3
|
+
|
|
4
|
+
executors:
|
|
5
|
+
python:
|
|
6
|
+
type: docker
|
|
7
|
+
image: python:3.7
|
|
8
|
+
prepare:
|
|
9
|
+
- pip install -r requirements.txt
|
|
10
|
+
- pip install wheel pytest pytest-cov
|
|
11
|
+
|
|
12
|
+
commands:
|
|
13
|
+
build:
|
|
14
|
+
steps:
|
|
15
|
+
- python setup.py bdist_wheel -d dist/
|
|
16
|
+
- python setup.py sdist -d dist/
|
|
17
|
+
|
|
18
|
+
test:
|
|
19
|
+
steps:
|
|
20
|
+
- pytest tests/
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
version: "2"
|
|
2
|
+
plugins:
|
|
3
|
+
pep8:
|
|
4
|
+
enabled: true
|
|
5
|
+
fixme:
|
|
6
|
+
enabled: true
|
|
7
|
+
config:
|
|
8
|
+
strings:
|
|
9
|
+
- FIXME
|
|
10
|
+
radon:
|
|
11
|
+
enabled: true
|
|
12
|
+
config:
|
|
13
|
+
python_version: 3
|
|
14
|
+
duplication:
|
|
15
|
+
enabled: true
|
|
16
|
+
config:
|
|
17
|
+
languages:
|
|
18
|
+
python:
|
|
19
|
+
python_version: 3
|
|
20
|
+
sonar-python:
|
|
21
|
+
enabled: true
|
|
22
|
+
config:
|
|
23
|
+
minimum_severity: major
|
|
24
|
+
csslint:
|
|
25
|
+
enabled: true
|
|
26
|
+
rubocop:
|
|
27
|
+
enabled: false
|
brock-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
**/*_cache
|
|
4
|
+
|
|
5
|
+
# Distribution / packaging
|
|
6
|
+
**/build/**
|
|
7
|
+
!**/build/*.py
|
|
8
|
+
*.egg
|
|
9
|
+
*.eggs
|
|
10
|
+
*.egg-info/
|
|
11
|
+
MANIFEST
|
|
12
|
+
|
|
13
|
+
# Coverage reports
|
|
14
|
+
**/.coverage_html/**
|
|
15
|
+
|
|
16
|
+
src/brock/__version__.py
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
stages:
|
|
2
|
+
- test
|
|
3
|
+
- build
|
|
4
|
+
- deploy
|
|
5
|
+
- release
|
|
6
|
+
|
|
7
|
+
workflow:
|
|
8
|
+
rules:
|
|
9
|
+
# don't create a pipeline if its a commit pipeline, on a branch and that branch has open merge requests (bc we will get a MR build instead)
|
|
10
|
+
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
|
|
11
|
+
when: never
|
|
12
|
+
- when: always
|
|
13
|
+
|
|
14
|
+
variables:
|
|
15
|
+
PACKAGE_REGISTRY: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/brock"
|
|
16
|
+
|
|
17
|
+
pre-commit:
|
|
18
|
+
stage: .pre
|
|
19
|
+
image:
|
|
20
|
+
name: registry.benderrobotics.com/br/toolchains/pre-commit:2.17.0
|
|
21
|
+
tags:
|
|
22
|
+
- docker
|
|
23
|
+
script:
|
|
24
|
+
- pre-commit run --all-files --show-diff-on-failure
|
|
25
|
+
|
|
26
|
+
.code-quality:
|
|
27
|
+
stage: test
|
|
28
|
+
tags:
|
|
29
|
+
- docker
|
|
30
|
+
image: docker:stable
|
|
31
|
+
allow_failure: true
|
|
32
|
+
variables:
|
|
33
|
+
CI_DEBUG_TRACE: "false"
|
|
34
|
+
REPORT_FORMAT: "json"
|
|
35
|
+
script:
|
|
36
|
+
- echo $REPORT_FORMAT
|
|
37
|
+
- CONTAINER_ID=$(docker ps -q -f "label=com.gitlab.gitlab-runner.job.id=${CI_JOB_ID}")
|
|
38
|
+
- VOLUME_PATH=$(docker inspect $CONTAINER_ID --format '{{ range .Mounts }}{{ if eq .Destination "/builds" }}{{ .Source }}{{ end }}{{ end }}')
|
|
39
|
+
- VOLUME_CODE_PATH="${VOLUME_PATH}/${CI_PROJECT_DIR#$CI_BUILDS_DIR}"
|
|
40
|
+
- docker run
|
|
41
|
+
--rm
|
|
42
|
+
--env SOURCE_CODE=$VOLUME_CODE_PATH
|
|
43
|
+
--env REPORT_FORMAT=$REPORT_FORMAT
|
|
44
|
+
--env CODECLIMATE_DEV=1
|
|
45
|
+
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
46
|
+
--volume $VOLUME_CODE_PATH:/code
|
|
47
|
+
registry.gitlab.com/gitlab-org/ci-cd/codequality:latest /code
|
|
48
|
+
artifacts:
|
|
49
|
+
expire_in: 1 week
|
|
50
|
+
dependencies: []
|
|
51
|
+
|
|
52
|
+
code-quality-json:
|
|
53
|
+
extends: .code-quality
|
|
54
|
+
artifacts:
|
|
55
|
+
reports:
|
|
56
|
+
codequality: gl-code-quality-report.json
|
|
57
|
+
paths: [gl-code-quality-report.json]
|
|
58
|
+
|
|
59
|
+
code-quality-html:
|
|
60
|
+
extends: .code-quality
|
|
61
|
+
variables:
|
|
62
|
+
REPORT_FORMAT: "html"
|
|
63
|
+
artifacts:
|
|
64
|
+
paths: [gl-code-quality-report.html]
|
|
65
|
+
|
|
66
|
+
test-unit:
|
|
67
|
+
stage: test
|
|
68
|
+
image: python:3.9
|
|
69
|
+
tags:
|
|
70
|
+
- docker
|
|
71
|
+
script:
|
|
72
|
+
- pip install virtualenv
|
|
73
|
+
- virtualenv venv
|
|
74
|
+
- source venv/bin/activate
|
|
75
|
+
- pip install -e ./[test]
|
|
76
|
+
- pytest tests/
|
|
77
|
+
- sed -i 's|<source>.*</source>|<source></source>|g;s|filename="|filename="src/brock/|g' coverage.xml
|
|
78
|
+
allow_failure: true
|
|
79
|
+
artifacts:
|
|
80
|
+
reports:
|
|
81
|
+
coverage_report:
|
|
82
|
+
coverage_format: cobertura
|
|
83
|
+
path: coverage.xml
|
|
84
|
+
|
|
85
|
+
build:
|
|
86
|
+
stage: build
|
|
87
|
+
image: python:3.9
|
|
88
|
+
tags:
|
|
89
|
+
- docker
|
|
90
|
+
artifacts:
|
|
91
|
+
paths:
|
|
92
|
+
- dist
|
|
93
|
+
expire_in: 30 days
|
|
94
|
+
reports:
|
|
95
|
+
dotenv: variables.env
|
|
96
|
+
before_script:
|
|
97
|
+
- pip install -U setuptools setuptools_scm build wheel
|
|
98
|
+
script:
|
|
99
|
+
- VERSION=$(python -c "import build.util; print(build.util.project_wheel_metadata('.').get('Version'))")
|
|
100
|
+
- python -m build --sdist --wheel --outdir $CI_PROJECT_DIR/dist .
|
|
101
|
+
- PACKAGE_NAME=$(cd dist && ls *.whl | head -1)
|
|
102
|
+
- ARCHIVE_NAME=$(cd dist && ls *.tar.gz | head -1)
|
|
103
|
+
- echo "PACKAGE_NAME=${PACKAGE_NAME}" >> variables.env
|
|
104
|
+
- echo "ARCHIVE_NAME=${ARCHIVE_NAME}" >> variables.env
|
|
105
|
+
- echo "VERSION=${VERSION}" >> variables.env
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
build-release-changelog:
|
|
109
|
+
image: python:3.9
|
|
110
|
+
stage: build
|
|
111
|
+
tags:
|
|
112
|
+
- docker
|
|
113
|
+
rules:
|
|
114
|
+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
|
|
115
|
+
before_script:
|
|
116
|
+
- pip install -i https://pypi.benderrobotics.com setuptools setuptools_scm gitlab_tools build
|
|
117
|
+
script:
|
|
118
|
+
- VERSION=$(python -c "import build.util; print(build.util.project_wheel_metadata('.').get('Version'))")
|
|
119
|
+
- gitlab-tools tag-changelog -t $API_TOKEN -u $CI_SERVER_URL -p $CI_PROJECT_PATH -o changes.md
|
|
120
|
+
artifacts:
|
|
121
|
+
paths:
|
|
122
|
+
- "changes.md"
|
|
123
|
+
expire_in: 1 days
|
|
124
|
+
|
|
125
|
+
deploy-wheel:
|
|
126
|
+
stage: deploy
|
|
127
|
+
needs:
|
|
128
|
+
- build
|
|
129
|
+
tags:
|
|
130
|
+
- docker
|
|
131
|
+
image: chartedcode/alpine-sftp-client
|
|
132
|
+
before_script:
|
|
133
|
+
- echo "$PYPI_KEY" | tr -d '\r' > ./ssh_key
|
|
134
|
+
- chmod 600 ./ssh_key
|
|
135
|
+
script:
|
|
136
|
+
- TAG_VERSION=${CI_COMMIT_TAG#"v"}
|
|
137
|
+
- test $VERSION = $TAG_VERSION
|
|
138
|
+
- |
|
|
139
|
+
sftp -i ./ssh_key -oStrictHostKeyChecking=no $PYPI_USER@$PYPI_HOST:/brock/ << EOF
|
|
140
|
+
put dist/*
|
|
141
|
+
quit
|
|
142
|
+
EOF
|
|
143
|
+
rules:
|
|
144
|
+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+.*$/ && $PYPI_USER && $PYPI_KEY
|
|
145
|
+
|
|
146
|
+
deploy-pypi:
|
|
147
|
+
stage: deploy
|
|
148
|
+
needs:
|
|
149
|
+
- build
|
|
150
|
+
tags:
|
|
151
|
+
- docker
|
|
152
|
+
image: python:3.9
|
|
153
|
+
before_script:
|
|
154
|
+
- pip install twine
|
|
155
|
+
script:
|
|
156
|
+
- twine upload --repository-url $PYPI_INDEX dist/*
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
deploy-release:
|
|
160
|
+
stage: deploy
|
|
161
|
+
needs: [build]
|
|
162
|
+
image: curlimages/curl:latest
|
|
163
|
+
tags:
|
|
164
|
+
- docker
|
|
165
|
+
script:
|
|
166
|
+
- TAG_VERSION=${CI_COMMIT_TAG#"v"}
|
|
167
|
+
- test $VERSION = $TAG_VERSION
|
|
168
|
+
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "dist/${PACKAGE_NAME}" "${PACKAGE_REGISTRY}/${VERSION}/${PACKAGE_NAME}"'
|
|
169
|
+
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "dist/${ARCHIVE_NAME}" "${PACKAGE_REGISTRY}/${VERSION}/${ARCHIVE_NAME}"'
|
|
170
|
+
rules:
|
|
171
|
+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
|
|
172
|
+
|
|
173
|
+
release:
|
|
174
|
+
stage: release
|
|
175
|
+
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
176
|
+
tags:
|
|
177
|
+
- docker
|
|
178
|
+
script:
|
|
179
|
+
- TAG_VERSION=${CI_COMMIT_TAG#"v"}
|
|
180
|
+
- test $VERSION = $TAG_VERSION
|
|
181
|
+
- DESCRIPTION=$(cat changes.md)
|
|
182
|
+
- |
|
|
183
|
+
release-cli create --name "Release of Brock $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG --milestone "$CI_COMMIT_TAG" \
|
|
184
|
+
--description "$DESCRIPTION" \
|
|
185
|
+
--assets-link "{\"name\":\"${PACKAGE_NAME}\",\"url\":\"${PACKAGE_REGISTRY}/${VERSION}/${PACKAGE_NAME}\"}" \
|
|
186
|
+
--assets-link "{\"name\":\"${ARCHIVE_NAME}\",\"url\":\"${PACKAGE_REGISTRY}/${VERSION}/${ARCHIVE_NAME}\"}"
|
|
187
|
+
rules:
|
|
188
|
+
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# File introduces automated checks triggered on git events
|
|
2
|
+
# to enable run `pip install pre-commit yapf && pre-commit install`
|
|
3
|
+
|
|
4
|
+
repos:
|
|
5
|
+
- repo: local
|
|
6
|
+
hooks:
|
|
7
|
+
- id: yapf
|
|
8
|
+
name: yapf
|
|
9
|
+
language: python
|
|
10
|
+
entry: yapf
|
|
11
|
+
args: [-i]
|
|
12
|
+
types: [python]
|
|
13
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
14
|
+
rev: v3.2.0
|
|
15
|
+
hooks:
|
|
16
|
+
- id: trailing-whitespace
|
|
17
|
+
- id: check-docstring-first
|
|
18
|
+
- id: check-json
|
|
19
|
+
- id: check-yaml
|
|
20
|
+
- id: requirements-txt-fixer
|
|
21
|
+
- id: double-quote-string-fixer
|
|
22
|
+
- id: end-of-file-fixer
|
|
23
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
24
|
+
rev: v0.931
|
|
25
|
+
hooks:
|
|
26
|
+
- id: mypy
|
|
27
|
+
args: [--ignore-missing-imports]
|
|
28
|
+
additional_dependencies: ["types-PyYAML==6.0.1"]
|
|
29
|
+
exclude: 'tests'
|
|
30
|
+
- repo: meta
|
|
31
|
+
hooks:
|
|
32
|
+
- id: check-useless-excludes
|
brock-0.1.0/.style.yapf
ADDED
brock-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2021 The Python Packaging Authority
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
brock-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: brock
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Brock
|
|
5
|
+
Author-email: "Bender Robotics s.r.o" <opensource@benderrobotics.com>
|
|
6
|
+
License: Copyright (c) 2021 The Python Packaging Authority
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
|
25
|
+
|
|
26
|
+
Project-URL: Homepage, https://www.benderrobotics.com
|
|
27
|
+
Project-URL: Repository, https://github.com/BenderRobotics/brock.git
|
|
28
|
+
Project-URL: Issues, https://github.com/BenderRobotics/brock/issues
|
|
29
|
+
Keywords: build,docker,toolchain
|
|
30
|
+
Classifier: Intended Audience :: Developers
|
|
31
|
+
Classifier: Development Status :: 4 - Beta
|
|
32
|
+
Classifier: Programming Language :: Python
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
43
|
+
Classifier: Topic :: Software Development
|
|
44
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
45
|
+
Classifier: Topic :: Software Development :: Embedded Systems
|
|
46
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
47
|
+
Classifier: Operating System :: POSIX
|
|
48
|
+
Classifier: Operating System :: Unix
|
|
49
|
+
Classifier: Operating System :: MacOS
|
|
50
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
51
|
+
Requires-Python: >=3.7
|
|
52
|
+
Description-Content-Type: text/markdown
|
|
53
|
+
License-File: LICENSE
|
|
54
|
+
Requires-Dist: markupsafe==2.0.1
|
|
55
|
+
Requires-Dist: colorama>=0.4.1
|
|
56
|
+
Requires-Dist: click>=7.1.2
|
|
57
|
+
Requires-Dist: hiyapyco
|
|
58
|
+
Requires-Dist: schema
|
|
59
|
+
Requires-Dist: setuptools_scm>=7.0.0
|
|
60
|
+
Requires-Dist: munch
|
|
61
|
+
Requires-Dist: fabric
|
|
62
|
+
Requires-Dist: docker>=6.0.1
|
|
63
|
+
Requires-Dist: sentry-sdk~=1.39
|
|
64
|
+
Provides-Extra: test
|
|
65
|
+
Requires-Dist: pytest; extra == "test"
|
|
66
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
67
|
+
|
|
68
|
+
# Bender Robotics command management system
|
|
69
|
+
Brock is a Python-based automation tool for launching commands in various
|
|
70
|
+
executors like Docker or remote systems. It was designed mainly for building
|
|
71
|
+
and testing automation of embedded software in Docker-based executors.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## Installation
|
|
75
|
+
|
|
76
|
+
### Prerequisities
|
|
77
|
+
Brock needs Docker to be installed and configured properly:
|
|
78
|
+
1. Install [Windows Subsystem for Linux 2](https://docs.microsoft.com/cs-cz/windows/wsl/install-win10).
|
|
79
|
+
2. Download and install [Docker Desktop](https://www.docker.com/products/docker-desktop).
|
|
80
|
+
3. Switch to Windows containers if the executor is Windows-based - click Docker
|
|
81
|
+
Desktop icon and select Switch to Windows containers... (requires Windows Pro
|
|
82
|
+
or Enterprise), or turn experimental features on - open Docker Desktop, go to
|
|
83
|
+
Settings -> Docker Engine, set `"experimental": true` (allows to use Linux
|
|
84
|
+
and Windows containers simultaneously).
|
|
85
|
+
|
|
86
|
+
### Brock
|
|
87
|
+
You can install Brock from BR's pypi, download wheel from release page or
|
|
88
|
+
build it yourself - see [Contributing](#Contributing)...
|
|
89
|
+
```shell
|
|
90
|
+
$ pip install brock
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Usage
|
|
94
|
+
Brock scans all directories from drive root to current directory and looks
|
|
95
|
+
for `.brock.yml` config files. The format of the files is described in
|
|
96
|
+
[example_brock.yml](example_brock.yml).
|
|
97
|
+
|
|
98
|
+
The configuration files are merged together, the highest priority config file
|
|
99
|
+
is the one in the current directory. Individual config files don't have to be
|
|
100
|
+
complete, however, the merged configuration must contain all required
|
|
101
|
+
parameters.
|
|
102
|
+
|
|
103
|
+
The lowest priority config file determines the base directory which will be
|
|
104
|
+
used as a working directory for the executor (e.g. mounted to docker, mounted
|
|
105
|
+
over SSH). The commands should not access files outside this directory.
|
|
106
|
+
|
|
107
|
+
The list of all available commands is provided by `brock --help`, let's assume
|
|
108
|
+
a command `test` was defined in the `.brock.yml`, you can run it like this:
|
|
109
|
+
```shell
|
|
110
|
+
$ brock test
|
|
111
|
+
>> Executor not running -> starting
|
|
112
|
+
>> Pulling image python:3.9
|
|
113
|
+
./debug/test -s
|
|
114
|
+
|
|
115
|
+
Unity test run 1 of 1
|
|
116
|
+
|
|
117
|
+
-----------------------
|
|
118
|
+
483 Tests 0 Failures 0 Ignored
|
|
119
|
+
OK
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
If the required executor is not running, it is started automatically when
|
|
123
|
+
executing a command. It stays running until it is explicitly stopped by
|
|
124
|
+
`brock --stop`. The executors can also be restarted (e.g. to fetch changes in
|
|
125
|
+
the brock configuration) by `brock --restart`. The current state of the
|
|
126
|
+
executors is printed by `brock --status`.
|
|
127
|
+
|
|
128
|
+
The docker image can be pulled again or rebuilt (if using Dockerfile) using
|
|
129
|
+
`brock --update`.
|
|
130
|
+
|
|
131
|
+
If needed, you can launch a custom command directly in the executor by
|
|
132
|
+
`brock exec`:
|
|
133
|
+
```shell
|
|
134
|
+
$ brock exec @python 'python --version'
|
|
135
|
+
Python 3.9.10
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Optionally, quotes or double-dash (`--`) can be used to avoid brock collecting
|
|
139
|
+
options destined to the command launched by executor:
|
|
140
|
+
```shell
|
|
141
|
+
$ brock exec @python "python --version"
|
|
142
|
+
Python 3.9.10
|
|
143
|
+
$ brock exec @python -- python --version
|
|
144
|
+
Python 3.9.10
|
|
145
|
+
|
|
146
|
+
If using a custom Docker registry, do not forget to login into the registry
|
|
147
|
+
before using `brock` - use full registry path including image name and tag:
|
|
148
|
+
```shell
|
|
149
|
+
$ docker login $IMAGE_REGISTRY
|
|
150
|
+
Username: $USER_NAME
|
|
151
|
+
Password:
|
|
152
|
+
Login Succeeded
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
If using Docker executor, you can launch a shell using `brock shell` (default
|
|
156
|
+
executor will be used if ommited):
|
|
157
|
+
```shell
|
|
158
|
+
$ brock shell @gcc
|
|
159
|
+
root@6bf119cb7b6a:/host# exit
|
|
160
|
+
exit
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Brock sets the following predefined environmental variables:
|
|
164
|
+
- `BROCK_HOST_PATH` - absolute path to current directory on host
|
|
165
|
+
- `BROCK_HOST_PROJECT_PATH` - absolute path to project root on host
|
|
166
|
+
- `BROCK_RELATIVE_PATH` - relative path from project root to current directory
|
|
167
|
+
|
|
168
|
+
Additional variables can be set using the config option `env` for each executor.
|
|
169
|
+
|
|
170
|
+
#### Options
|
|
171
|
+
Brock offers the possibility of options in commands.
|
|
172
|
+
Configuration of options in .brock.yaml (see example_brock.yml)
|
|
173
|
+
|
|
174
|
+
opt-name:
|
|
175
|
+
- flag: str | None -> option is a flag e.g. `brock build --verbose`
|
|
176
|
+
|
|
177
|
+
- argument: str | None -> option is an argument e.g. `brock build something`,
|
|
178
|
+
can be * then an unlimited number of arguments is accepted
|
|
179
|
+
|
|
180
|
+
- default: any | None -> any value
|
|
181
|
+
|
|
182
|
+
- choice: list[str] -> list of acceptable values, brock checks input is in choice and also displays it in help
|
|
183
|
+
|
|
184
|
+
- variable: str | None -> optional custom name of the variable inside the session, to avoid any conflicts with built-in variables
|
|
185
|
+
|
|
186
|
+
- help: str | None
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
### Isolation types
|
|
190
|
+
The Brock can detect Windows version and the version of the Windows Docker
|
|
191
|
+
image, the needed isolation mode is determined automatically - if possible,
|
|
192
|
+
the image is started in `process` isolation, `hyperv` is used otherwise.
|
|
193
|
+
|
|
194
|
+
### Volume synchronization
|
|
195
|
+
To achieve satisfactory performance when using Linux containers on Windows
|
|
196
|
+
(or macOS), the project folder needs to be mounted more efficiently. For this
|
|
197
|
+
purpose, two volume synchronization mechanisms are available: Rsync or Mutagen.
|
|
198
|
+
|
|
199
|
+
#### Rsync
|
|
200
|
+
An additional container with Rsync is started - the project folder is mounted to
|
|
201
|
+
this container together with a named volume (that will reside inside the Linux
|
|
202
|
+
host) and these folders are then being synced using Rsync. To turn this feature
|
|
203
|
+
on, use the `sync` option in the config file.
|
|
204
|
+
|
|
205
|
+
Optionally, specific files/folders can be excluded from sync using
|
|
206
|
+
configuration option `exclude` under `sync` section.
|
|
207
|
+
|
|
208
|
+
#### Mutagen
|
|
209
|
+
Another option to synchronize volumes on macOS or Windows is to use
|
|
210
|
+
[Mutagen Extension](https://mutagen.io/documentation/docker-desktop-extension)
|
|
211
|
+
for Docker Desktop. Before use, it must be installed first:
|
|
212
|
+
```shell
|
|
213
|
+
docker extension install mutagenio/docker-desktop-extension:latest
|
|
214
|
+
```
|
|
215
|
+
Then, a cache must be created for each path which should be synchronized. Go to
|
|
216
|
+
Docker Desktop -> Extensions -> Mutagen, click Create Cache and enter the
|
|
217
|
+
project root path. Finally, configure the executor to use Mutagen
|
|
218
|
+
volume synchronization (see `example_brock.yml`).
|
|
219
|
+
|
|
220
|
+
### Devices in Docker executor
|
|
221
|
+
The docker can use the system devices if passed correctly, however this only
|
|
222
|
+
works when running a native container - e.g. a Windows container with the same
|
|
223
|
+
system version as the Windows host, or a Linux container under a Linux host.
|
|
224
|
+
Check the `devices` section of the config file.
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
## Build
|
|
228
|
+
Please first apply all steps in [contributing section](#Contributing).
|
|
229
|
+
|
|
230
|
+
After that you can call build scripts:
|
|
231
|
+
```shell
|
|
232
|
+
$ python build/build.py # builds the package
|
|
233
|
+
```
|
|
234
|
+
You can find build artifacts in the newly created dist folder.
|
|
235
|
+
|
|
236
|
+
## Contributing
|
|
237
|
+
Here is a short guide to ease you up contributing.
|
|
238
|
+
|
|
239
|
+
Start by installing virtual environment package
|
|
240
|
+
```shell
|
|
241
|
+
$ pip install virtualenv
|
|
242
|
+
```
|
|
243
|
+
Then create your own virtual environment
|
|
244
|
+
```shell
|
|
245
|
+
$ virtualenv venv
|
|
246
|
+
```
|
|
247
|
+
Now you should see venv folder in the project structure.
|
|
248
|
+
Activate virtual environment
|
|
249
|
+
```shell
|
|
250
|
+
$ source venv/bin/activate # on linux
|
|
251
|
+
$ venv\Scripts\activate.bat # on windows
|
|
252
|
+
```
|
|
253
|
+
After that you should see (venv) as prefix to your command line cursor.
|
|
254
|
+
Note you need to repeat activation every time you close the terminal.
|
|
255
|
+
|
|
256
|
+
To install the package in development mode call:
|
|
257
|
+
```shell
|
|
258
|
+
$ pip install -e .
|
|
259
|
+
```
|
|
260
|
+
Now you can call Brock directly from the command line and all changes to the
|
|
261
|
+
source code are instantly applied.
|