From 7999f78541c7b41552bfedb1fd69ad05dc589bca Mon Sep 17 00:00:00 2001 From: hhenry01 Date: Thu, 14 Sep 2023 16:47:40 -0700 Subject: [PATCH] Temporary commit to test CI --- .devcontainer/devcontainer.json | 4 ++-- .devcontainer/docker-compose.ci.yml | 27 ++++++++++++++++++++++---- .devcontainer/docker-compose.yml | 3 +++ .github/workflows/test_definitions.yml | 9 ++++++++- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c652e572b..30c9233b5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,9 +5,9 @@ // Uncomment the files containing the programs you need // "docker-compose.docs.yml", // docs // "docker-compose.website.yml", // grafana, website + // "docker-compose.db.yml", // mongodb - "docker-compose.yml", - "docker-compose.db.yml" // mongodb + "docker-compose.yml" ], "forwardPorts": [ 3000, // grafana diff --git a/.devcontainer/docker-compose.ci.yml b/.devcontainer/docker-compose.ci.yml index c41f01c8e..da1a0b685 100644 --- a/.devcontainer/docker-compose.ci.yml +++ b/.devcontainer/docker-compose.ci.yml @@ -3,18 +3,37 @@ version: '3.8' services: + # mongodb_container: + # image: mongo:latest + # environment: + # MONGO_INITDB_ROOT_USERNAME: root + # MONGO_INITDB_ROOT_PASSWORD: rootpassword + # ports: + # - 27017:27017 sailbot-workspace: build: context: . dockerfile: Dockerfile - # URL: mongodb://localhost:27017 - mongodb: + # NOTE: CI reads environment variables from sailbot_workspace/.github/workflows/test_definitions.yml instead of here + environment: + - MONGODB_CONN_STR=mongodb://root:rootpassword@mongodb_container:27017 + # Initialize mongodb and keep the service running + # command: '/bin/bash -c "sleep 5; mongosh $$CONN_STR --eval \"show dbs;\""; sleep infinity' + command: 'sleep infinity' + depends_on: + - mongodb_container + + # # URL: mongodb://mongodb:27017 + mongodb_container: image: mongo:latest restart: unless-stopped + environment: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: rootpassword + ports: + - 27017:27017 - # 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: diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index da1dc0148..a18e265c6 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -12,6 +12,9 @@ services: - sailbot-new-project-bashhistory:/home/ros/commandhistory:delegated - sailbot-new-project-roslog:/home/ros/.ros/log:delegated + environment: + - MONGODB_CONN_STR=mongodb://localhost:27017 + # Overrides default command so things don't shut down after the process ends. command: sleep infinity diff --git a/.github/workflows/test_definitions.yml b/.github/workflows/test_definitions.yml index c78133d22..f96ef4809 100644 --- a/.github/workflows/test_definitions.yml +++ b/.github/workflows/test_definitions.yml @@ -46,6 +46,7 @@ jobs: uses: actions/checkout@v4 with: repository: UBCSailbot/sailbot_workspace + ref: user/hhenry01/enable-docker-ci - name: Checkout ROS package if: ${{ inputs.repository != 'sailbot_workspace' }} @@ -63,12 +64,18 @@ jobs: - name: Start MongoDB if: ${{ inputs.repository != 'sailbot_workspace' && inputs.repository != 'custom_interfaces' }} - run: docker-compose -f ".devcontainer/docker-compose.ci.yml" up -d --build + # URL to mongosh command must match what is defined in sailbot_workspace/.devcontainer/.docker-compose.ci.yml + run: docker compose -f .devcontainer/docker-compose.ci.yml up -d && docker compose -f .devcontainer/docker-compose.ci.yml run sailbot-workspace mongosh "mongodb://mongodb_container:27017" + + # - name: Get MongoDB Connection String + # if: ${{ inputs.repository != 'sailbot_workspace' && inputs.repository != 'custom_interfaces' }} + # run: docker network ls && docker network inspect devcontainer_default && echo "MONGODB_CONN_STR=mongodb://$(docker network inspect devcontainer_default | grep mongodb -A 3 | grep IPv4Address | cut -d "\"" -f 4 | cut -d "/" -f 1):27017" >> $GITHUB_ENV - name: Test uses: ./.github/actions/test/ env: DISABLE_VCS: ${{ inputs.repository != 'sailbot_workspace' }} + # MONGODB_CONN_STR: $MONGODB_CONN_STR - name: Stop MongoDB if: ${{ inputs.repository != 'sailbot_workspace' && inputs.repository != 'custom_interfaces' }}