From 0ce547916e82d33299652c34b0ba064b60e5178a Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Thu, 16 May 2024 21:50:40 +0900 Subject: [PATCH] feat(ci): use BuildJet as self-hosted runner (#3) * chore(docker): separate `rosdep install` and `colcon build` RUN commands (#4719) * Use BuildJet as self-hosted runner (#1) * use buildjet * remove condition and add pr * disable update * remove jq and free disk * disable condition * empty Signed-off-by: Yutaka Kondo * Revert "disable condition" This reverts commit 12f239814acd4db3925130d215c88dc9ce574ae0. * disable minimum condition --------- Signed-off-by: Yutaka Kondo * check author * new use rule * log json * refine log * fix typo --------- Signed-off-by: Yutaka Kondo --- .../actions/docker-build-and-push/action.yaml | 7 ----- .../workflows/docker-build-and-push-main.yaml | 31 ++++++++++--------- docker/autoware-openadk/Dockerfile | 6 ++-- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/.github/actions/docker-build-and-push/action.yaml b/.github/actions/docker-build-and-push/action.yaml index 13526e9083e..84a7c12a2b0 100644 --- a/.github/actions/docker-build-and-push/action.yaml +++ b/.github/actions/docker-build-and-push/action.yaml @@ -25,12 +25,6 @@ runs: - name: Setup Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Install jq - run: | - sudo apt-get -y update - sudo apt-get -y install jq - shell: bash - - name: Set Docker tags id: set-docker-tags run: | @@ -123,7 +117,6 @@ runs: ${{ inputs.build-args }} - name: Build and Save Artifacts - if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }} uses: docker/bake-action@v3 with: push: false diff --git a/.github/workflows/docker-build-and-push-main.yaml b/.github/workflows/docker-build-and-push-main.yaml index d5fe698bccf..7f3d04d2ec9 100644 --- a/.github/workflows/docker-build-and-push-main.yaml +++ b/.github/workflows/docker-build-and-push-main.yaml @@ -7,13 +7,7 @@ name: docker-build-and-push-main on: - push: - tags: - - adkit-v*.*.* - branches: - - main - schedule: - - cron: 0 0 1,15 * * + pull_request: workflow_dispatch: inputs: artifacts-destination: @@ -26,7 +20,7 @@ on: jobs: docker-build-and-push-main: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 strategy: fail-fast: false matrix: @@ -44,12 +38,22 @@ jobs: lib_dir: x86_64 additional-tag-suffix: -cuda steps: + - name: Check if PR author is the specific user + id: author-check + run: | + PR_AUTHOR=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH") + if [[ "$PR_AUTHOR" == "youtalk" ]]; then + echo "$PR_AUTHOR is a target user" + echo "author-found=true" >> $GITHUB_OUTPUT + else + echo "$PR_AUTHOR is not a target user" + echo "author-found=false" >> $GITHUB_OUTPUT + fi + shell: bash + - name: Check out repository uses: actions/checkout@v4 - - name: Free disk space - uses: ./.github/actions/free-disk-space - - name: Load env run: | cat amd64.env | sed -e "s/^\s*//" -e "/^#/d" >> $GITHUB_ENV @@ -58,6 +62,7 @@ jobs: fi - name: Build 'autoware-openadk' + if: steps.author-check.outputs.author-found == 'true' uses: ./.github/actions/docker-build-and-push with: bake-target: autoware-openadk @@ -70,7 +75,3 @@ jobs: tag-suffix: ${{ matrix.additional-tag-suffix }}-amd64 tag-prefix: ${{ env.rosdistro }} allow-push: true - - - name: Show disk space - run: | - df -h diff --git a/docker/autoware-openadk/Dockerfile b/docker/autoware-openadk/Dockerfile index c7ce5cca809..3602fe690cf 100644 --- a/docker/autoware-openadk/Dockerfile +++ b/docker/autoware-openadk/Dockerfile @@ -66,7 +66,10 @@ RUN --mount=type=ssh \ && apt-get update \ && rosdep update \ && DEBIAN_FRONTEND=noninteractive rosdep install -y --ignore-src --from-paths src --rosdistro "$ROS_DISTRO" \ - && source /opt/ros/"$ROS_DISTRO"/setup.bash \ + && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache + +# Build Autoware +RUN source /opt/ros/"$ROS_DISTRO"/setup.bash \ && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --cmake-args \ " -Wno-dev" \ " --no-warn-unused-cli" \ @@ -74,7 +77,6 @@ RUN --mount=type=ssh \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ && find /autoware/install -type d -exec chmod 777 {} \; \ && chmod -R 777 /var/tmp/ccache \ - && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache \ && rm -rf /autoware/build /autoware/src CMD ["/bin/bash"]