Skip to content

Add a template: feature_request.yml #9

Add a template: feature_request.yml

Add a template: feature_request.yml #9

Workflow file for this run

name: Burger-War Image Build & Test
# トリガーイベントの指定
on:
# 指定ブランチで指定ファイルがPUSHされたときに実行する
push:
paths-ignore:
- 'commands/**'
- '.gitignore'
- 'LICENSE'
- '**.md'
# ブラウザ上からの手動実行設定
workflow_dispatch:
inputs:
# リリース有無の設定
release_enable:
description: 'Dockerイメージのリリース (yes/no)'
default: 'yes'
required: true
# 環境変数の設定
env:
DOCKER_BUILDKIT: 1
RESISTRY_URL: ghcr.io/${{ github.repository_owner }}
IMAGE_NAME_CORE: burger-war-core
IMAGE_NAME_SIM: burger-war-sim
IMAGE_NAME_ROBO: burger-war-robo
WORKSPACE_DIR: ${HOME}/work/burger_war_dev/burger_war_dev/catkin_ws
DOCKER_ROOT_DIR: ${HOME}/work/burger_war_dev/burger_war_dev/catkin_ws/src/burger_war_dev/docker
DOCKER_FILE_CORE: ${HOME}/work/burger_war_dev/burger_war_dev/catkin_ws/src/burger_war_dev/docker/core/Dockerfile
DOCKER_FILE_SIM: ${HOME}/work/burger_war_dev/burger_war_dev/catkin_ws/src/burger_war_dev/docker/sim/Dockerfile
DOCKER_FILE_ROBO: ${HOME}/work/burger_war_dev/burger_war_dev/catkin_ws/src/burger_war_dev/docker/robo/Dockerfile
TEST_LOG_ARCHIVE: test_logs-${{ github.run_number }}
DISPLAY: ':99'
KIT_VERSION: latest
# 実行する処理
jobs:
# ビルドとテストを実施し、テストにPASSすれば、仮バージョンでプッシュ
build-test:
runs-on: ubuntu-20.04
steps:
# ディレクトリの準備
- name: Create Workspace
run: |
mkdir -p ${{ env.WORKSPACE_DIR }}/logs
mkdir -p ${{ env.WORKSPACE_DIR }}/src
# burger_war_kitのチェックアウト
- name: Checkout Kit Repository
uses: actions/checkout@v2
with:
repository: p-robotics-hub/burger_war_kit
path: catkin_ws/src/burger_war_kit
# burger_war_devのチェックアウト
- name: Checkout Dev Repository
uses: actions/checkout@v2
with:
path: catkin_ws/src/burger_war_dev
# # 追加ライブラリのチェックアウト
# - name: Checkout Library Repository
# uses: actions/checkout@v2
# with:
# repository: tysik/obstacle_detector
# path: catkin_ws/src/obstacle_detector
# burger-warのソースリストの確認(ホスト側)
- name: Source Package List(Host)
run: |
echo "catkin_ws/src ======================================================"
ls -la ${{ env.WORKSPACE_DIR }}/src/*
echo "${GITHUB_WORKSPACE} ======================================================"
ls -la ${GITHUB_WORKSPACE}
# Dockerのversion確認
- name: Print Docker Version
run: |
docker version
# burger-warイメージのビルド
- name: Build Core Image
run: |
docker build --file ${{ env.DOCKER_FILE_CORE }} --tag ${{ env.IMAGE_NAME_CORE }} --build-arg KIT_VERSION=${{ env.KIT_VERSION }} ${{ env.DOCKER_ROOT_DIR }}
- name: Build Sim Image
run: |
docker build --file ${{ env.DOCKER_FILE_SIM }} --tag ${{ env.IMAGE_NAME_SIM }} ${{ env.DOCKER_ROOT_DIR }}
- name: Build Robo Image
run: |
docker build --file ${{ env.DOCKER_FILE_ROBO }} --tag ${{ env.IMAGE_NAME_ROBO }} ${{ env.DOCKER_ROOT_DIR }}
# xvfbのインストールと起動
- name: Xvfb install and run
run: |
sudo apt-get install -y xvfb
Xvfb -ac ${{ env.DISPLAY }} -screen 0 1280x780x24 &
# burger-warコンテナ起動
- name: Launch Docker Container
run: |
docker run \
--name ${{ env.IMAGE_NAME_CORE }} \
-d \
--privileged \
--net host \
--mount type=bind,src=${{ env.WORKSPACE_DIR }},dst=/home/developer/catkin_ws \
--device /dev/snd \
-v /dev/shm \
-e DISPLAY=${{ env.DISPLAY }} \
-e HOST_USER_ID=$(id -u) \
-e HOST_GROUP_ID=$(id -g) \
${{ env.IMAGE_NAME_CORE }} \
tail -f /dev/null
docker ps -a
docker logs ${{ env.IMAGE_NAME_CORE }}
# burger-warのソースリストの確認(コンテナ側)
- name: Source Package List(Container)
run: |
docker exec -u developer -t ${{ env.IMAGE_NAME_CORE }} bash -l -c "ls -la /home/developer/catkin_ws/src/*"
# ロボコンプロジェクトのビルド
- name: Build Robot Programs
run: |
docker exec -u developer -t ${{ env.IMAGE_NAME_CORE }} bash -l -c "catkin build"
# burger-warのテスト
- name: Test Docker Image
id: image-test
run: |
docker exec -u developer -t ${{ env.IMAGE_NAME_CORE }} bash -l -c "cd src/burger_war_kit && bash scripts/sim_run_test.sh" \
&& echo "::set-output name=test_result::0" \
|| echo "::set-output name=test_result::1"
# テスト結果をArtifactにアップロードする
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: ${{ env.TEST_LOG_ARCHIVE }}
path: /home/runner/work/burger_war_dev/burger_war_dev/catkin_ws/logs/test_logs.tgz
retention-days: 90
# ghcr.ioにログイン
- name: Login to ghrc.io
if: steps.image-test.outputs.test_result == 0 && github.event.inputs.release_enable == 'yes' && env.ENV_GHCR_USERNAME != null
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PASSWORD }}
env:
ENV_GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
# burger-warイメージをghcr.ioにプッシュ
- name: Push Docker Image
if: steps.image-test.outputs.test_result == 0 && github.event.inputs.release_enable == 'yes' && env.ENV_GHCR_USERNAME != null
run: |
# burger-war-coreのプッシュ
docker tag ${{ env.IMAGE_NAME_CORE }} ${{ env.RESISTRY_URL }}/${{ env.IMAGE_NAME_CORE }}
docker push ${{ env.RESISTRY_URL }}/${{ env.IMAGE_NAME_CORE }}
# burger-war-simのプッシュ
docker tag ${{ env.IMAGE_NAME_SIM }} ${{ env.RESISTRY_URL }}/${{ env.IMAGE_NAME_SIM }}
docker push ${{ env.RESISTRY_URL }}/${{ env.IMAGE_NAME_SIM }}
# burger-war-roboのプッシュ
docker tag ${{ env.IMAGE_NAME_ROBO }} ${{ env.RESISTRY_URL }}/${{ env.IMAGE_NAME_ROBO }}
docker push ${{ env.RESISTRY_URL }}/${{ env.IMAGE_NAME_ROBO }}
env:
ENV_GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
# テストがNGだった場合
- name: If Test Failed
if: steps.image-test.outputs.test_result != 0
run: |
echo "::error::Test is failed!!"
echo "::error::See step 'Test Docker Image'"
exit 1