Skip to content

Commit

Permalink
feat(docker): integrate cuda/no-cuda jobs into single job (#5363)
Browse files Browse the repository at this point in the history
  • Loading branch information
youtalk authored Nov 7, 2024
1 parent 06d386a commit 9dca304
Show file tree
Hide file tree
Showing 10 changed files with 673 additions and 401 deletions.
121 changes: 121 additions & 0 deletions .github/actions/docker-build-and-push-cuda/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: docker-build-and-push-cuda
description: Workflow do build and push CUDA images to registry.

inputs:
platform:
description: ""
required: true
bake-target:
description: ""
required: true
build-args:
description: ""
required: false

runs:
using: composite
steps:
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Restore ccache
uses: actions/cache/restore@v4
with:
path: |
root-ccache
key: ccache-${{ inputs.platform }}-${{ hashFiles('src/**/*.cpp') }}
restore-keys: |
ccache-${{ inputs.platform }}-
- name: Restore apt-get
uses: actions/cache/restore@v4
with:
path: |
var-cache-apt
key: apt-get-${{ inputs.platform }}-${{ hashFiles('src/**/package.xml') }}
restore-keys: |
apt-get-${{ inputs.platform }}-
- name: Inject cache into docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"root-ccache": "/root/.ccache",
"var-cache-apt": "/var/cache/apt"
}
skip-extraction: true

- name: Get current date
id: date
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash

- name: Docker meta for autoware:universe-sensing-perception-devel-cuda
id: meta-universe-sensing-perception-devel-cuda
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ 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-cuda
id: meta-universe-sensing-perception-cuda
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ 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-devel-cuda
id: meta-universe-devel-cuda
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ 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-cuda
id: meta-universe-cuda
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ 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 GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

- name: Build and Push to GitHub Container Registry
uses: docker/bake-action@v5
with:
push: true
files: |
docker/docker-bake-cuda.hcl
${{ steps.meta-universe-sensing-perception-devel-cuda.outputs.bake-file }}
${{ steps.meta-universe-sensing-perception-cuda.outputs.bake-file }}
${{ steps.meta-universe-devel-cuda.outputs.bake-file }}
${{ steps.meta-universe-cuda.outputs.bake-file }}
provenance: false
set: |
${{ inputs.build-args }}
60 changes: 26 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

runs:
using: composite
Expand All @@ -42,19 +36,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 @@ -78,8 +70,8 @@ runs:
with:
images: ghcr.io/${{ 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 @@ -90,8 +82,8 @@ runs:
with:
images: ghcr.io/${{ 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 @@ -102,8 +94,8 @@ runs:
with:
images: ghcr.io/${{ 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
Expand All @@ -114,8 +106,8 @@ runs:
with:
images: ghcr.io/${{ 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
Expand All @@ -126,8 +118,8 @@ runs:
with:
images: ghcr.io/${{ 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 @@ -138,8 +130,8 @@ runs:
with:
images: ghcr.io/${{ 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 @@ -150,8 +142,8 @@ runs:
with:
images: ghcr.io/${{ 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 @@ -162,8 +154,8 @@ runs:
with:
images: ghcr.io/${{ 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 @@ -174,8 +166,8 @@ runs:
with:
images: ghcr.io/${{ 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 @@ -186,8 +178,8 @@ runs:
with:
images: ghcr.io/${{ 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 @@ -198,8 +190,8 @@ runs:
with:
images: ghcr.io/${{ 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
Expand All @@ -210,8 +202,8 @@ runs:
with:
images: ghcr.io/${{ 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
Expand Down
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 @@ -36,48 +33,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 @@ -104,4 +97,4 @@ runs:
context: .
push: false
build-args: ${{ inputs.build-args }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:${{ inputs.name }}-${{ inputs.platform }}-${{ inputs.cache-tag-suffix }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:${{ inputs.platform }}-${{ inputs.cache-tag-suffix }}
Loading

0 comments on commit 9dca304

Please sign in to comment.