Skip to content

Docker release

Docker release #332

Workflow file for this run

name: Docker release
on:
push:
branches:
- '**'
schedule:
- cron: '0 0 * * 0'
jobs:
build-docker:
runs-on: ubuntu-20.04
env:
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/baseline_walking_controller
steps:
- name: Checkout repository code
uses: actions/checkout@v3
with:
submodules: recursive
path: BaselineWalkingController
- name: Docker version
run: docker version
- name: Build docker image
run: |
cd ${GITHUB_WORKSPACE}/BaselineWalkingController/.github/workflows/
docker build -t ${IMAGE_NAME}_ci:${{ github.sha }} --build-arg REPOSITORY=${{ github.repository_owner }} --build-arg COMMIT_SHA=${{ github.sha }} .
- name: Docker images
run: docker images
- name: Login to registries
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
- name: Push image for CI
run: |
docker push ${IMAGE_NAME}_ci:${{ github.sha }}
- name: Push image for release
if: github.repository_owner == 'isri-aist' && github.ref == 'refs/heads/master'
run: |
docker tag ${IMAGE_NAME}_ci:${{ github.sha }} ${IMAGE_NAME}:latest
docker push ${IMAGE_NAME}:latest
test-docker:
needs: build-docker
strategy:
fail-fast: false
matrix:
mpc-method: [PreviewControlZmp]
mpc-framework: [OpenLoopMpc]
motion-type: [WalkingOnPlane, WalkingOnStairs, WalkingOnPlaneVel, WalkingWithFootstepPlanner]
runs-on: ubuntu-20.04
container:
image: ghcr.io/${{ github.repository_owner }}/baseline_walking_controller_ci:${{ github.sha }}
env:
HOME: /root
RESULTS_POSTFIX: ${{ matrix.mpc-method }}-${{ matrix.mpc-framework }}-${{ matrix.motion-type }}-docker
steps:
- name: Check repository
shell: bash
run: |
set -e
. ${HOME}/catkin_ws/devel/setup.bash
roscd baseline_walking_controller
set -x
git remote get-url origin
git log HEAD^..HEAD
- name: Run simulation
shell: bash
run: |
set -e
. ${HOME}/catkin_ws/devel/setup.bash
set -x
export DISPLAY=":1"
Xvfb ${DISPLAY} -screen 0 1920x1080x24 &
sleep 10s
fluxbox 2> /dev/null &
mkdir -p ${HOME}/.config/mc_rtc/controllers
cp ${HOME}/catkin_ws/src/isri-aist/BaselineWalkingController/etc/mc_rtc.yaml ${HOME}/.config/mc_rtc
CI_DIR=${HOME}/catkin_ws/src/isri-aist/BaselineWalkingController/.github/workflows
python3 ${CI_DIR}/scripts/mergeConfigs.py ${CI_DIR}/config/${{ matrix.mpc-method }}.yaml ${CI_DIR}/config/${{ matrix.mpc-framework }}.yaml ${CI_DIR}/config/${{ matrix.motion-type }}.yaml > ${HOME}/.config/mc_rtc/controllers/BaselineWalkingController.yaml
ffmpeg -y -f x11grab -s 1920x1080 -r 30 -i ${DISPLAY} -qscale 0 -vcodec huffyuv /tmp/video.avi > /dev/null 2>&1 < /dev/null &
FFMPEG_PID=$!
cd /usr/share/hrpsys/samples/JVRC1
./clear-omninames.sh
if [ "${{ matrix.motion-type }}" == "WalkingOnPlane" -o "${{ matrix.motion-type }}" == "WalkingOnPlaneVel" ]; then
CNOID_FILE=sim_mc.cnoid
else
CNOID_FILE=sim_mc_comanoid_staircase.cnoid
fi
choreonoid ${CNOID_FILE} --test-mode --start-simulation &
CNOID_PID=$!
if [ "${{ matrix.motion-type }}" == "WalkingWithFootstepPlanner" ]; then
SLEEP_DURATION="70s"
else
SLEEP_DURATION="50s"
fi
sleep ${SLEEP_DURATION}
kill -2 ${CNOID_PID}
kill -2 ${FFMPEG_PID}
sleep 1s
kill -9 ${CNOID_PID} || true
sleep 10s
mkdir -p /tmp/results
ffmpeg -nostats -i /tmp/video.avi /tmp/results/BWC-video-${RESULTS_POSTFIX}.mp4
LOG_FILENAME=BWC-log-${RESULTS_POSTFIX}
mv `readlink -f /tmp/mc-control-BaselineWalkingController-latest.bin` /tmp/${LOG_FILENAME}.bin
tar czf /tmp/results/${LOG_FILENAME}.tar.gz -C /tmp ${LOG_FILENAME}.bin
- name: Upload simulation data
uses: actions/upload-artifact@v3
with:
name: BWC-docker-results
path: /tmp/results
- name: Check simulation results
shell: bash
run: |
set -e
set -x
if [ "${{ matrix.motion-type }}" == "WalkingOnPlane" ]; then
EXPECTED_BASE_POS="1.34 -0.41 0.8"
elif [ "${{ matrix.motion-type }}" == "WalkingOnStairs" ]; then
EXPECTED_BASE_POS="1.75 0.0 1.68"
elif [ "${{ matrix.motion-type }}" == "WalkingOnPlaneVel" ]; then
EXPECTED_BASE_POS="0.74 -0.53 0.8"
else # if [ "${{ matrix.motion-type }}" == "WalkingWithFootstepPlanner" ]; then
EXPECTED_BASE_POS="2.5 -0.25 0.8"
fi
LOG_FILENAME=BWC-log-${RESULTS_POSTFIX}
CI_DIR=${HOME}/catkin_ws/src/isri-aist/BaselineWalkingController/.github/workflows
python3 ${CI_DIR}/scripts/checkSimulationResults.py /tmp/${LOG_FILENAME}.bin --expected-base-pos ${EXPECTED_BASE_POS}