diff --git a/.github/workflows/new-pycram-ci.yml b/.github/workflows/new-pycram-ci.yml new file mode 100644 index 000000000..07678b99d --- /dev/null +++ b/.github/workflows/new-pycram-ci.yml @@ -0,0 +1,72 @@ +name: pycram_docker_ci +defaults: + run: + shell: bash -ieo pipefail {0} + +on: + push: + branches: + - dev + - master + pull_request: + branches: + - master + - dev + workflow_dispatch: # For manual debugging + inputs: + debug_enabled: + type: boolean + required: false + default: false + description: "Run tmate session" + +jobs: + build_and_run_tests: + runs-on: ubuntu-20.04 + container: + image: "pycram/pycram:dev" + steps: + - name: Checkout PyCRAM + uses: actions/checkout@v3 + with: + path: "ros/src/pycram" + repository: ${{ github.repository }} + ref: ${{ github.ref }} + submodules: "recursive" + + # For debugging + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} + + - name: Update PyCRAM source files + run: | + rm -rf /opt/ros/overlay_ws/src/pycram/* + cd /opt/ros/overlay_ws/src/pycram + rm -rf .git .github .gitignore .gitmodules .readthedocs.yaml + mv /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}/ros/src/pycram /opt/ros/overlay_ws/src + + - name: Remake workspace & start roscore + run: | + sudo -s + source /opt/ros/noetic/setup.bash + cd /opt/ros/overlay_ws + catkin_make + source /opt/ros/overlay_ws/devel/setup.bash + roslaunch pycram ik_and_description.launch & + + - name: Install python dependencies + run: | + pip3 install --upgrade pip --root-user-action=ignore + cd /opt/ros/overlay_ws/src/pycram + pip3 install -r requirements.txt + + - name: Install pytest, pyjpt & mlflow + run: | + pip3 install --ignore-installed pytest pyjpt mlflow + + - name: Run tests + run: | + source /opt/ros/overlay_ws/devel/setup.bash + roscd pycram + pytest -v test diff --git a/.github/workflows/pycram-ci.yml b/.github/workflows/pycram-ci.yml deleted file mode 100644 index 2c0e299c9..000000000 --- a/.github/workflows/pycram-ci.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: CI standalone -defaults: - run: - shell: bash -ieo pipefail {0} -on: - push: - branches: - - dev - - master - pull_request: - branches: - - master - - dev -jobs: - Build_and_run_Tests: - runs-on: ubuntu-20.04 - steps: - - name: Checkout pycram - uses: actions/checkout@v3 - with: - path: 'ros_ws/src/pycram' - repository: ${{github.repository}} - ref: ${{github.ref}} - submodules: recursive - - - name: Checkout iai_maps - uses: actions/checkout@v3 - with: - path: 'ros_ws/src/iai_maps' - repository: code-iai/iai_maps - ref: master - - name: Checkout iai_robots - uses: actions/checkout@v3 - with: - path: 'ros_ws/src/iai_robots' - repository: code-iai/iai_robots - ref: master - - name: Checkout pr2_common - uses: actions/checkout@v3 - with: - path: 'ros_ws/src/pr2_common' - repository: PR2/pr2_common - ref: master - - name: Checkout kdl_ik_service - uses: actions/checkout@v3 - with: - path: 'ros_ws/src/kdl_ik_service' - repository: cram2/kdl_ik_service - ref: master - - name: Checkout pr2_kinematics - uses: actions/checkout@v3 - with: - path: 'ros_ws/src/pr2_kinematics' - repository: PR2/pr2_kinematics - ref: kinetic-devel - - name: install ros and deps - uses: betwo/github-setup-catkin@master - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - with: - # Version range or exact version of ROS version to use, using SemVer's version range syntax. - ros-version: noetic - build-tool: 'catkin_tools' - # Root directory of the catkin workspace - workspace: $GITHUB_WORKSPACE/ros_ws - - name: build and source workspace - run: | - cd ros_ws - catkin_make - echo 'export ROS_HOSTNAME=localhost' >> ~/.bashrc - echo 'source $GITHUB_WORKSPACE/ros_ws/devel/setup.bash' >> ~/.bashrc - - name: Upgrade pip - run: | - sudo pip3 install --upgrade pip - - name: Install requirements - run: | - cd $GITHUB_WORKSPACE/ros_ws/src/pycram - sudo pip3 install -r requirements.txt - - name: install additional requirements - run: | - sudo pip3 install --ignore-installed pytest pyjpt mlflow - - name: start roscore - run: | - roslaunch pycram ik_and_description.launch & - - name: Run Tests - run: | - roscd pycram - pytest -v test diff --git a/.github/workflows/update-docker-image.yml b/.github/workflows/update-docker-image.yml new file mode 100644 index 000000000..8c6686c2c --- /dev/null +++ b/.github/workflows/update-docker-image.yml @@ -0,0 +1,31 @@ +name: update_docker_image +on: + push: + branches: + - master + - dev + paths: + - 'requirements.txt' +# only run when a commit has changes in the requirements.txt file + +jobs: + build_and_push_docker_image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: log into Docker Hub #Set repository secrets in github secrets + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASS }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: ./docker + push: true + tags: ${{ vars.DOCKER_IMAGE }} diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..e85fb2af8 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,21 @@ +ARG FROM_IMAGE=ros:noetic-ros-core +ARG OVERLAY_WS=/opt/ros/overlay_ws + +FROM $FROM_IMAGE as cacher +ARG OVERLAY_WS +WORKDIR $OVERLAY_WS/src + +RUN apt-get update && apt-get install python3-pip python3-vcstool git -y && pip3 install pip --upgrade +RUN pip3 install rosdep && rosdep init + +RUN vcs import --input https://raw.githubusercontent.com/cram2/pycram/dev/pycram-https.rosinstall --recursive --skip-existing $OVERLAY_WS/src +RUN rosdep update && rosdep install --from-paths $OVERLAY_WS/src --ignore-src -r -y + +RUN . /opt/ros/noetic/setup.sh && cd $OVERLAY_WS && catkin_make +RUN echo "source $OVERLAY_WS/devel/setup.bash" >> ~/.bashrc + +RUN pip3 install --upgrade pip +WORKDIR $OVERLAY_WS/src/pycram +RUN pip3 install -r requirements.txt + +EXPOSE 11311 \ No newline at end of file