Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add action to check the app accessibility after serving #1686

Merged
merged 8 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/actions/check-app-accessibility/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'Check App Accessibility'
description: 'Parse logs and check if the app is running'
inputs:
log-file:
description: 'The path to the log file containing the serve output'
required: true
runs:
using: "composite"
steps:
- name: Parse logs and check if app is running
id: check-app
shell: bash
run: |

echo "Serve output:"
cat ${{ inputs.log-file }}
APP_URL=$(grep -oP 'You can access it here: \K.+' ${{ inputs.log-file }} | head -n 1)
echo "Extracted app URL: $APP_URL"
if [ -z "$APP_URL" ]; then
echo "Error: Failed to extract app URL from logs."
exit 1
fi
APP_URL="${APP_URL%/}/openapi.json"

echo "Checking if $APP_URL is accessible"
retries=6
for i in $(seq 1 $retries); do
status_code=$(curl --max-time 60 --write-out %{http_code} --silent --output /dev/null --verbose $APP_URL)
echo "Attempt $i: Status code: $status_code"
if [ "$status_code" -eq 200 ]; then
echo "$APP_URL is accessible"
exit 0
else
echo "Attempt $i failed: $APP_URL is not accessible"
sleep 10 # Wait before retrying
fi
done

echo "Error: $APP_URL is not accessible after $retries attempts"
exit 1
16 changes: 14 additions & 2 deletions .github/workflows/cli-commands-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ jobs:
- name: Run agenta variant serve
run: |
cd examples/baby_name_generator
agenta variant serve --file_name app.py
agenta variant serve --file_name app.py 2>&1 | tee ../../serve_output.log
shell: bash
continue-on-error: false

- name: Check if app is running
uses: ./.github/actions/check-app-accessibility
with:
log-file: serve_output.log
continue-on-error: false

- name: Run agenta variant serve with overwrite
run: |
cd examples/baby_name_generator
Expand Down Expand Up @@ -90,10 +96,16 @@ jobs:
- name: Run agenta variant serve
run: |
cd examples/baby_name_generator
agenta variant serve --file_name app.py
agenta variant serve --file_name app.py 2>&1 | tee ../../serve_output.log
shell: bash
continue-on-error: false

- name: Check if app is running
uses: ./.github/actions/check-app-accessibility
with:
log-file: serve_output.log
continue-on-error: false

- name: Run agenta variant serve with overwrite
run: |
cd examples/baby_name_generator
Expand Down
Loading