Skip to content

Commit

Permalink
feat(docker): integrate cuda/no-cuda jobs into single job (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
youtalk authored Oct 22, 2024
1 parent 2dc79b5 commit 335e294
Show file tree
Hide file tree
Showing 9 changed files with 551 additions and 388 deletions.
112 changes: 78 additions & 34 deletions .github/actions/docker-build-and-push/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: docker-build-and-push
description: ""

inputs:
name:
description: ""
required: true
platform:
description: ""
required: true
Expand All @@ -14,9 +11,6 @@ inputs:
build-args:
description: ""
required: false
tag-suffix:
description: ""
required: false
dockerhub-token:
description: ""
required: true
Expand Down Expand Up @@ -45,19 +39,17 @@ runs:
with:
path: |
root-ccache
key: ccache-${{ inputs.platform }}-${{ inputs.name }}-${{ hashFiles('src/**/*.cpp') }}
key: ccache-${{ inputs.platform }}-${{ hashFiles('src/**/*.cpp') }}
restore-keys: |
ccache-${{ inputs.platform }}-${{ inputs.name }}-
ccache-${{ inputs.platform }}-
- name: Restore apt-get
uses: actions/cache/restore@v4
with:
path: |
var-cache-apt
key: apt-get-${{ inputs.platform }}-${{ inputs.name }}-${{ hashFiles('src/**/package.xml') }}
key: apt-get-${{ inputs.platform }}-${{ hashFiles('src/**/package.xml') }}
restore-keys: |
apt-get-${{ inputs.platform }}-${{ inputs.name }}-
apt-get-${{ inputs.platform }}-
- name: Inject cache into docker
Expand All @@ -81,8 +73,8 @@ runs:
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=base${{ inputs.tag-suffix }}-${{ inputs.platform }}
type=raw,value=base${{ inputs.tag-suffix }}-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=raw,value=base-${{ inputs.platform }}
type=raw,value=base-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-base
flavor: |
latest=false
Expand All @@ -93,8 +85,8 @@ runs:
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=core-devel${{ inputs.tag-suffix }}-${{ inputs.platform }}
type=raw,value=core-devel${{ inputs.tag-suffix }}-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=raw,value=core-devel-${{ inputs.platform }}
type=raw,value=core-devel-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-core-devel
flavor: |
latest=false
Expand All @@ -105,32 +97,56 @@ runs:
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=universe-sensing-perception-devel${{ inputs.tag-suffix }}-${{ inputs.platform }}
type=raw,value=universe-sensing-perception-devel${{ inputs.tag-suffix }}-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=raw,value=universe-sensing-perception-devel-${{ inputs.platform }}
type=raw,value=universe-sensing-perception-devel-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-universe-sensing-perception-devel
flavor: |
latest=false
- name: Docker meta for autoware:universe-sensing-perception-devel-cuda
id: meta-universe-sensing-perception-devel-cuda
uses: docker/metadata-action@v5
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=universe-sensing-perception-devel-cuda-${{ inputs.platform }}
type=raw,value=universe-sensing-perception-devel-cuda-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-universe-sensing-perception-devel-cuda
flavor: |
latest=false
- name: Docker meta for autoware:universe-sensing-perception
id: meta-universe-sensing-perception
uses: docker/metadata-action@v5
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=universe-sensing-perception${{ inputs.tag-suffix }}-${{ inputs.platform }}
type=raw,value=universe-sensing-perception${{ inputs.tag-suffix }}-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=raw,value=universe-sensing-perception-${{ inputs.platform }}
type=raw,value=universe-sensing-perception-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-universe-sensing-perception
flavor: |
latest=false
- name: Docker meta for autoware:universe-sensing-perception-cuda
id: meta-universe-sensing-perception-cuda
uses: docker/metadata-action@v5
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=universe-sensing-perception-cuda-${{ inputs.platform }}
type=raw,value=universe-sensing-perception-cuda-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-universe-sensing-perception-cuda
flavor: |
latest=false
- name: Docker meta for autoware:universe-localization-mapping-devel
id: meta-universe-localization-mapping-devel
uses: docker/metadata-action@v5
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=universe-localization-mapping-devel${{ inputs.tag-suffix }}-${{ inputs.platform }}
type=raw,value=universe-localization-mapping-devel${{ inputs.tag-suffix }}-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=raw,value=universe-localization-mapping-devel-${{ inputs.platform }}
type=raw,value=universe-localization-mapping-devel-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-universe-localization-mapping-devel
flavor: |
latest=false
Expand All @@ -141,8 +157,8 @@ runs:
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=universe-localization-mapping${{ inputs.tag-suffix }}-${{ inputs.platform }}
type=raw,value=universe-localization-mapping${{ inputs.tag-suffix }}-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=raw,value=universe-localization-mapping-${{ inputs.platform }}
type=raw,value=universe-localization-mapping-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-universe-localization-mapping
flavor: |
latest=false
Expand All @@ -153,8 +169,8 @@ runs:
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=universe-planning-control-devel${{ inputs.tag-suffix }}-${{ inputs.platform }}
type=raw,value=universe-planning-control-devel${{ inputs.tag-suffix }}-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=raw,value=universe-planning-control-devel-${{ inputs.platform }}
type=raw,value=universe-planning-control-devel-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-universe-planning-control-devel
flavor: |
latest=false
Expand All @@ -165,8 +181,8 @@ runs:
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=universe-planning-control${{ inputs.tag-suffix }}-${{ inputs.platform }}
type=raw,value=universe-planning-control${{ inputs.tag-suffix }}-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=raw,value=universe-planning-control-${{ inputs.platform }}
type=raw,value=universe-planning-control-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-universe-planning-control
flavor: |
latest=false
Expand All @@ -177,8 +193,8 @@ runs:
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=universe-vehicle-system-devel${{ inputs.tag-suffix }}-${{ inputs.platform }}
type=raw,value=universe-vehicle-system-devel${{ inputs.tag-suffix }}-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=raw,value=universe-vehicle-system-devel-${{ inputs.platform }}
type=raw,value=universe-vehicle-system-devel-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-universe-vehicle-system-devel
flavor: |
latest=false
Expand All @@ -189,8 +205,8 @@ runs:
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=universe-vehicle-system${{ inputs.tag-suffix }}-${{ inputs.platform }}
type=raw,value=universe-vehicle-system${{ inputs.tag-suffix }}-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=raw,value=universe-vehicle-system-${{ inputs.platform }}
type=raw,value=universe-vehicle-system-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-universe-vehicle-system
flavor: |
latest=false
Expand All @@ -201,24 +217,48 @@ runs:
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=universe-devel${{ inputs.tag-suffix }}-${{ inputs.platform }}
type=raw,value=universe-devel${{ inputs.tag-suffix }}-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=raw,value=universe-devel-${{ inputs.platform }}
type=raw,value=universe-devel-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-universe-devel
flavor: |
latest=false
- name: Docker meta for autoware:universe-devel-cuda
id: meta-universe-devel-cuda
uses: docker/metadata-action@v5
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=universe-devel-cuda-${{ inputs.platform }}
type=raw,value=universe-devel-cuda-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-universe-devel-cuda
flavor: |
latest=false
- name: Docker meta for autoware:universe
id: meta-universe
uses: docker/metadata-action@v5
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=universe${{ inputs.tag-suffix }}-${{ inputs.platform }}
type=raw,value=universe${{ inputs.tag-suffix }}-${{ steps.date.outputs.date }}-${{ inputs.platform }}
type=raw,value=universe-${{ inputs.platform }}
type=raw,value=universe-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-universe
flavor: |
latest=auto
- name: Docker meta for autoware:universe-cuda
id: meta-universe-cuda
uses: docker/metadata-action@v5
with:
images: ${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: |
type=raw,value=universe-cuda-${{ inputs.platform }}
type=raw,value=universe-cuda-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-universe-cuda
flavor: |
latest=auto
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
Expand All @@ -234,15 +274,19 @@ runs:
${{ steps.meta-base.outputs.bake-file }}
${{ steps.meta-core-devel.outputs.bake-file }}
${{ steps.meta-universe-sensing-perception-devel.outputs.bake-file }}
${{ steps.meta-universe-sensing-perception-devel-cuda.outputs.bake-file }}
${{ steps.meta-universe-sensing-perception.outputs.bake-file }}
${{ steps.meta-universe-sensing-perception-cuda.outputs.bake-file }}
${{ steps.meta-universe-localization-mapping-devel.outputs.bake-file }}
${{ steps.meta-universe-localization-mapping.outputs.bake-file }}
${{ steps.meta-universe-planning-control-devel.outputs.bake-file }}
${{ steps.meta-universe-planning-control.outputs.bake-file }}
${{ steps.meta-universe-vehicle-system-devel.outputs.bake-file }}
${{ steps.meta-universe-vehicle-system.outputs.bake-file }}
${{ steps.meta-universe-devel.outputs.bake-file }}
${{ steps.meta-universe-devel-cuda.outputs.bake-file }}
${{ steps.meta-universe.outputs.bake-file }}
${{ steps.meta-universe-cuda.outputs.bake-file }}
provenance: false
set: |
${{ inputs.build-args }}
25 changes: 9 additions & 16 deletions .github/actions/docker-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: docker-build
description: ""

inputs:
name:
description: ""
required: true
platform:
description: ""
required: true
Expand Down Expand Up @@ -39,48 +36,44 @@ runs:

- name: Cache ccache
uses: actions/cache@v4
if: ${{ inputs.name == 'no-cuda' && github.ref == 'refs/heads/main' }}
if: ${{ github.ref == 'refs/heads/main' }}
id: cache-ccache
with:
path: |
root-ccache
key: ccache-${{ inputs.platform }}-${{ inputs.name }}-${{ hashFiles('src/**/*.cpp') }}
key: ccache-${{ inputs.platform }}-${{ hashFiles('src/**/*.cpp') }}
restore-keys: |
ccache-${{ inputs.platform }}-${{ inputs.name }}-
ccache-${{ inputs.platform }}-
- name: Cache apt-get
uses: actions/cache@v4
if: ${{ inputs.name == 'no-cuda' && github.ref == 'refs/heads/main' }}
if: ${{ github.ref == 'refs/heads/main' }}
id: cache-apt-get
with:
path: |
var-cache-apt
key: apt-get-${{ inputs.platform }}-${{ inputs.name }}-${{ hashFiles('src/**/package.xml') }}
key: apt-get-${{ inputs.platform }}-${{ hashFiles('src/**/package.xml') }}
restore-keys: |
apt-get-${{ inputs.platform }}-${{ inputs.name }}-
apt-get-${{ inputs.platform }}-
- name: Restore ccache
uses: actions/cache/restore@v4
if: ${{ inputs.name != 'no-cuda' || github.ref != 'refs/heads/main' }}
if: ${{ github.ref != 'refs/heads/main' }}
with:
path: |
root-ccache
key: ccache-${{ inputs.platform }}-${{ inputs.name }}-${{ hashFiles('src/**/*.cpp') }}
key: ccache-${{ inputs.platform }}-${{ hashFiles('src/**/*.cpp') }}
restore-keys: |
ccache-${{ inputs.platform }}-${{ inputs.name }}-
ccache-${{ inputs.platform }}-
- name: Restore apt-get
uses: actions/cache/restore@v4
if: ${{ inputs.name != 'no-cuda' || github.ref != 'refs/heads/main' }}
if: ${{ github.ref != 'refs/heads/main' }}
with:
path: |
var-cache-apt
key: apt-get-${{ inputs.platform }}-${{ inputs.name }}-${{ hashFiles('src/**/package.xml') }}
key: apt-get-${{ inputs.platform }}-${{ hashFiles('src/**/package.xml') }}
restore-keys: |
apt-get-${{ inputs.platform }}-${{ inputs.name }}-
apt-get-${{ inputs.platform }}-
- name: Inject cache into docker
Expand All @@ -106,4 +99,4 @@ runs:
context: .
push: false
build-args: ${{ inputs.build-args }}
cache-from: type=registry,ref=${{ github.repository }}-buildcache:${{ inputs.name }}-${{ inputs.platform }}-${{ inputs.cache-tag-suffix }}
cache-from: type=registry,ref=${{ github.repository }}-buildcache:${{ inputs.platform }}-${{ inputs.cache-tag-suffix }}
35 changes: 7 additions & 28 deletions .github/workflows/docker-build-and-push-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,6 @@ jobs:
docker-build-and-push:
needs: load-env
runs-on: buildjet-16vcpu-ubuntu-2204-arm
strategy:
fail-fast: false
matrix:
name:
- no-cuda
- cuda
include:
- name: no-cuda
platform: arm64
base_image_env: base_image
lib_dir: aarch64
setup-args: --no-nvidia
tag-suffix: ""
- name: cuda
platform: arm64
base_image_env: base_image
lib_dir: aarch64
tag-suffix: -cuda
steps:
- name: Check if PR author is the specific user
id: author-check
Expand Down Expand Up @@ -74,19 +56,16 @@ jobs:
(github.event_name == 'push' && github.ref_type == 'tag') }}
uses: ./.github/actions/docker-build-and-push
with:
name: ${{ matrix.name }}
platform: ${{ matrix.platform }}
platform: arm64
bake-target: autoware
build-args: |
*.platform=linux/${{ matrix.platform }}
*.platform=linux/arm64
*.args.ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }}
*.args.BASE_IMAGE=${{ needs.load-env.outputs[format('{0}', matrix.base_image_env)] }}
*.args.SETUP_ARGS=${{ matrix.setup-args }}
*.args.LIB_DIR=${{ matrix.lib_dir }}
*.cache-from=type=registry,ref=${{ github.repository }}-buildcache:${{ matrix.name }}-${{ matrix.platform }}-${{ github.head_ref }}
*.cache-from=type=registry,ref=${{ github.repository }}-buildcache:${{ matrix.name }}-${{ matrix.platform }}-main
*.cache-to=type=registry,ref=${{ github.repository }}-buildcache:${{ matrix.name }}-${{ matrix.platform }}-${{ github.head_ref }},mode=max
tag-suffix: ${{ matrix.tag-suffix }}
*.args.BASE_IMAGE=${{ needs.load-env.outputs.base_image }}
*.args.LIB_DIR=aarch64
*.cache-from=type=registry,ref=${{ github.repository }}-buildcache:arm64-${{ github.head_ref }}
*.cache-from=type=registry,ref=${{ github.repository }}-buildcache:arm64-main
*.cache-to=type=registry,ref=${{ github.repository }}-buildcache:arm64-${{ github.head_ref }},mode=max
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Show disk space
Expand Down
Loading

0 comments on commit 335e294

Please sign in to comment.