From 3c82d2301fde1f916053728af0a598ab813dc821 Mon Sep 17 00:00:00 2001 From: Zach R Date: Wed, 10 Jan 2024 07:35:45 -0800 Subject: [PATCH] feat: add simulation to PRs --- .github/workflows/build.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ba0370fa..e0f56774 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,12 +1,13 @@ -name: Build +name: CI on: push: pull_request: + jobs: build: - name: Build + name: Build & Simulate runs-on: ubuntu-latest container: wpilib/roborio-cross-ubuntu:2024-22.04 steps: @@ -16,3 +17,12 @@ jobs: run: chmod +x gradlew - name: Build robot code run: ./gradlew build + + # Runs a simulation to spot check crashes + - name: Run simulation to check for runtime errors + run: timeout 1m ./gradlew simulateJava 2>&1 | awk -v rc=0 '/The robot program quit unexpectedly/ { rc=1 } 1; END {exit rc}' + # 1. Run simulation with 1 minute timeout + # 2. Redirect stderr to stdout (just in case) + # 3. Use awk to check for robot crash message and set the return code based on this. (Alternative to grep that doesn't filter the simulation output) + # Stolen from https://github.com/AusTINCANsProgrammingTeam/2022RobotCode/blob/041e469ab0d2047a0c6d66b3d953b5adc3b3e29a/.github/workflows/main.yml#L35-L41 +