diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3149435..3b3e72e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu { - "name": "ROS 2 Humble Devcontainer", + "name": "ROS 2 Devcontainer", "build": { "dockerfile": "./Dockerfile", "args": { diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index bdd03a7..d65dfa4 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -1,86 +1,87 @@ name: Docker Image CI on: - push: - branches: ["main"] - # ensure that version tags also trigger a build, naming convention is `vX.Y.Z` - # make sure the naming convention is followed in tags. - tags: - - "v*" - pull_request: - branches: ["main"] - # permit manual trigger as well - workflow_dispatch: + push: + branches: ["main"] + # ensure that version tags also trigger a build, naming convention is `vX.Y.Z` + # make sure the naming convention is followed in tags. + tags: + - "v*" + pull_request: + + workflow_dispatch: jobs: - build: - # this only works on jabasai organisation and should be skipped otherwise - if: github.repository_owner == 'jabasai' - runs-on: ubuntu-latest - permissions: - contents: read - packages: write + build: + runs-on: ubuntu-latest + + env: # set the ROS distribution to be used in the devcontainer, e.g. humble or iron + ROS_DISTRO: humble + + permissions: + contents: read + packages: write - steps: - - name: Git Checkout - uses: actions/checkout@v5 - with: - fetch-depth: 1 + steps: + - name: Git Checkout + uses: actions/checkout@v5 + with: + fetch-depth: 1 - # log in to GitHub Container Registry with correct permission - # only works within jabasai organisation and NOT on forks - - name: Docker Login GHCR - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + # log in to GitHub Container Registry with correct permission + - name: Docker Login GHCR + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - # create a docker image name from the github repository name, ensuring lower case and no disallowed characters - - name: create docker image name from github name - id: docker-image-name - run: | - repo_name=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]' | tr '. ' '-') - echo "image_name=$repo_name" >> $GITHUB_OUTPUT + # create a docker image name from the github repository name, ensuring lower case and no disallowed characters + - name: create docker image name from github name + id: docker-image-name + run: | + repo_name=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]' | tr '. ' '-') + echo "image_name=$repo_name" >> $GITHUB_OUTPUT - # set the relevant docker tags and labels - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - # list of Docker images to use as base name for tags - labels: | - org.opencontainers.image.source=https://github.com/${{ github.repository }} - org.opencontainers.image.revision=${{ github.sha }} - org.opencontainers.image.created=${{ github.event.head_commit.timestamp }} - org.opencontainers.image.version=${{ github.ref_name }} - images: | - ghcr.io/${{ steps.docker-image-name.outputs.image_name }} - flavor: | - latest=auto - tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=raw,value=latest,enable={{is_default_branch}} - type=ref,event=branch + # set the relevant docker tags and labels + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + labels: | + org.opencontainers.image.source=https://github.com/${{ github.repository }} + org.opencontainers.image.creator=${{ github.repository_owner }} + org.opencontainers.image.revision=${{ github.sha }} + org.opencontainers.image.created=${{ github.event.head_commit.timestamp }} + org.opencontainers.image.version=${{ github.ref_name }} + images: | + ghcr.io/${{ steps.docker-image-name.outputs.image_name }} + flavor: | + latest=auto + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=raw,value=latest,enable={{is_default_branch}} + type=ref,event=branch - - name: setup buildx - uses: docker/setup-buildx-action@v2 + - name: setup buildx + uses: docker/setup-buildx-action@v4 - - name: Build and Push - uses: docker/build-push-action@v6 - with: - context: . - file: ./.devcontainer/Dockerfile - platforms: linux/amd64 # add other platforms if needed - cache-from: type=gha - cache-to: type=gha,mode=max - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - target: final - build-args: | - BASE_IMAGE=ros:humble - GIT_REPO_VERSION=${{ github.ref_name }} - GIT_REPO_VERSION_DATE=${{ github.event.head_commit.timestamp }} + - name: Build and Push + uses: docker/build-push-action@v6 + with: + context: . + file: ./.devcontainer/Dockerfile + platforms: linux/amd64 # add other platforms if needed + cache-from: type=gha + cache-to: type=gha,mode=max + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + target: final + build-args: | + BASE_IMAGE=ros:${{ env.ROS_DISTRO }} + GIT_REPO_VERSION=${{ github.ref_name }} + GIT_REPO_VERSION_DATE=${{ github.event.head_commit.timestamp }} diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 1c97337..686846b 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -16,10 +16,15 @@ on: jobs: copilot-setup-steps: + # ensure this matches the target platform for your development environment, e.g. if you are using a devcontainer with Ubuntu 22.04, use ubuntu-22.04 here as well. runs-on: ubuntu-22.04 permissions: contents: read + env: + # set the ROS distribution to be used in the setup steps, e.g. humble or iron + ROS_DISTRO: humble + steps: - uses: actions/checkout@v3 @@ -29,12 +34,12 @@ jobs: - name: install workspace dependencies run: | sudo apt-get update - sudo apt-get install -y ros-humble-ros-base - source /opt/ros/humble/setup.bash - rosdep update --rosdistro humble + sudo apt-get install -y ros-${ROS_DISTRO}-ros-base + source /opt/ros/${ROS_DISTRO}/setup.bash + rosdep update --rosdistro ${ROS_DISTRO} rosdep install --from-paths src --ignore-src -r -y - name: build workspace run: | - source /opt/ros/humble/setup.bash + source /opt/ros/${ROS_DISTRO}/setup.bash colcon build --symlink-install --continue-on-error diff --git a/.github/workflows/dev-container.yml b/.github/workflows/dev-container.yml index 5e93b6c..11c6f93 100644 --- a/.github/workflows/dev-container.yml +++ b/.github/workflows/dev-container.yml @@ -1,26 +1,33 @@ name: 'devcontainer CI' on: workflow_dispatch: + pull_request: - branches: - - main + paths: + - '.devcontainer/**' + - '.github/workflows/dev-container.yml' + push: branches: - main + paths: + - '.devcontainer/**' + - '.github/workflows/dev-container.yml' jobs: build_devcontainer: runs-on: ubuntu-latest steps: - name: Checkout from github - uses: actions/checkout@v3 + uses: actions/checkout@v6 - name: extract the github reference run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV - name: "image name from repo name" id: docker_image_name run: echo "docker_image=${{ github.repository }}" | tr '[:upper:]' '[:lower:]' |sed 's/[^0-9,a-z,A-Z,=,_,\/]/-/g' >>${GITHUB_OUTPUT} - name: setup buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v4 + - name: Build and run dev container task uses: devcontainers/ci@v0.3 with: diff --git a/.github/workflows/ros-ci.yml b/.github/workflows/ros-ci.yml index 3462229..41910ad 100644 --- a/.github/workflows/ros-ci.yml +++ b/.github/workflows/ros-ci.yml @@ -5,17 +5,12 @@ on: # you may want to configure the branches that this should be run on here. branches: [ "main" ] pull_request: - branches: [ "main" ] jobs: test_docker: # On Linux, iterates on all ROS 1 and ROS 2 distributions. runs-on: ubuntu-latest strategy: matrix: - ros_distribution: - # - noetic - - humble - # - iron # Define the Docker image(s) associated with each ROS distribution. # The include syntax allows additional variables to be defined, like @@ -34,12 +29,6 @@ jobs: # Humble Hawksbill (May 2022 - May 2027) - docker_image: ubuntu:jammy ros_distribution: humble - ros_version: 2 - - # Iron Irwini (May 2023 - November 2024) - # - docker_image: ubuntu:jammy - # ros_distribution: iron - # ros_version: 2 # # Rolling Ridley (No End-Of-Life) # - docker_image: ubuntu:jammy @@ -49,20 +38,12 @@ jobs: container: image: ${{ matrix.docker_image }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 + - name: setup ROS environment uses: ros-tooling/setup-ros@v0.7 - #with: - # required-ros-distributions: ${{ matrix.ros_distribution }} - - name: build and test ROS 1 - if: ${{ matrix.ros_version == 1 }} - uses: ros-tooling/action-ros-ci@v0.3 - with: - import-token: ${{ github.token }} - target-ros1-distro: ${{ matrix.ros_distribution }} - skip-tests: true + - name: build and test ROS 2 - if: ${{ matrix.ros_version == 2 }} uses: ros-tooling/action-ros-ci@v0.3 with: import-token: ${{ github.token }}