diff --git a/.devcontainer/smoke_test.sh b/.devcontainer/smoke_test.sh new file mode 100755 index 0000000..cd0291a --- /dev/null +++ b/.devcontainer/smoke_test.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -e + +mushr_noetic run 'source ~/.bashrc && roslaunch mushr_sim teleop.launch' > /tmp/output & +sleep 5 +if tail -n 1 /tmp/output | grep -q "Rosbridge WebSocket server started at ws://0.0.0.0:9090"; then + echo "✅ smoke_test passed" + exit 0; +else + # Print output of `roslaunch mushr_sim teleop.launch` for debugging + cat /tmp/output + echo "❌ smoke_test failed" + exit 1; +fi \ No newline at end of file diff --git a/.github/workflows/devcontainer-test.sh b/.github/workflows/devcontainer-test.sh new file mode 100755 index 0000000..a04022c --- /dev/null +++ b/.github/workflows/devcontainer-test.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -e + +SRC_DIR="$(pwd)" + +echo "Running Smoke Test" + +# Build +export DOCKER_BUILDKIT=1 +echo "(*) Installing @devcontainer/cli" +npm install -g @devcontainers/cli + +echo "Building Dev Container" +ID_LABEL="test-container=mushr" +devcontainer up --id-label ${ID_LABEL} --workspace-folder "${SRC_DIR}" + +# Test +devcontainer exec --workspace-folder "${SRC_DIR}" --id-label ${ID_LABEL} /bin/sh -c './src/mushr/.devcontainer/smoke_test.sh' + +# Clean up +docker rm -f $(docker container ls -f "label=${ID_LABEL}" -q) diff --git a/.github/workflows/test-pr.yaml b/.github/workflows/test-pr.yaml new file mode 100644 index 0000000..2cb966d --- /dev/null +++ b/.github/workflows/test-pr.yaml @@ -0,0 +1,16 @@ +name: "CI" +on: + pull_request: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout main + id: checkout_release + uses: actions/checkout@v3 + - name: Devcontainer container smoke test + id: test_devcontainer + shell: bash + run: ./.github/workflows/devcontainer-test.sh \ No newline at end of file