Skip to content

Commit 4efe8fb

Browse files
Update/iron (#70)
* Add script to add submodules to workspace from repos file (#59) * Update workflow to only trigger when pushing to specific branches (#60) * Bump athackst/mkdocs-simple-plugin from 2.3.0 to 3.0.0 (#61) * Bump athackst/mkdocs-simple-plugin from 3.0.0 to 3.1.0 (#62) * Bump actions/checkout from 3 to 4 (#64) * Add rosdistro to setup and update purge command (#68) * Remove eol foxy and add rolling to ros workflow (#69) * Updates to work with iron --------- Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent e582227 commit 4efe8fb

File tree

6 files changed

+89
-7
lines changed

6 files changed

+89
-7
lines changed

.devcontainer/repos_to_submodules.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import glob
2+
import os
3+
import subprocess
4+
import yaml
5+
6+
prefix="src"
7+
8+
def add_git_submodule(repo_name, repo_url, repo_version):
9+
subprocess.call(['git', 'submodule', 'add', '-b', repo_version, repo_url, repo_name])
10+
11+
def is_submodule(repo_name):
12+
try:
13+
subprocess.check_output(['git', 'submodule', 'status', repo_name], stderr=subprocess.DEVNULL)
14+
return True
15+
except subprocess.CalledProcessError:
16+
return False
17+
18+
def parse_repos_file(file_path):
19+
with open(file_path, 'r') as file:
20+
repos_data = yaml.safe_load(file)
21+
repositories = repos_data['repositories']
22+
23+
for repo_name, repo_info in repositories.items():
24+
if 'type' in repo_info and repo_info['type'] == 'git':
25+
repo_url = repo_info['url']
26+
repo_version = repo_info['version']
27+
submodule_name = os.path.join(prefix, repo_name)
28+
29+
if not is_submodule(submodule_name):
30+
add_git_submodule(submodule_name, repo_url, repo_version)
31+
print(f"Added {repo_name} as a submodule.")
32+
33+
# Find .repos files within the src directory
34+
repos_files = glob.glob('src/**/*.repos', recursive=True)
35+
36+
# Process each .repos file
37+
for repos_file in repos_files:
38+
parse_repos_file(repos_file)

.github/workflows/docs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1616
- name: Build and push docs
17-
uses: athackst/mkdocs-simple-plugin@v2.3.0
17+
uses: athackst/mkdocs-simple-plugin@v3.1.0

.github/workflows/ros.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: ROS
33
on:
44
pull_request:
55
push:
6+
branches:
7+
- humble*
8+
- iron*
9+
- rolling*
610
workflow_dispatch:
711

812
jobs:
@@ -12,7 +16,7 @@ jobs:
1216
steps:
1317
-
1418
name: Checkout code
15-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
1620
-
1721
name: Test
1822
uses: ./.github/actions/test/
@@ -27,9 +31,19 @@ jobs:
2731
steps:
2832
-
2933
name: Checkout code
30-
uses: actions/checkout@v3
34+
uses: actions/checkout@v4
3135
-
3236
name: Run linter
3337
uses: ./.github/actions/lint/
3438
env:
3539
LINTER: ${{ matrix.linter }}
40+
41+
complete:
42+
name: Tests passed
43+
needs:
44+
- lint
45+
- test
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Check
49+
run: echo "Completed successfully!"

.vscode/tasks.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"label": "purge",
5252
"detail": "Purge workspace by deleting all generated files.",
5353
"type": "shell",
54-
"command": "rm -fr build install log; py3clean .",
54+
"command": "sudo rm -fr build install log; sudo py3clean .",
5555
"problemMatcher": []
5656
},
5757
// Linting and static code analysis tasks
@@ -228,6 +228,13 @@
228228
"type": "shell",
229229
"command": "./setup.sh",
230230
"problemMatcher": []
231+
},
232+
{
233+
"label": "add submodules from .repos",
234+
"detail": "Create a git submodule for all repositories in your .repos file",
235+
"type": "shell",
236+
"command": "python3 .devcontainer/repos_to_submodules.py",
237+
"problemMatcher": []
231238
}
232239
],
233240
"inputs": [

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,26 @@ If you want to access the vGPU through WSL2, you'll need to add additional compo
143143
"LIBGL_ALWAYS_SOFTWARE": "1" // Needed for software rendering of opengl
144144
},
145145
```
146+
147+
### Repos are not showing up in VS Code source control
148+
149+
This is likely because vscode doesn't necessarily know about other repositories unless you've added them directly.
150+
151+
```
152+
File->Add Folder To Workspace
153+
```
154+
155+
![Screenshot-26](https://github.com/athackst/vscode_ros2_workspace/assets/6098197/d8711320-2c16-463b-9d67-5bd9314acc7f)
156+
157+
158+
Or you've added them as a git submodule.
159+
160+
![Screenshot-27](https://github.com/athackst/vscode_ros2_workspace/assets/6098197/8ebc9aac-9d70-4b53-aa52-9b5b108dc935)
161+
162+
To add all of the repos in your *.repos file, run the script
163+
164+
```bash
165+
python3 .devcontainer/repos_to_submodules.py
166+
```
167+
168+
or run the task titled `add submodules from .repos`

setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ set -e
33

44
vcs import < src/ros2.repos src
55
sudo apt-get update
6-
rosdep update
7-
rosdep install --from-paths src --ignore-src -y
6+
rosdep update --rosdistro=$ROS_DISTRO
7+
rosdep install --from-paths src --ignore-src -y --rosdistro=$ROS_DISTRO

0 commit comments

Comments
 (0)