|
34 | 34 | echo "${{ github.workspace }}/venv/bin" >> $GITHUB_PATH
|
35 | 35 |
|
36 | 36 | - name: Install xircuits in virtual environment
|
37 |
| - run: | |
38 |
| - python -m pip install --upgrade pip |
39 |
| - pip install xircuits |
| 37 | + run: pip install xircuits |
40 | 38 |
|
41 | 39 | - name: Set Environment Variables
|
42 | 40 | run: |
|
@@ -74,65 +72,74 @@ jobs:
|
74 | 72 |
|
75 | 73 | - name: Test Flask .xircuits Workflow
|
76 | 74 | run: |
|
77 |
| - export PYTHONPATH="${GITHUB_WORKSPACE}:${PYTHONPATH}" |
78 |
| - LOG_FILE="${GITHUB_WORKSPACE}/workflow_logs.txt" |
79 |
| - TEST_FILES=$(echo "$TEST_XIRCUITS" | tr '\n' ' ') |
80 |
| - echo "Starting Flask .xircuits workflow test..." > $LOG_FILE |
81 |
| - IFS=' ' read -r -a FILE_ARRAY <<< "$TEST_FILES" |
82 |
| - if [ ${#FILE_ARRAY[@]} -eq 0 ]; then |
83 |
| - echo "Error: No .xircuits files specified for testing." | tee -a $LOG_FILE |
| 75 | + export PYTHONPATH="${GITHUB_WORKSPACE}:${PYTHONPATH}" |
| 76 | + LOG_FILE="${GITHUB_WORKSPACE}/workflow_logs.txt" |
| 77 | + TEST_FILES=$(echo "$TEST_XIRCUITS" | tr '\n' ' ') |
| 78 | + echo "Starting Flask .xircuits workflow test..." > $LOG_FILE |
| 79 | + IFS=' ' read -r -a FILE_ARRAY <<< "$TEST_FILES" |
| 80 | + if [ ${#FILE_ARRAY[@]} -eq 0 ]; then |
| 81 | + echo "Error: No .xircuits files specified for testing." | tee -a $LOG_FILE |
| 82 | + exit 1 |
| 83 | + fi |
| 84 | + for FILE in "${FILE_ARRAY[@]}"; do |
| 85 | + FULL_PATH="${COMPONENT_LIBRARY_PATH}/${FILE}" |
| 86 | + echo "Processing file: $FULL_PATH" | tee -a $LOG_FILE |
| 87 | + if [ ! -f "$FULL_PATH" ]; then |
| 88 | + echo "Error: Xircuits file not found at $FULL_PATH" | tee -a $LOG_FILE |
84 | 89 | exit 1
|
85 | 90 | fi
|
86 |
| - for FILE in "${FILE_ARRAY[@]}"; do |
87 |
| - FULL_PATH="${COMPONENT_LIBRARY_PATH}/${FILE}" |
88 |
| - echo "Processing file: $FULL_PATH" | tee -a $LOG_FILE |
89 |
| - if [ ! -f "$FULL_PATH" ]; then |
90 |
| - echo "Error: Xircuits file not found at $FULL_PATH" | tee -a $LOG_FILE |
91 |
| - exit 1 |
92 |
| - fi |
93 |
| - echo "Compiling Xircuits workflow: ${FULL_PATH}" >> $LOG_FILE |
94 |
| - xircuits compile "$FULL_PATH" "${FULL_PATH%.*}.py" 2>&1 | tee -a $LOG_FILE |
95 |
| - if [ ! -f "${FULL_PATH%.*}.py" ]; then |
96 |
| - echo "Error: Compiled Python file not found at ${FULL_PATH%.*}.py" | tee -a $LOG_FILE |
97 |
| - exit 1 |
98 |
| - fi |
99 |
| - echo "Running Python script: ${FULL_PATH%.*}.py" >> $LOG_FILE |
100 |
| - python "${FULL_PATH%.*}.py" 2>&1 | tee -a $LOG_FILE & |
101 |
| - PYTHON_PID=$! |
102 |
| - echo "Waiting for Flask server to initialize..." >> $LOG_FILE |
103 |
| - sleep 10 |
| 91 | + echo "Compiling Xircuits workflow: ${FULL_PATH}" >> $LOG_FILE |
| 92 | + xircuits compile "$FULL_PATH" "${FULL_PATH%.*}.py" 2>&1 | tee -a $LOG_FILE |
| 93 | + if [ ! -f "${FULL_PATH%.*}.py" ]; then |
| 94 | + echo "Error: Compiled Python file not found at ${FULL_PATH%.*}.py" | tee -a $LOG_FILE |
| 95 | + exit 1 |
| 96 | + fi |
| 97 | + echo "Running Python script: ${FULL_PATH%.*}.py" >> $LOG_FILE |
| 98 | + python "${FULL_PATH%.*}.py" 2>&1 | tee -a $LOG_FILE & |
| 99 | + PYTHON_PID=$! |
| 100 | + echo "Waiting for Flask server to initialize..." >> $LOG_FILE |
| 101 | + sleep 10 |
| 102 | + |
| 103 | + # Set endpoint and expected result based on file |
| 104 | + if [[ "$FILE" == "examples/InlineExample.xircuits" ]]; then |
| 105 | + TEST_ENDPOINT="http://localhost:5000/greet" |
| 106 | + EXPECTED_RESPONSE="Hello from Xircuits Flask endpoint!" |
| 107 | + else |
104 | 108 | TEST_ENDPOINT="http://127.0.0.1:8080/hello/world"
|
105 |
| - RETRIES=3 |
106 |
| - SUCCESS=0 |
107 |
| - for i in $(seq 1 $RETRIES); do |
108 |
| - echo "Attempt $i: Checking endpoint $TEST_ENDPOINT..." | tee -a $LOG_FILE |
109 |
| - if curl -s "$TEST_ENDPOINT" | grep -q "Hello World!"; then |
110 |
| - echo "Flask test successful: Endpoint $TEST_ENDPOINT is running as expected." | tee -a $LOG_FILE |
111 |
| - SUCCESS=1 |
112 |
| - break |
113 |
| - else |
114 |
| - echo "Attempt $i failed. Retrying in 5 seconds..." | tee -a $LOG_FILE |
115 |
| - sleep 5 |
116 |
| - fi |
117 |
| - done |
118 |
| - if [ $SUCCESS -ne 1 ]; then |
119 |
| - echo "Flask test failed: Endpoint $TEST_ENDPOINT did not respond as expected after $RETRIES attempts." | tee -a $LOG_FILE |
120 |
| - if ps -p $PYTHON_PID > /dev/null; then |
121 |
| - echo "Killing Python script process (PID: $PYTHON_PID)..." >> $LOG_FILE |
122 |
| - kill -9 $PYTHON_PID |
123 |
| - fi |
124 |
| - exit 1 |
| 109 | + EXPECTED_RESPONSE="Hello World!" |
| 110 | + fi |
| 111 | + |
| 112 | + RETRIES=3 |
| 113 | + SUCCESS=0 |
| 114 | + for i in $(seq 1 $RETRIES); do |
| 115 | + echo "Attempt $i: Checking endpoint $TEST_ENDPOINT..." | tee -a $LOG_FILE |
| 116 | + if curl -s "$TEST_ENDPOINT" | grep -q "$EXPECTED_RESPONSE"; then |
| 117 | + echo "Flask test successful: Endpoint $TEST_ENDPOINT responded as expected." | tee -a $LOG_FILE |
| 118 | + SUCCESS=1 |
| 119 | + break |
| 120 | + else |
| 121 | + echo "Attempt $i failed. Retrying in 5 seconds..." | tee -a $LOG_FILE |
| 122 | + sleep 5 |
125 | 123 | fi
|
| 124 | + done |
| 125 | + if [ $SUCCESS -ne 1 ]; then |
| 126 | + echo "Flask test failed: Endpoint $TEST_ENDPOINT did not respond as expected after $RETRIES attempts." | tee -a $LOG_FILE |
126 | 127 | if ps -p $PYTHON_PID > /dev/null; then
|
127 |
| - echo "Python script ran successfully for the duration of the test. Killing the process..." | tee -a $LOG_FILE |
| 128 | + echo "Killing Python script process (PID: $PYTHON_PID)..." >> $LOG_FILE |
128 | 129 | kill -9 $PYTHON_PID
|
129 |
| - else |
130 |
| - echo "Python script finished execution before the test completed." | tee -a $LOG_FILE |
131 | 130 | fi
|
132 |
| - echo "Completed testing file: $FULL_PATH" | tee -a $LOG_FILE |
133 |
| - done |
134 |
| - echo "All Flask and Python script tests completed successfully." >> $LOG_FILE |
135 |
| - |
| 131 | + exit 1 |
| 132 | + fi |
| 133 | + if ps -p $PYTHON_PID > /dev/null; then |
| 134 | + echo "Python script ran successfully for the duration of the test. Killing the process..." | tee -a $LOG_FILE |
| 135 | + kill -9 $PYTHON_PID |
| 136 | + else |
| 137 | + echo "Python script finished execution before the test completed." | tee -a $LOG_FILE |
| 138 | + fi |
| 139 | + echo "Completed testing file: $FULL_PATH" | tee -a $LOG_FILE |
| 140 | + done |
| 141 | + echo "All Flask and Python script tests completed successfully." >> $LOG_FILE |
| 142 | + |
136 | 143 | - name: Upload log file
|
137 | 144 | if: always()
|
138 | 145 | uses: actions/upload-artifact@v4
|
|
0 commit comments