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 test failure workflow #13

Merged
merged 16 commits into from
Nov 1, 2024
44 changes: 44 additions & 0 deletions .github/workflows/test-kaggle-script-action-failure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Test Kaggle Script Action Failure

on:
pull_request:

jobs:
test_kaggle_action_failure:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Kaggle API credentials
env:
KAGGLE_USERNAME: ${{ secrets.KAGGLE_USERNAME }}
KAGGLE_KEY: ${{ secrets.KAGGLE_KEY }}
run: |
echo "KAGGLE_USERNAME=${KAGGLE_USERNAME}" >> $GITHUB_ENV
echo "KAGGLE_KEY=${KAGGLE_KEY}" >> $GITHUB_ENV

- name: Test Kaggle Script Action Failure
id: kaggle_test
uses: ./
with:
username: ${{ secrets.KAGGLE_USERNAME }}
key: ${{ secrets.KAGGLE_KEY }}
title: "Test Kaggle Script Action Failure"
custom_script: |
python test.py --url "https://jsonplaceholder.typicode.com/nonexistent"
working_subdir: "tests"
enable_internet: true
enable_gpu: true
enable_tpu: false
sleep_time: 10
continue-on-error: true

- name: Verify Workflow Outcome
if: steps.kaggle_test.outcome == 'success'
run: exit 1

- name: Verify Workflow Outcome (Negative Case)
if: steps.kaggle_test.outcome == 'failure'
run: exit 0
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ on:
pull_request:

jobs:
test_kaggle_action:
test_kaggle_script_action:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Kaggle API credentials
env:
KAGGLE_USERNAME: ${{ secrets.KAGGLE_USERNAME }}
KAGGLE_KEY: ${{ secrets.KAGGLE_KEY }}
run: |
echo "KAGGLE_USERNAME=${KAGGLE_USERNAME}" >> $GITHUB_ENV
echo "KAGGLE_KEY=${KAGGLE_KEY}" >> $GITHUB_ENV

- name: Test Kaggle Script Action
uses: ./
with:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ on:
pull_request:

jobs:
test_kaggle_action:
run_unit_tests:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Execute Kaggle Script Action
uses: KevKibe/[email protected].1
uses: KevKibe/[email protected].2
with:
username: ${{ secrets.KAGGLE_USERNAME }}
key: ${{ secrets.KAGGLE_KEY }}
Expand All @@ -79,15 +79,15 @@ on:
- main

jobs:
test_kaggle_action:
run_model_training:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Run Bert Model Training
uses: KevKibe/[email protected].1
uses: KevKibe/[email protected].2
with:
username: ${{ secrets.KAGGLE_USERNAME }}
key: ${{ secrets.KAGGLE_KEY }}
Expand Down
24 changes: 17 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,15 @@ runs:
action_path="${{ github.action_path }}"
action_path=$(realpath "${{ github.action_path }}")
echo "Checking status for Kaggle kernel: '$kernel_name'"

log_message() {
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1"
}

while true; do
log_message "Retrieving kernel status..."
status=$(kaggle kernels status "$kernel_name" 2>&1)

if [[ "$status" == *"403"* || "$status" == *"denied"* ]]; then
log_message "::error::Access denied or kernel not found. Check if the API key has permissions and if the kernel name is correct."
exit 1
Expand All @@ -262,17 +263,23 @@ runs:
sleep "${{ inputs.sleep_time }}"
fi
done

log_file="./$kernel_slug.log"

log_message "::group::Full log"
log_message "Fetching full kernel output log for '$kernel_name':"
kaggle kernels output "$kernel_name" -p . 2>&1

if [ -f "$log_file" ]; then
while IFS= read -r line; do
[[ -n "$line" ]] && log_message "$line"
done < <(jq -r '.[].data' "$log_file")
jq -c '.[]' "$log_file" | while IFS= read -r entry; do
data_field=$(echo "$entry" | jq -r '.data')
[[ -n "$data_field" ]] && log_message "$data_field"

if echo "$data_field" | grep -Ei "Error|Traceback|Exception|404 Client Error|failed|FAIL"; then
log_message "::error::Error found in log: $data_field"
exit 1
fi
done
else
log_message "Log file '$log_file' not found."
fi
Expand All @@ -283,6 +290,9 @@ runs:
exit 1
fi




branding:
icon: upload
color: green
Loading