Skip to content

Commit

Permalink
ci(build-main): improve storage cleaning and ci build pipeline (autow…
Browse files Browse the repository at this point in the history
…arefoundation#4191)

Signed-off-by: M. Fatih Cırıt <[email protected]>
  • Loading branch information
xmfcx authored Feb 21, 2024
1 parent 0d594f7 commit c02aa1d
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 80 deletions.
6 changes: 5 additions & 1 deletion .github/actions/docker-build-and-push/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ inputs:
tag-suffix:
description: ""
required: false
allow-push:
description: ""
default: "true"
required: false

runs:
using: composite
Expand Down Expand Up @@ -87,7 +91,7 @@ runs:
uses: docker/bake-action@v3
with:
# Checking event_name for https://github.com/autowarefoundation/autoware/issues/2796
push: ${{ github.event_name == 'schedule' || github.ref_name == github.event.repository.default_branch || github.event_name == 'push'}}
push: ${{ (github.event_name == 'schedule' || github.ref_name == github.event.repository.default_branch || github.event_name == 'push') && inputs.allow-push == 'true' }}
files: |
docker/${{ inputs.bake-target }}/docker-bake.hcl
${{ steps.meta-devel.outputs.bake-file }}
Expand Down
35 changes: 14 additions & 21 deletions .github/actions/free-disk-space/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,18 @@ runs:
fi
shell: bash

# https://github.community/t/bug-strange-no-space-left-on-device-ioexceptions-on-github-runners/17616
- name: Free disk space
run: |
df -h
sudo apt-get -y purge \
dotnet* \
ghc* \
php* \
|| true
sudo apt-get -y autoremove
sudo apt-get -y autoclean
sudo rm -rf \
/usr/local/lib/android \
/usr/share/dotnet/ \
/opt/ghc
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: true

docker rmi $(docker image ls -aq) || true
df -h
shell: bash
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: false
72 changes: 43 additions & 29 deletions .github/workflows/build-main-self-hosted.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,56 @@ on:
workflow_dispatch:

jobs:
load-env:
uses: ./.github/workflows/load-env.yaml

build-main-self-hosted:
needs: load-env
runs-on: [self-hosted, linux, ARM64]
container: ${{ needs.load-env.outputs.base-image }}
strategy:
fail-fast: false
matrix:
name:
- no-cuda
- cuda
include:
- name: no-cuda
base_image_env: base_image
setup-args: --no-nvidia
additional-tag-suffix: ""
- name: cuda
base_image_env: cuda_base_image
setup-args: --no-cuda-drivers
additional-tag-suffix: -cuda
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Run setup script
# https://github.com/actions/checkout/issues/211
- name: Change permission of workspace
run: |
./setup-dev-env.sh -y
- name: Set git config
uses: autowarefoundation/autoware-github-actions/set-git-config@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
sudo chown -R $USER:$USER ${{ github.workspace }}
- name: Run vcs import
run: |
mkdir src
vcs import src < autoware.repos
- name: Check out repository
uses: actions/checkout@v4

- name: Run vcs export
run: |
vcs export --exact src || true
- name: Free disk space
uses: ./.github/actions/free-disk-space

- name: Run rosdep install
- name: Load env
run: |
sudo apt-get -y update
rosdep update
DEBIAN_FRONTEND=noninteractive rosdep install -y --from-paths src --ignore-src --rosdistro ${{ needs.load-env.outputs.rosdistro }}
cat amd64.env | sed -e "s/^\s*//" -e "/^#/d" >> $GITHUB_ENV
if [ "$(uname -m)" = "aarch64" ]; then
cat arm64.env | sed -e "s/^\s*//" -e "/^#/d" >> $GITHUB_ENV
fi
- name: Build
- name: Build 'autoware-universe'
uses: ./.github/actions/docker-build-and-push
with:
bake-target: autoware-universe
build-args: |
*.platform=linux/arm64
*.args.ROS_DISTRO=${{ env.rosdistro }}
*.args.BASE_IMAGE=${{ env[format('{0}', matrix.base_image_env)] }}
*.args.PREBUILT_BASE_IMAGE=${{ env.prebuilt_base_image }}
*.args.SETUP_ARGS=${{ matrix.setup-args }}
tag-prefix: ${{ env.rosdistro }}-
tag-suffix: ${{ matrix.additional-tag-suffix }}-arm64
allow-push: false

- name: Show disk space
run: |
. /opt/ros/${{ needs.load-env.outputs.rosdistro }}/setup.sh
colcon build --event-handlers console_cohesion+ --cmake-args -DCMAKE_BUILD_TYPE=Release
df -h
67 changes: 38 additions & 29 deletions .github/workflows/build-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,51 @@ on:
workflow_dispatch:

jobs:
load-env:
uses: ./.github/workflows/load-env.yaml

build-main:
needs: load-env
runs-on: ubuntu-latest
container: ${{ needs.load-env.outputs.base-image }}
strategy:
fail-fast: false
matrix:
name:
- no-cuda
- cuda
include:
- name: no-cuda
base_image_env: base_image
setup-args: --no-nvidia
additional-tag-suffix: ""
- name: cuda
base_image_env: cuda_base_image
setup-args: --no-cuda-drivers
additional-tag-suffix: -cuda
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Run setup script
run: |
./setup-dev-env.sh -y
- name: Free disk space
uses: ./.github/actions/free-disk-space

- name: Set git config
uses: autowarefoundation/autoware-github-actions/set-git-config@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Run vcs import
- name: Load env
run: |
mkdir src
vcs import src < autoware.repos
cat amd64.env | sed -e "s/^\s*//" -e "/^#/d" >> $GITHUB_ENV
if [ "$(uname -m)" = "aarch64" ]; then
cat arm64.env | sed -e "s/^\s*//" -e "/^#/d" >> $GITHUB_ENV
fi
- name: Run vcs export
run: |
vcs export --exact src || true
- name: Run rosdep install
run: |
sudo apt-get -y update
rosdep update
DEBIAN_FRONTEND=noninteractive rosdep install -y --from-paths src --ignore-src --rosdistro ${{ needs.load-env.outputs.rosdistro }}
- name: Build
- name: Build 'autoware-universe'
uses: ./.github/actions/docker-build-and-push
with:
bake-target: autoware-universe
build-args: |
*.platform=linux/amd64
*.args.ROS_DISTRO=${{ env.rosdistro }}
*.args.BASE_IMAGE=${{ env[format('{0}', matrix.base_image_env)] }}
*.args.PREBUILT_BASE_IMAGE=${{ env.prebuilt_base_image }}
*.args.SETUP_ARGS=${{ matrix.setup-args }}
tag-prefix: ${{ env.rosdistro }}-
tag-suffix: ${{ matrix.additional-tag-suffix }}-amd64
allow-push: false

- name: Show disk space
run: |
. /opt/ros/${{ needs.load-env.outputs.rosdistro }}/setup.sh
colcon build --event-handlers console_cohesion+ --cmake-args -DCMAKE_BUILD_TYPE=Release
df -h

0 comments on commit c02aa1d

Please sign in to comment.