diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.git diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml deleted file mode 100644 index ee7d951..0000000 --- a/.github/workflows/build_docker.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Build and publish Jammy/Humble Docker image - -on: - pull_request: - paths: - - ".devcontainer/**" - - "*/package.xml" - push: - branches: - - main - -env: - # Use docker.io for Docker Hub if empty - REGISTRY: ghcr.io - # github.repository as / - IMAGE_NAME: bdaiinstitute/ros_utilties_jammy_humble - -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. - id-token: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Workaround: https://github.com/docker/build-push-action/issues/461 - - name: Setup Docker buildx - uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf - - # Login against a Docker registry except on PR - # https://github.com/docker/login-action - - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' - uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - # Extract metadata (tags, labels) for Docker - # https://github.com/docker/metadata-action - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - # Build and push Docker image with Buildx (don't push on PR) - # https://github.com/docker/build-push-action - - name: Build and push Docker image - id: build-and-push - uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a - with: - context: . - file: .devcontainer/Dockerfile - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0b88c53 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,82 @@ +name: ros_utilities CI + +on: + pull_request: + push: + branches: + - main + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: bdaiinstitute/ros_utilties_jammy_humble + +defaults: + run: + shell: bash + +jobs: + lint: + name: Lint ros_utilities packages + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - name: Lint sources + uses: pre-commit/action@v3.0.0 + prepare_container: + name: Prepare Humble container for tests + runs-on: ubuntu-latest + needs: lint + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + outputs: + image: ${{ fromJSON(steps.meta.outputs.json).tags[0] }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Setup Docker buildx # to workaround: https://github.com/docker/build-push-action/issues/461 + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c # https://github.com/docker/login-action + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 # https://github.com/docker/metadata-action + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + id: meta + - name: Build and push Docker image (may be cached) + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a # https://github.com/docker/build-push-action + with: + context: . + file: .devcontainer/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + build_and_test: + name: Build and test ros_utilities packages + runs-on: ubuntu-latest + needs: prepare_container + container: + image: ${{ needs.prepare_container.outputs.image }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Build and run tests + run: | + source /opt/ros/humble/setup.bash + colcon build --symlink-install + source install/setup.bash + colcon test --event-handlers console_direct+ + colcon test-result --all --verbose diff --git a/.github/workflows/maintenance.yaml b/.github/workflows/maintenance.yaml new file mode 100644 index 0000000..c4584b5 --- /dev/null +++ b/.github/workflows/maintenance.yaml @@ -0,0 +1,26 @@ +name: ros_utilities CI maintenance + +on: + schedule: + - cron: "0 0 * * 0" # once a week + +env: + ORG_NAME: bdaiinstitute + # github.repository as / + IMAGE_NAME: bdaiinstitute/ros_utilties_jammy_humble + +jobs: + clean-ghcr: + name: Prune old images from Github Container Registry + runs-on: ubuntu-latest + steps: + - name: Delete old pull request images + uses: snok/container-retention-policy@v2 + with: + image-names: ${{ env.IMAGE_NAME }} + skip-tags: main + cut-off: One week ago UTC + account-name: ${{ env.ORG_NAME }} + account-type: org + token: ${{ secrets.GITHUB_TOKEN }} + token-type: github-token diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 01ca2e0..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: ros_utilities CI -on: - pull_request: - push: - branches: - - main - -jobs: - build_and_test: - runs-on: ubuntu-latest - defaults: - run: - shell: bash - container: - image: ghcr.io/bdaiinstitute/ros_utilties_jammy_humble:main - steps: - - uses: actions/checkout@v3 - - name: Build and run tests - run: | - source /opt/ros/humble/setup.bash - colcon build --symlink-install - source install/setup.bash - colcon test --event-handlers console_direct+ - colcon test-result --all --verbose diff --git a/.github/workflows/util_pre-commit.yml b/.github/workflows/util_pre-commit.yml deleted file mode 100644 index 853b6de..0000000 --- a/.github/workflows/util_pre-commit.yml +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2023 Boston Dynamics AI Institute, Inc. All rights reserved. - -name: Util - Pre-Commit Runner - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - pre-commit: - name: util_pre-commit - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - - uses: pre-commit/action@v3.0.0