Scenario Test #313
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Scenario Test | |
on: | |
workflow_run: | |
workflows: [Create and publish a Docker image for CI] | |
types: | |
- completed | |
workflow_dispatch: | |
permissions: | |
pull-requests: write # For uploading PR comments | |
jobs: | |
on-failure: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | |
steps: | |
- run: echo 'The triggering workflow failed' | |
scenario_test: | |
strategy: | |
matrix: | |
env: | |
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_DIR: "tests/test_scenario_*.py"} | |
- {CONSAI_YELLOW: "true", CONSAI_INVERT: "true", TEST_DIR: "tests/yellow_invert/test_scenario_*.py"} | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.10' | |
- 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: Download SHA artifact | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
uses: actions/download-artifact@v4 | |
with: | |
name: image_sha | |
- name: Start Docker Compose services | |
run: | | |
if [ -f image_sha.txt ]; then | |
CONSAI_TAG=humble-light-sha-$(cat image_sha.txt) | |
else | |
CONSAI_TAG=humble-light | |
fi | |
docker compose -f .docker/consai-grsim-compose.yml up -d | |
env: | |
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_DIR }} --vision_port=10020 --logging --log_recorder=./ssl-log-recorder | |
- 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: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: failure-logs | |
path: '*.log.gz' | |
- name: Check if Artifact was uploaded | |
id: check-artifact | |
if: always() | |
run: | | |
if [ -z "${{ steps.upload-artifact.outputs.artifact-url }}" ]; then | |
echo "Artifact URL not found, skipping comment." | |
echo "skip_comment=true" >> $GITHUB_OUTPUT | |
else | |
echo "Artifact URL found." | |
echo "skip_comment=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Comment PR with Artifact URL | |
if: always() && steps.check-artifact.outputs.skip_comment != 'true' | |
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 }} |