actions / actions/toolkit

core.setFailed and core.error won't fail the workflow

Open
#1,385 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

I am testing a simple script with github actions

name: CI test

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Install pnpm
      uses: pnpm/action-setup@v2
      with:
        version: 7
    - name: Setup node 16
      uses: actions/setup-node@v3
      with:
        node-version: 16
        cache: pnpm
    - name: Install deps
      run: pnpm install
    - name: Test in Electron
      run: pnpm run test

and my node script is easy

const core = require('@actions/core');

ipc.on('log', (log) => {        
    if(log === 'pass'){
        console.log('CI pass')
    }else{
        core.setFailed(`CI not pass`);
    }
})
ipc.on('error', (log) => {
    core.error(log);
})

it shows errors in actions log, but the workflow still finished and marked as succeeded
Screenshot 2023-03-26 at 14 19 28

Do I miss something?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided workflow and Node script, focusing on the @actions/core setFailed and error calls and how the Test in Electron step exits. Confirm whether the workflow step receives a nonzero failure status; done means the same script reliably marks the workflow as failed when the log is not pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, javascript, node.js, typescript
Domain
ci-cd
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.