Skip to content

Webサービス向けのバックエンドサーバーの追加 #752

Webサービス向けのバックエンドサーバーの追加

Webサービス向けのバックエンドサーバーの追加 #752

name: scenario test
on:
workflow_dispatch:
pull_request:
merge_group:
env:
PYTHON_VERSION: '3.10'
jobs:
create_scenario_test_image:
name: build image for scenario test
runs-on: ubuntu-latest
env:
DEBIAN_FRONTEND: noninteractive
strategy:
fail-fast: false
matrix:
rosdistro: [humble]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
uses: docker/build-push-action@v5
with:
context: .
file: docker/scenario/Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}:scenario-${{ github.sha }}
cache-from: type=gha
setup_scenario_test_library:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Setup virtual environment
run: |
python -m venv env
source env/bin/activate
- name: Cache virtual environment
uses: actions/cache@v4
with:
path: env
key: ${{ runner.os }}-env-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-env-
- name: Install robocup_scenario_test library
run: |
source env/bin/activate
python -m pip install --upgrade pip
sudo apt update
sudo apt install -y protobuf-compiler
pip install -v git+https://github.com/SSL-Roots/robocup_scenario_test
pip install pytest
scenario_test:
needs: [create_scenario_test_image, setup_scenario_test_library]
strategy:
fail-fast: false
matrix:
env:
# - TEST: STOP_AVOID_BALL
- TEST: STOP_ROBOT_SPEED
- TEST: emit_from_penalty_01
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache virtual environment
uses: actions/cache@v4
with:
path: env
key: ${{ runner.os }}-env-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-env-
- name: Setup virtual environment
run: |
python -m venv env
source env/bin/activate
python -m pip list
- name: Start Docker Compose services
run: |
docker compose -f docker/scenario/docker-compose.yaml up -d
env:
CRANE_TAG: scenario-${{ github.sha }}
- name: Wait for crane to start
timeout-minutes: 5
run: |
sleep 5
- name: Download logger
run: |
curl -L https://github.com/RoboCup-SSL/ssl-go-tools/releases/download/v1.5.2/ssl-log-recorder_v1.5.2_linux_amd64 -o ssl-log-recorder
chmod +x ssl-log-recorder
- name: Run pytest
id: pytest
run: |
source env/bin/activate
pytest scenario_test/${{ matrix.env.TEST }}.py --vision_port=10020 --logging --log_recorder=./ssl-log-recorder
echo "LOG_EXISTS=$(ls *.log.gz 2> /dev/null)" >> $GITHUB_ENV
- name: Get and print logs
if: always()
run: docker compose -f docker/scenario/docker-compose.yaml logs
- name: Clean up Docker Compose services
if: always()
run: docker compose -f docker/scenario/docker-compose.yaml down
- name: setup ssl-log-video
if: ${{ failure() || contains(github.event.pull_request.labels.*.name, 'シナリオテスト動画出力') }}
run: |
export PATH=$PATH:/usr/local/go/bin && \
git clone https://github.com/ibis-ssl/ssl-go-tools.git -b video && \
cd ssl-go-tools/cmd/ssl-log-video && \
go mod tidy && \
go build -o ssl-log-video ssl-log-video.go && \
chmod +x ssl-log-video
- name: make log video
if: ${{ failure() || contains(github.event.pull_request.labels.*.name, 'シナリオテスト動画出力') }}
run: |
export PATH=$PATH:/usr/local/go/bin
sudo apt update
sudo apt install -y ffmpeg
find . -name "*.log.gz" -exec sh -c 'gunzip -c "$1" > "${1%.gz}" && ./ssl-go-tools/cmd/ssl-log-video/ssl-log-video -file "${1%.gz}" -output "${1%.gz}.avi" && ffmpeg -i "${1%.gz}.avi" -vcodec libx264 -acodec aac ${1%.gz}.mp4' _ {} \;
- name: Upload artifacts
id: upload-artifact
if: ${{ failure() || contains(github.event.pull_request.labels.*.name, 'シナリオテスト動画出力') }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.env.TEST}}-failure-log-video
path: '*.mp4'
- name: Comment PR with Artifact URL
if: ${{ failure() }}
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Failure logs: ${{ steps.upload-artifact.outputs.artifact-url }}