Skip to content

Commit

Permalink
Integrate website into tests (#235)
Browse files Browse the repository at this point in the history
* Run website by default

* Run website by default in CI

* Pin mongodb major version

* Clean and populate sailbot_db before running tests

* Checkout net when running local pathfinding

* Print website logs

* Run setup script first

* Run container first

* Cleanup

* Run setup automatically after rebuild

* Forward website port in compose file

* Checkout website repo in local pathfinding CI

* Another missing repo for local pathfinding ci

* Revert local pathfinding branch

---------

Co-authored-by: Sean Donaghy <[email protected]>
  • Loading branch information
patrick-5546 and SPDonaghy authored Mar 6, 2024
1 parent 6166b71 commit b21e268
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 38 deletions.
5 changes: 2 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
"name": "Sailbot Workspace",
"dockerComposeFile": [
// Uncomment the files containing the programs you need
"docker-compose.db.yml", // mongodb
// "docker-compose.docs.yml", // docs
// "docker-compose.website.yml", // website
"docker-compose.website.yml", // website

"docker-compose.yml"
],
"forwardPorts": [
3005, // website
8000 // docs
],
"service": "sailbot-workspace",
Expand All @@ -19,6 +17,7 @@
"containerEnv": {
"LIBGL_ALWAYS_SOFTWARE": "1" // Needed for software rendering of opengl
},
"postCreateCommand": "./setup.sh",
// Set *default* container specific settings.json values on container create.
"customizations": {
"codespaces": {
Expand Down
23 changes: 0 additions & 23 deletions .devcontainer/docker-compose.db.yml

This file was deleted.

19 changes: 19 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ services:
build:
context: .
dockerfile: Dockerfile
ports:
- "3005:3005"
volumes:
- ..:/workspaces/sailbot_workspace:cached
- sailbot-new-project-bashhistory:/home/ros/commandhistory:delegated
Expand All @@ -22,6 +24,23 @@ services:
- seccomp:unconfined
- apparmor:unconfined

# URL: mongodb://localhost:27017
mongodb:
image: mongo:7
restart: unless-stopped
volumes:
- mongodb-data:/data/db:delegated

# Runs on the same network as the workspace container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:sailbot-workspace

# Uncomment to change startup options
# environment:
# MONGO_INITDB_ROOT_USERNAME: root
# MONGO_INITDB_ROOT_PASSWORD: example
# MONGO_INITDB_DATABASE: your-database-here

volumes:
mongodb-data:
sailbot-new-project-bashhistory:
sailbot-new-project-roslog:
6 changes: 3 additions & 3 deletions .github/actions/ament-lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ runs:
steps:
- name: Build Containers
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml build
run: docker compose -f .devcontainer/docker-compose.yml build

- name: Run Containers
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml up -d
run: docker compose -f .devcontainer/docker-compose.yml up -d

- name: Run Tests
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml exec -T sailbot-workspace /bin/bash -c "export LINTER=${{ inputs.linter}} && export DISABLE_VCS=${{ inputs.disable_vcs }} && cd /workspaces/sailbot_workspace && .github/actions/ament-lint/run.sh"
run: docker compose -f .devcontainer/docker-compose.yml exec -T sailbot-workspace /bin/bash -c "export LINTER=${{ inputs.linter}} && export DISABLE_VCS=${{ inputs.disable_vcs }} && cd /workspaces/sailbot_workspace && .github/actions/ament-lint/run.sh"
16 changes: 15 additions & 1 deletion .github/actions/checkout/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,22 @@ runs:
repository: UBCSailbot/custom_interfaces
path: src/custom_interfaces

- name: Checkout network_systems ROS package
if: ${{ inputs.repository != 'sailbot_workspace' && inputs.repository == 'local_pathfinding' }}
uses: actions/checkout@v4
with:
repository: UBCSailbot/network_systems
path: src/network_systems

- name: Checkout website ROS package
if: ${{ inputs.repository != 'sailbot_workspace' && inputs.repository == 'local_pathfinding' }}
uses: actions/checkout@v4
with:
repository: UBCSailbot/website
path: src/website

- name: Checkout virtual_iridium repository
if: ${{ inputs.repository != 'sailbot_workspace' && inputs.repository == 'network_systems' }}
if: ${{ inputs.repository != 'sailbot_workspace' && (inputs.repository == 'network_systems' || inputs.repository == 'local_pathfinding') }}
uses: actions/checkout@v4
with:
repository: UBCSailbot/virtual_iridium
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/clang-tidy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ runs:
steps:
- name: Build Containers
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml build
run: docker compose -f .devcontainer/docker-compose.yml build

- name: Run Containers
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml up -d
run: docker compose -f .devcontainer/docker-compose.yml up -d

- name: Run Tests
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml exec -T sailbot-workspace /bin/bash -c "export DISABLE_VCS=${{ inputs.disable_vcs }} && cd /workspaces/sailbot_workspace && .github/actions/clang-tidy/run.sh"
run: docker compose -f .devcontainer/docker-compose.yml exec -T sailbot-workspace /bin/bash -c "export DISABLE_VCS=${{ inputs.disable_vcs }} && cd /workspaces/sailbot_workspace && .github/actions/clang-tidy/run.sh"
11 changes: 7 additions & 4 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ inputs:
runs:
using: "composite"
steps:
- name: Build Containers
# TODO: remove once monorepo and combine website docker compose into main one
- name: Setup Code
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml -f .devcontainer/docker-compose.db.yml build
run: |
docker compose -f .devcontainer/docker-compose.yml up -d
docker compose -f .devcontainer/docker-compose.yml exec -T sailbot-workspace /bin/bash -c "export DISABLE_VCS=${{ inputs.disable_vcs }} && cd /workspaces/sailbot_workspace && ./setup.sh"
- name: Run Containers
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml -f .devcontainer/docker-compose.db.yml up -d
run: docker compose -f .devcontainer/docker-compose.yml -f .devcontainer/docker-compose.website.yml up -d

- name: Run Tests
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml -f .devcontainer/docker-compose.db.yml exec -T sailbot-workspace /bin/bash -c "export DISABLE_VCS=${{ inputs.disable_vcs }} && cd /workspaces/sailbot_workspace && .github/actions/test/run.sh"
run: docker compose -f .devcontainer/docker-compose.yml -f .devcontainer/docker-compose.website.yml exec -T sailbot-workspace /bin/bash -c "export DISABLE_VCS=${{ inputs.disable_vcs }} && cd /workspaces/sailbot_workspace && .github/actions/test/run.sh"
11 changes: 10 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ trap 'exit' INT TERM
trap 'signal_handler' EXIT

if [ -f install/local_setup.bash ]; then source install/local_setup.bash; fi
if [ -d src/network_systems ]; then ./run_virtual_iridium.sh &> /dev/null & fi

NET_DIR=src/network_systems
if [ -d $NET_DIR ]; then
./run_virtual_iridium.sh &> /dev/null &
pushd $NET_DIR
./scripts/sailbot_db sailbot_db --clear
./scripts/sailbot_db sailbot_db --populate
popd
fi

colcon test --packages-ignore virtual_iridium --merge-install --event-handlers console_cohesion+
colcon test-result
exit 0

0 comments on commit b21e268

Please sign in to comment.