Skip to content

Commit 539f836

Browse files
AlexFernandes-MOVAICopilot
andcommitted
fix: add checks for requirements files and improve error handling in Ansible setup
Co-authored-by: Copilot <copilot@github.com>
1 parent 9493286 commit 539f836

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

.github/workflows/integration-platform-remote-fleet-tests.yml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,12 @@ jobs:
407407
echo "::group::Setup Python & Ansible"
408408
python3.10 -m venv ansible-venv
409409
source ansible-venv/bin/activate
410-
python3.10 -m pip install -qq -r requirements.txt
411-
ansible-galaxy install -r requirements.yml --timeout 120
410+
if [ -f requirements.txt ]; then
411+
python3.10 -m pip install -qq -r requirements.txt
412+
fi
413+
if [ -f requirements.yml ]; then
414+
ansible-galaxy install -r requirements.yml --timeout 120
415+
fi
412416
echo "✓ Python venv and Ansible ready"
413417
echo "::endgroup::"
414418
@@ -667,21 +671,31 @@ jobs:
667671
echo "::group::Setup Ansible environment"
668672
python3.10 -m venv ansible-venv
669673
source ansible-venv/bin/activate
670-
python3.10 -m pip install -qq -r requirements.txt || true
671-
ansible-galaxy install -r requirements.yml --timeout 120 || true
674+
if [ -f requirements.txt ]; then
675+
python3.10 -m pip install -qq -r requirements.txt
676+
fi
677+
if [ -f requirements.yml ]; then
678+
ansible-galaxy install -r requirements.yml --timeout 120
679+
fi
672680
echo "✓ Ansible environment ready"
673681
echo "::endgroup::"
674682
675683
echo "::group::Collect fleet host logs"
676684
rm -rf "$QA_ARTIFACTS_PATH"
677685
mkdir -p "$QA_ARTIFACTS_PATH/"
678686
687+
# Fail fast if inventory is missing
688+
if [ ! -f ./provisioned_inventory.yml ]; then
689+
echo "ERROR: provisioned_inventory.yml not found - cannot collect host logs"
690+
exit 1
691+
fi
692+
679693
for fleet_host in "manager" "member0" "member1"; do
680694
echo "Collecting from $fleet_host..."
681-
ansible "$fleet_host" -i ./provisioned_inventory.yml --key-file ~/.ssh/aws_slave.pem -m shell -a 'journalctl -u movai-service --since "1hour ago"' > "$QA_ARTIFACTS_PATH/$fleet_host.log" || true
682-
ansible "$fleet_host" -i ./provisioned_inventory.yml --key-file ~/.ssh/aws_slave.pem -m shell -a 'docker ps -a' > "$QA_ARTIFACTS_PATH/$fleet_host-docker_ps.log" || true
683-
tail -n +2 "$QA_ARTIFACTS_PATH/$fleet_host-docker_ps.log"
684-
ansible "$fleet_host" -i ./provisioned_inventory.yml --key-file ~/.ssh/aws_slave.pem -m shell -a 'journalctl -u docker --boot --lines=all' > "$QA_ARTIFACTS_PATH/$fleet_host-all-docker.log" || true
695+
ansible "$fleet_host" -i ./provisioned_inventory.yml --key-file ~/.ssh/aws_slave.pem -m shell -a 'journalctl -u movai-service --since "1hour ago"' > "$QA_ARTIFACTS_PATH/$fleet_host.log"
696+
ansible "$fleet_host" -i ./provisioned_inventory.yml --key-file ~/.ssh/aws_slave.pem -m shell -a 'docker ps -a' > "$QA_ARTIFACTS_PATH/$fleet_host-docker_ps.log"
697+
tail -n +2 "$QA_ARTIFACTS_PATH/$fleet_host-docker_ps.log" 2>/dev/null || true
698+
ansible "$fleet_host" -i ./provisioned_inventory.yml --key-file ~/.ssh/aws_slave.pem -m shell -a 'journalctl -u docker --boot --lines=all' > "$QA_ARTIFACTS_PATH/$fleet_host-all-docker.log"
685699
done
686700
echo "✓ Host logs collected"
687701
echo "::endgroup::"
@@ -690,7 +704,7 @@ jobs:
690704
# shellcheck disable=SC2086
691705
scp -r -i ~/.ssh/aws_slave.pem -o StrictHostKeyChecking=no \
692706
"${{ needs.Fleet-Tests-Provisioning.outputs.ssh_connect_string }}:${{ env.REMOTE_WORKSPACE_PATH }}/${{ steps.tests_setup.outputs.tests_dir }}/tests_artifacts" \
693-
"$QA_ARTIFACTS_PATH/" || echo "⚠ No test artifacts found"
707+
"$QA_ARTIFACTS_PATH/" || { echo "ERROR: Failed to collect test artifacts"; exit 1; }
694708
echo "✓ Test artifacts collected"
695709
echo "::endgroup::"
696710
deactivate

0 commit comments

Comments
 (0)