diff --git a/.github/workflows/test-kaggle-script-action-failure.yml b/.github/workflows/test-kaggle-script-action-failure.yml new file mode 100644 index 0000000..fe39b28 --- /dev/null +++ b/.github/workflows/test-kaggle-script-action-failure.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/test-kaggle-action.yml b/.github/workflows/test-kaggle-script-action.yml similarity index 65% rename from .github/workflows/test-kaggle-action.yml rename to .github/workflows/test-kaggle-script-action.yml index 15af21c..069242c 100644 --- a/.github/workflows/test-kaggle-action.yml +++ b/.github/workflows/test-kaggle-script-action.yml @@ -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: diff --git a/README.md b/README.md index a8ef67f..99df177 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ on: pull_request: jobs: - test_kaggle_action: + run_unit_tests: runs-on: ubuntu-latest steps: @@ -57,7 +57,7 @@ jobs: uses: actions/checkout@v3 - name: Execute Kaggle Script Action - uses: KevKibe/kaggle-script-action@v1.0.1 + uses: KevKibe/kaggle-script-action@v1.0.2 with: username: ${{ secrets.KAGGLE_USERNAME }} key: ${{ secrets.KAGGLE_KEY }} @@ -79,7 +79,7 @@ on: - main jobs: - test_kaggle_action: + run_model_training: runs-on: ubuntu-latest steps: @@ -87,7 +87,7 @@ jobs: uses: actions/checkout@v3 - name: Run Bert Model Training - uses: KevKibe/kaggle-script-action@v1.0.1 + uses: KevKibe/kaggle-script-action@v1.0.2 with: username: ${{ secrets.KAGGLE_USERNAME }} key: ${{ secrets.KAGGLE_KEY }} diff --git a/action.yml b/action.yml index d89270c..e23d1da 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -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 @@ -283,6 +290,9 @@ runs: exit 1 fi + + + branding: icon: upload color: green