Skip to content

Separete scenario tests to multiple jobs #326

Separete scenario tests to multiple jobs

Separete scenario tests to multiple jobs #326

Workflow file for this run

name: Scenario Test
on:
pull_request:
paths-ignore:
- '**.md'
- '.github/workflows/build_docker_image.yaml'
workflow_dispatch:
permissions:
pull-requests: write # For uploading PR comments
# For uploading docker image
contents: read
packages: write
env:
PYTHON_VERSION: 3.10
CONSAI_TAG: humble-light-sha-${{ github.sha }}
jobs:
create_docker_image:
uses: ./.github/workflows/build_docker_image_for_ci.yaml
environment_setup:
needs: create_docker_image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip packages
uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.cache/pypoetry
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install robocup_scenario_test library
run: |
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
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Pull Docker Compose images
run: |
docker compose -f .docker/consai-grsim-compose.yml pull
env:
CONSAI_TAG: ${{ env.CONSAI_TAG }}
scenario_test:
needs: environment_setup
strategy:
matrix:
env:
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "tests/test_scenario_ball_placement.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "tests/test_scenario_force_start.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "tests/test_scenario_free_kick.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "tests/test_scenario_halt.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "tests/test_scenario_kickoff.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "tests/test_scenario_obstacle_avoidance.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "tests/test_scenario_penalty.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "tests/test_scenario_stop.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "tests/test_scenario_timeout.py"}
- {CONSAI_YELLOW: "true", CONSAI_INVERT: "true", TEST_NAME: "tests/yellow_invert/test_scenario_yellow_invert_kickoff.py"}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip packages
uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.cache/pypoetry
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Start Docker Compose services
run: |
docker compose -f .docker/consai-grsim-compose.yml up -d
env:
CONSAI_TAG: ${{ env.CONSAI_TAG }}
CONSAI_YELLOW: ${{ matrix.env.CONSAI_YELLOW }}
CONSAI_INVERT: ${{ matrix.env.CONSAI_INVERT }}
- name: Wait for game.py to start
timeout-minutes: 5
run: |
CHECK_INTERVAL=5
until docker top consai 2>/dev/null | grep -q game.py
do
echo "Waiting for game.py to start..."
sleep $CHECK_INTERVAL
done
echo "game.py started!"
- 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
run: |
pytest ${{ matrix.env.TEST_NAME }} --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/consai-grsim-compose.yml logs --tail 100
- name: Clean up Docker Compose services
if: always()
run: docker compose -f .docker/consai-grsim-compose.yml down
- name: Upload artifacts
id: upload-artifact
if: env.LOG_EXISTS != ''
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.env.TEST_NAME}}-failure-logs
path: '*.log.gz'
- name: Comment PR with Artifact URL
if: env.LOG_EXISTS != ''
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 }}