Skip to content

Commit

Permalink
enable custom .repos filename
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbusch committed Oct 10, 2023
1 parent 4ff69fc commit 37a86f2
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitlab-ci/docker-ros.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ variables:
ENABLE_RECURSIVE_ADDITIONAL_PIP: 'false' # Enable recursive discovery of files named `additional-pip-file`
CUSTOM_SCRIPT_FILE: docker/custom.sh # Relative filepath to script containing custom installation commands
ENABLE_RECURSIVE_CUSTOM_SCRIPT: 'false' # Enable recursive discovery of files named `custom-script-file`
ADDITIONAL_REPOS_FILE: .repos # Relative filepath to script containing custom installation commands
ENABLE_RECURSIVE_VCS_IMPORT: 'true' # Enable recursive discovery of files named `additional-repos-file`
# -----
DOCKER_ROS_GIT_REF: main
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,10 @@ Create a folder `additional-files` in your `docker` folder (or configure a diffe
*default:* `docker/additional-files`
- **`additional-pip-file` | `ADDITIONAL_PIP_FILE`**
Relative filepath to file containing additional pip packages to install
*default:* `docker/additional-pip-requirements.txt`
*default:* `docker/additional-pip-requirements.txt`
- **`additional-repos-file` | `ADDITIONAL_REPOS_FILE`**
Relative filepath to file containing additional repos to install via vcstools
*default:* `.repos`
- **`base-image` | `BASE_IMAGE`**
Base image `name:tag`
*required*
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ runs:
ENABLE_RECURSIVE_ADDITIONAL_PIP: ${{ inputs.enable-recursive-additional-pip }}
CUSTOM_SCRIPT_FILE: ${{ inputs.custom-script-file }}
ENABLE_RECURSIVE_CUSTOM_SCRIPT: ${{ inputs.enable-recursive-custom-script }}
ADDITIONAL_REPOS_FILE: ${{ inputs.additional-repos-file }}
ENABLE_RECURSIVE_VCS_IMPORT: ${{ inputs.enable-recursive-vcs-import }}

- name: Set up industrial_ci
Expand Down Expand Up @@ -228,6 +229,7 @@ runs:
ENABLE_RECURSIVE_ADDITIONAL_PIP: ${{ inputs.enable-recursive-additional-pip }}
CUSTOM_SCRIPT_FILE: ${{ inputs.custom-script-file }}
ENABLE_RECURSIVE_CUSTOM_SCRIPT: ${{ inputs.enable-recursive-custom-script }}
ADDITIONAL_REPOS_FILE: ${{ inputs.additional-repos-file }}
ENABLE_RECURSIVE_VCS_IMPORT: ${{ inputs.enable-recursive-vcs-import }}
_ENABLE_IMAGE_PUSH: true
_IMAGE_POSTFIX: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) && format('_{0}_ci', steps.slugify-ref-name.outputs.slug) || '' }}
Expand Down Expand Up @@ -260,6 +262,7 @@ runs:
ENABLE_RECURSIVE_ADDITIONAL_PIP: ${{ inputs.enable-recursive-additional-pip }}
CUSTOM_SCRIPT_FILE: ${{ inputs.custom-script-file }}
ENABLE_RECURSIVE_CUSTOM_SCRIPT: ${{ inputs.enable-recursive-custom-script }}
ADDITIONAL_REPOS_FILE: ${{ inputs.additional-repos-file }}
ENABLE_RECURSIVE_VCS_IMPORT: ${{ inputs.enable-recursive-vcs-import }}
_ENABLE_IMAGE_PUSH: true
_IMAGE_POSTFIX: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) && format('_{0}_ci', steps.slugify-ref-name.outputs.slug) || '' }}
6 changes: 4 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ COPY docker/docker-ros/docker/recursive_vcs_import.py /usr/local/bin
RUN apt-get update && \
apt-get install -y python-is-python3 && \
rm -rf /var/lib/apt/lists/*

ARG ADDITIONAL_REPOS_FILE=".repos"
ARG ENABLE_RECURSIVE_VCS_IMPORT="true"
RUN if [[ $ENABLE_RECURSIVE_ADDITIONAL_DEBS == 'true' ]]; then \
/usr/local/bin/recursive_vcs_import.py src src/upstream ; \
/usr/local/bin/recursive_vcs_import.py src/target src/upstream ${ADDITIONAL_REPOS_FILE}; \
else \
vcs import src/upstream < src/target/.repos ; \
vcs import src/upstream < src/target/${ADDITIONAL_REPOS_FILE} ; \
fi

# create install script with list of rosdep dependencies
Expand Down
9 changes: 6 additions & 3 deletions docker/recursive_vcs_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@
from typing import List, Optional


def findDotRepos(search_path: str, clone_path: Optional[str] = None) -> List[pathlib.Path]:
def findDotRepos(search_path: str, clone_path: Optional[str] = None, repos_file: str = ".repos") -> List[pathlib.Path]:

repos = list(pathlib.Path(search_path).glob("**/*.repos"))
if clone_path is not None:
repos.extend(list(pathlib.Path(clone_path).glob("**/*.repos")))
repos.extend(list(pathlib.Path(clone_path).glob("**/*.repos"))) # find .repos in upstream dependencies
else:
repos = list(pathlib.Path(search_path).glob(f"**/*{repos_file}")) # find .repos in target repo
return repos

