Skip to content

Commit

Permalink
ci: refactor workflows to be OS/distro independent like #3087 (#3092)
Browse files Browse the repository at this point in the history
* ci: refactor workflows to be OS/distro independent like #3087

Signed-off-by: Kenji Miyake <[email protected]>

* add needs

Signed-off-by: Kenji Miyake <[email protected]>

* add outputs

Signed-off-by: Kenji Miyake <[email protected]>

Signed-off-by: Kenji Miyake <[email protected]>
  • Loading branch information
kenji-miyake authored Nov 30, 2022
1 parent 1d492a3 commit 7de7beb
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 49 deletions.
21 changes: 1 addition & 20 deletions .github/workflows/build-main-self-hosted.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,7 @@ on:

jobs:
load-env:
runs-on: ubuntu-latest
outputs:
base-image: ${{ steps.set-env.outputs.base-image }}
rosdistro: ${{ steps.set-env.outputs.rosdistro }}
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Load env
run: |
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: Set env
id: set-env
run: |
echo "base-image=${{ env.base_image }}" >> $GITHUB_OUTPUT
echo "rosdistro=${{ env.rosdistro }}" >> $GITHUB_OUTPUT
uses: ./.github/workflows/load-env.yaml

build-main-self-hosted:
needs: load-env
Expand Down
21 changes: 1 addition & 20 deletions .github/workflows/build-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,7 @@ on:

jobs:
load-env:
runs-on: ubuntu-latest
outputs:
base-image: ${{ steps.set-env.outputs.base-image }}
rosdistro: ${{ steps.set-env.outputs.rosdistro }}
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Load env
run: |
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: Set env
id: set-env
run: |
echo "base-image=${{ env.base_image }}" >> $GITHUB_OUTPUT
echo "rosdistro=${{ env.rosdistro }}" >> $GITHUB_OUTPUT
uses: ./.github/workflows/load-env.yaml

build-main:
needs: load-env
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/load-env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: load-env

on:
workflow_call:
outputs:
base-image:
value: ${{ jobs.load-env.outputs.base-image }}
rosdistro:
value: ${{ jobs.load-env.outputs.rosdistro }}

jobs:
load-env:
runs-on: ubuntu-latest
outputs:
base-image: ${{ steps.set-env.outputs.base-image }}
rosdistro: ${{ steps.set-env.outputs.rosdistro }}
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Load env
run: |
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: Set env
id: set-env
run: |
echo "base-image=${{ env.base_image }}" >> $GITHUB_OUTPUT
echo "rosdistro=${{ env.rosdistro }}" >> $GITHUB_OUTPUT
6 changes: 5 additions & 1 deletion .github/workflows/setup-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ on:
pull_request:

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

setup-docker:
needs: load-env
runs-on: ubuntu-latest
container: ubuntu:20.04
container: ${{ needs.load-env.outputs.base-image }}
steps:
- name: Check out repository
uses: actions/checkout@v3
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/setup-universe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ on:
pull_request:

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

setup-universe:
needs: load-env
runs-on: ubuntu-latest
container: ubuntu:20.04
container: ${{ needs.load-env.outputs.base-image }}
steps:
- name: Check out repository
uses: actions/checkout@v3
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/update-docker-manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ on:
workflow_dispatch:

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

update-docker-manifest:
needs: load-env
runs-on: ubuntu-latest
steps:
- name: Check out repository
Expand All @@ -21,26 +25,26 @@ jobs:
uses: ./.github/actions/create-main-distro-alias
with:
package-name: autoware-universe
rosdistro: galactic
rosdistro: ${{ needs.load-env.outputs.rosdistro }}
tag-name: latest

- name: Create alias from 'autoware-universe:{rosdistro}-latest-prebuilt' to 'autoware-universe:latest-prebuilt'
uses: ./.github/actions/create-main-distro-alias
with:
package-name: autoware-universe
rosdistro: galactic
rosdistro: ${{ needs.load-env.outputs.rosdistro }}
tag-name: latest-prebuilt

- name: Create alias from 'autoware-universe:{rosdistro}-latest-cuda' to 'autoware-universe:latest-cuda'
uses: ./.github/actions/create-main-distro-alias
with:
package-name: autoware-universe
rosdistro: galactic
rosdistro: ${{ needs.load-env.outputs.rosdistro }}
tag-name: latest-cuda

- name: Create alias from 'autoware-universe:{rosdistro}-latest-prebuilt-cuda' to 'autoware-universe:latest-prebuilt-cuda'
uses: ./.github/actions/create-main-distro-alias
with:
package-name: autoware-universe
rosdistro: galactic
rosdistro: ${{ needs.load-env.outputs.rosdistro }}
tag-name: latest-prebuilt-cuda
10 changes: 7 additions & 3 deletions .github/workflows/vcs-import.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ on:
workflow_dispatch:

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

vcs-import:
needs: load-env
runs-on: ubuntu-latest
container: ros:galactic
container: ros:${{ needs.load-env.outputs.rosdistro }}
steps:
- name: Check out repository
uses: actions/checkout@v3
Expand All @@ -20,7 +24,7 @@ jobs:
- name: Register AutonomouStuff repository
uses: autowarefoundation/autoware-github-actions/register-autonomoustuff-repository@v1
with:
rosdistro: galactic
rosdistro: ${{ needs.load-env.outputs.rosdistro }}

- name: Set git config
uses: autowarefoundation/autoware-github-actions/set-git-config@v1
Expand All @@ -40,4 +44,4 @@ jobs:
run: |
sudo apt-get -y update
rosdep update
DEBIAN_FRONTEND=noninteractive rosdep install -y --from-paths src --ignore-src --rosdistro galactic
DEBIAN_FRONTEND=noninteractive rosdep install -y --from-paths src --ignore-src --rosdistro ${{ needs.load-env.outputs.rosdistro }}

0 comments on commit 7de7beb

Please sign in to comment.