testing ci #9
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: Verify and Install IPs | |
on: | |
push: | |
workflow_dispatch: | |
jobs: | |
verify_install: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y jq | |
pip install ipmgr | |
- name: Create results file | |
run: echo "" > results.txt | |
- name: Read and process JSON | |
id: process_json | |
run: | | |
# Extract IP names and their latest version | |
jq -r 'to_entries[] | "\(.key) \(.value.release | keys | last)"' verified_IPs.json > ip_versions.txt | |
- name: Install and verify IPs | |
run: | | |
# Loop through each IP and version | |
while read -r NAME VERSION; do | |
echo "Processing $NAME with version $VERSION" | |
if ipm install "$NAME"; then | |
# Redirect both stdout and stderr to a log file | |
if ipm check-ip --ip-root ~/.ipm/"$NAME"/"$VERSION" --ip-name "$NAME" > check_ip.log 2>&1; then | |
echo "$NAME: PASSED" >> results.txt | |
else | |
# Capture the last 10 lines of the log to determine the failure step | |
FAILURE_LOG=$(tail -n 10 check_ip.log) | |
echo "$NAME: FAILED during check-ip" >> results.txt | |
echo "$NAME failure details:" >> results.txt | |
echo "$FAILURE_LOG" >> results.txt | |
fi | |
else | |
echo "$NAME: FAILED during install" >> results.txt | |
fi | |
done < ip_versions.txt | |
- name: Output results | |
run: cat results.txt | |
- name: Fail job if any IP failed | |
run: | | |
if grep -q "FAILED" results.txt; then | |
echo "Some IPs failed. See results above." | |
exit 1 | |
fi | |
shell: bash |