crytic / slither-action

GNU Affero General Public License v3.0
127 stars 19 forks source link

Unable to use Slither output in subsequent step #65

Closed eugenPtr closed 7 months ago

eugenPtr commented 7 months ago

Hi, I am trying to create a comment on the PR with the report in Markdown format.

My issue is that ${{ steps.slither.outputs.stdout }} is always empty. Checking the workflow output, I can see the report being generated normally in Markdown format but I cannot use it in subsequent steps.

Here is my yaml file

name: Run Slither Analysis

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

env:
  FOUNDRY_PROFILE: ci

jobs:
  run-slither:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3

      - name: Run Slither
        uses: crytic/slither-action@v0.3.0
        id: slither
        continue-on-error: true
        with:
          target: 'foundry-project/'
          node-version: 16
          fail-on: medium
          slither-args: --checklist --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/

      - name: Check output
        run: |
          echo "Slither report: "
          echo "${{ steps.slither.outputs.stdout }}"

      - name: Create/update checklist as PR comment
        uses: actions/github-script@v6
        env:
          REPORT: ${{ steps.slither.outputs.stdout }}
        with:
          github-token: ${{ secrets.REPO_ADMIN_PAT}}
          script: |
            const script = require('.github/scripts/comment')
            const header = '# Slither report'
            const body = process.env.REPORT
            console.log("Body: ", body)
            await script({ github, context, header, body })

Here is the log of the "Check output" step

##[debug]Evaluating condition for step: 'Check output'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Check output
##[debug]Loading inputs
##[debug]Evaluating: format('echo "Slither report: "
##[debug]echo "{0}"
##[debug]', steps.slither.outputs.stdout)
##[debug]Evaluating format:
##[debug]..Evaluating String:
##[debug]..=> 'echo "Slither report: "
##[debug]echo "{0}"
##[debug]'
##[debug]..Evaluating Index:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating steps:
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'slither'
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'outputs'
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'stdout'
##[debug]..=> null
##[debug]=> 'echo "Slither report: "
##[debug]echo ""
##[debug]'
##[debug]Result: 'echo "Slither report: "
##[debug]echo ""
##[debug]'
##[debug]Loading env
Run echo "Slither report: "
##[debug]/usr/bin/bash -e /home/runner/work/_temp/6d60a855-[2](https://github.com/NethermindEth/improbable-eggnog-delegated-staking/actions/runs/7573769799/job/20626712682#step:5:2)2ff-468f-a7ea-aad[3](https://github.com/NethermindEth/improbable-eggnog-delegated-staking/actions/runs/7573769799/job/20626712682#step:5:3)[4](https://github.com/NethermindEth/improbable-eggnog-delegated-staking/actions/runs/7573769799/job/20626712682#step:5:4)60682[5](https://github.com/NethermindEth/improbable-eggnog-delegated-staking/actions/runs/7573769799/job/20626712682#step:5:5)3.sh
Slither report: 

##[debug]Finishing: Check output

The body is also empty when console.logged in the following step.

image

Any clues what could be causing the issue here?

elopez commented 7 months ago

Hi! thanks for the report @eugenPtr . My suspicion is that, as you're using fail-on: medium and continue-on-error: true, the Slither step is failing early and thus not producing the stdout variable. Exporting the Slither stdout into steps.slither.outputs.stdout is the very last thing done by the action on a successful run.

Would you mind trying with fail-on: none and removing continue-on-error: true and reporting back?

eugenPtr commented 7 months ago

@elopez thank you so much for the prompt response. That did the trick! Thank you ser!