def main():

search_path = sys.argv[1] if len(sys.argv) > 1 else "."
clone_path = sys.argv[2] if len(sys.argv) > 2 else "."
repos_file = sys.argv[3] if len(sys.argv) > 3 else ".repos"
cloned_repos = []

while True:

found_repos = findDotRepos(search_path, clone_path)
found_repos = findDotRepos(search_path, clone_path, repos_file)
remaining_repos = set(found_repos) - set(cloned_repos)

if not remaining_repos:
Expand Down
1 change: 1 addition & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ build_image() {
$(if [[ -n "${ENABLE_RECURSIVE_ADDITIONAL_PIP}" ]]; then echo "--build-arg ENABLE_RECURSIVE_ADDITIONAL_PIP=${ENABLE_RECURSIVE_ADDITIONAL_PIP}"; fi) \
$(if [[ -n "${CUSTOM_SCRIPT_FILE}" ]]; then echo "--build-arg CUSTOM_SCRIPT_FILE=${CUSTOM_SCRIPT_FILE}"; fi) \
$(if [[ -n "${ENABLE_RECURSIVE_CUSTOM_SCRIPT}" ]]; then echo "--build-arg ENABLE_RECURSIVE_CUSTOM_SCRIPT=${ENABLE_RECURSIVE_CUSTOM_SCRIPT}"; fi) \
$(if [[ -n "${ADDITIONAL_REPOS_FILE}" ]]; then echo "--build-arg ADDITIONAL_REPOS_FILE=${ADDITIONAL_REPOS_FILE}"; fi) \
$(if [[ -n "${ENABLE_RECURSIVE_VCS_IMPORT}" ]]; then echo "--build-arg ENABLE_RECURSIVE_VCS_IMPORT=${ENABLE_RECURSIVE_VCS_IMPORT}"; fi) \
.
echo "Successfully built stage '${TARGET}' for platform '${PLATFORM}' as '${IMAGE}'"
Expand Down
1 change: 1 addition & 0 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ADDITIONAL_PIP_FILE="${ADDITIONAL_PIP_FILE:-}"
ENABLE_RECURSIVE_ADDITIONAL_PIP="${ENABLE_RECURSIVE_ADDITIONAL_PIP:-}"
CUSTOM_SCRIPT_FILE="${CUSTOM_SCRIPT_FILE:-}"
ENABLE_RECURSIVE_CUSTOM_SCRIPT="${ENABLE_RECURSIVE_CUSTOM_SCRIPT:-}"
ADDITIONAL_REPOS_FILE="${ADDITIONAL_REPOS_FILE:-}"
ENABLE_RECURSIVE_VCS_IMPORT="${ENABLE_RECURSIVE_VCS_IMPORT:-}"
_ENABLE_IMAGE_PUSH="${_ENABLE_IMAGE_PUSH:-false}"
_IMAGE_POSTFIX="${_IMAGE_POSTFIX:-""}"
Expand Down
1 change: 1 addition & 0 deletions templates/docker-compose.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ x-build: &build
ADDITIONAL_DEBS_FILE: $ADDITIONAL_DEBS_FILE
ADDITIONAL_FILES_DIR: $ADDITIONAL_FILES_DIR
ADDITIONAL_PIP_FILE: $ADDITIONAL_PIP_FILE
ADDITIONAL_REPOS_FILE: $ADDITIONAL_REPOS_FILE
CUSTOM_SCRIPT_FILE: $CUSTOM_SCRIPT_FILE
ENABLE_RECURSIVE_ADDITIONAL_DEBS: $ENABLE_RECURSIVE_ADDITIONAL_DEBS
ENABLE_RECURSIVE_ADDITIONAL_PIP: $ENABLE_RECURSIVE_ADDITIONAL_PIP
Expand Down

0 comments on commit 37a86f2

Please sign in to comment.