actionlint icon indicating copy to clipboard operation
actionlint copied to clipboard

Unable to ignore errors by `paths` config

Open pociej opened this issue 2 years ago • 10 comments

Hi I observed strange experience Im unable to understand.

here is me config

self-hosted-runner:
  labels:
    - aws-linux-small
    - aws-linux-medium
paths:
  .github/workflows/**/*.yaml:
    ignore:
      - 'shellcheck reported issue in this script: SC2086:.+'
      - 'shellcheck reported issue in this script: SC2046:.+'
      - 'shellcheck reported issue in this script: SC2155:.+'
      - 'shellcheck reported issue in this script: SC2044:.+'

It was working for me perfectly fine and stopped because of reasons i dont understand. Im now hited by errors listed on ignore list

like that

.github/workflows/release.yaml:429:7: shellcheck reported issue in this script: SC2086:info:2:29: Double quote to prevent globbing and word splitting [shellcheck]
    |
429 |       run: |
    |       ^~~~
.github/workflows/test_e2e_devnet.yaml:57:9: shellcheck reported issue in this script: SC2044:warning:1:17: For loops over find output are fragile. Use find -exec or a while read loop [shellcheck]
   |
[57](https://github.com/vlayer-xyz/vlayer/actions/runs/11928877667/job/33246589658#step:4:58) |         run: |
   |         ^~~~

Im sure the config file is properly loaded as self-hosted-runners are there. Im running actionlint as documented :

jobs:
  actionlint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Download actionlint
        id: get_actionlint
        run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) 
        shell: bash
      - name: Check workflow files
        run: ${{ steps.get_actionlint.outputs.executable }}
        shell: bash

any idea of what could be the reason? Thx in advance.

pociej avatar Nov 20 '24 08:11 pociej

Can you provide your workflow input (smaller is better) which can reproduce this issue?

rhysd avatar Nov 21 '24 10:11 rhysd

@pociej make sure you are targeting the correct files, I had a problem yesterday with this too, then I realized I had to change the glob to *.{yaml,yml}

ahmedelgabri avatar Nov 21 '24 10:11 ahmedelgabri

I tried to reproduce it but I could not.

.github/actionlint.yaml:

paths:
  .github/workflows/**/*.yaml:
    ignore:
      - 'shellcheck reported issue in this script: SC2086:.+'

.github/workflows/test.yaml:

on: push

jobs:
  tests:
    runs-on: ubuntu-latest
    steps:
      # This causes SC2086
      - run: echo $FOO

And I ran:

actionlint

The command did not report any error. When I removed actionlint.yaml, it reported an error. So the command seems to work as intended.

Can you check actionlint command is the latest by actionlint -version?

rhysd avatar Nov 21 '24 10:11 rhysd

This is happening to me too.

.github/actionlint.yml:

paths:
  .github/workflows/**/*.yml:
    ignore:
      - 'the runner of ".+" action is too old to run on GitHub Actions'

.github/workflows/simple.yml:

on:
  pull_request:
jobs:
  checkout:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

Run:

actionlint

Output:

simple.yml:7:15: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]
   |
7 |       - uses: actions/checkout@v3
   |               ^~~~~~~~~~~~~~~~~~~

Version:

actionlint -version
1.7.4
installed by building from source
built with go1.23.2 compiler for darwin/arm64

Note: If I run actionlint -ignore 'the runner of ".+" action is too old to run on GitHub Actions.' it is ignored.

chrisponton avatar Nov 22 '24 12:11 chrisponton

Thank you @chrisponton for the steps. However, I still cannot reproduce this issue... actionlint command reports nothing. And when removing the - 'the runner of ".+" action is too old to run on GitHub Actions' line, it reports one error as expected.

Here are the steps I tried:

rm -rf ./tmp  # Ensure the directory doesn't exist
mkdir ./tmp && cd ./tmp
mkdir -p .github/workflows
vim .github/actionlint.yml  # Write the config file
vim .github/workflows/simple.yml  # Write the workflow file
git init
actionlint

And actionlint in my local:

$ which actionlint
/usr/local/bin/actionlint
$ actionlint -version
1.7.4
installed by building from source
built with go1.23.2 compiler for darwin/amd64

Is anything different from what you tried?

And one additional question. How do you run actionlint command? (running directly from your terminal, via some text editor extention, via some tools such as pre-commit, via Docker container, on CI, ...)

rhysd avatar Nov 24 '24 05:11 rhysd

Hi @rhysd. Thank you for trying to replicate it again.

I tried your steps and it worked with a new folder so revisited my repository, cleared it out and added it again.

It started to work which was odd... I do wonder if I was doing something silly like not running actionLint from the root folder but not sure now.

Anyway, this works for me now. Thank you.

I did although have something odd where an issue was not found locally but was in the GitHub action, adding further ignores resolved it though. The action was using this method.

Happy for this issue to be closed.

chrisponton avatar Nov 25 '24 13:11 chrisponton

@chrisponton I appreciate your effort for the repro. That sounds weird. I guess there would be some hidden pre-condition. Let's keep this issue open with not-reproducible label so that someone else will be able to provide another repro in the future.

rhysd avatar Nov 26 '24 14:11 rhysd

~~I have a minimal reproduction for this here https://github.com/pseudo-su/actionlint-repro-issue-481~~

~~looks like it was fixed in versions 1.7.4 onwards~~

# Not working in versions
go run github.com/rhysd/actionlint/cmd/[email protected]
go run github.com/rhysd/actionlint/cmd/[email protected]
go run github.com/rhysd/actionlint/cmd/[email protected]
go run github.com/rhysd/actionlint/cmd/[email protected]

# Working in versions
go run github.com/rhysd/actionlint/cmd/[email protected]
go run github.com/rhysd/actionlint/cmd/[email protected]
go run github.com/rhysd/actionlint/cmd/[email protected]
go run github.com/rhysd/actionlint/cmd/[email protected]

edit: just looked at the release notes and realised that the ignore config feature was only added in v1.7.4 🤦‍♂

pseudo-su avatar Jan 30 '25 05:01 pseudo-su

Always on

Riyan12xx avatar Jan 30 '25 10:01 Riyan12xx

I'm also experiencing an issue where:

  • I have an actionlint.yml I know is getting picked up because the self-hosted runners I've declared there are not being reported as invaid
  • running actionlint -color -ignore '"env" is not allowed in "runs" section because .* is a Composite action.*' passes w/ exit code 0, but not when the ignore is put in my config file:
# See https://github.com/rhysd/actionlint/blob/main/docs/config.md
self-hosted-runner:
  labels:
    - ubuntu-latest-xl
    - macos-15-large
    - macos-15-xlarge
    - ubuntu-latest-reassure-tests
    - macos-12

paths:
  .github/workflows/**/*.{yml,yaml}:
    ignore:
      - '"env" is not allowed in "runs" section because .* is a Composite action.*'

Edit: Probably a misconfig in my path. I was able to fix it in my case with this diff:

-   .github/workflows/**/*.{yml,yaml}:
+   '**/*':

roryabraham avatar Feb 05 '25 19:02 roryabraham