Giter Site home page Giter Site logo

raven-actions / actionlint Goto Github PK

View Code? Open in Web Editor NEW
22.0 2.0 0.0 531 KB

✅ Run actionlint in your GitHub workflow

Home Page: https://github.com/marketplace/actions/actionlint

License: MIT License

actions github github-actions linter workflows actionlint code-quality code-review ci lint

actionlint's Introduction

✅ actionlint Action

GitHub - marketplace GitHub - release GitHub - ci GitHub - license

This GitHub Action allows you to quickly and easily run actionlint in your GitHub workflow using native Runner OS without installing 3rd party dependencies. It is based on an official action lint usage proposal from Use actionlint on GitHub Actions together with Problem Matchers.

  • Action is platform-independent and tested on all the latest GitHub-hosted runners (ubuntu-latest, macos-latest, windows-latest).
  • Uses GitHub cache for caching actionlint binaries for faster and more efficient workflow run.
    • 3rd party actionlint dependencies like shellcheck or pyflakes are not cached, but action installs them if not present on the GitHub Runner using pipx (make sure your GitHub Runner has it).

demo-error

demo-ok

📑 Table of Contents

🛠️ Usage

Quick Start

Just place in your GitHub workflow steps:

- name: actionlint
  uses: raven-actions/actionlint@v2

Customization

You can modify the default configuration with optional inputs. All optional inputs are listed in the 📥 Inputs section.

Action returns some basic information. For more details, follow 📤 Outputs section.

- name: actionlint
  id: actionlint  #optional, id required only when outputs are used in the workflow steps later
  uses: raven-actions/actionlint@v2
  with:
    matcher: false  # optional
    cache: false  # optional
    fail-on-error: false  # optional
    files: "tests/*.yml, tests/*.yaml"  # optional, example on how to grab all .yml and .yaml files from the test directory
    flags: "-ignore SC2086"  # optional

- name: actionlint Summary
  if: ${{ steps.actionlint.outputs.exit-code != 0 }}  # example usage, do echo only when actionlint action failed
  run: |
    echo "Used actionlint version ${{ steps.actionlint.outputs.version-semver }}"
    echo "Used actionlint release ${{ steps.actionlint.outputs.version-tag }}"
    echo "actionlint ended with ${{ steps.actionlint.outputs.exit-code }} exit code"
    echo "actionlint ended because '${{ steps.actionlint.outputs.exit-message }}'"
    echo "actionlint found ${{ steps.actionlint.outputs.total-errors }} errors"
    echo "actionlint checked ${{ steps.actionlint.outputs.total-files }} files"
    echo "actionlint cache used: ${{ steps.actionlint.outputs.cache-hit }}"
    exit ${{ steps.actionlint.outputs.exit-code }}

📥 Inputs

Name Required Type Default value Description
version false string latest SemVer version of actionlint, recommended to keep default: latest
matcher false bool true Use matcher for GitHub annotations.
files false string not set To lint different workflow files (default searching directory is .github/workflows), use comma-separated glob patterns, e.g., tests/*.yml, tests/*.yaml
flags false string not set Extra flags to use with actionlint
group-result false bool true Use the GitHub log grouping feature for failure actionlint results.
fail-on-error false bool true Fail action on actionlint errors.
shellcheck false bool true Use shellcheck with actionlint (and install if it does not exist)
pyflakes false bool true Use pyflakes with actionlint (and install if it does not exist)
cache false bool true Use GitHub cache for caching binaries for the next runs.
github-token false string github.token GitHub Token for API authentication.

📤 Outputs

Name Type Description
version-semver string SemVer version of actionlint, recommended to keep default: latest
version-tag string Use matcher for GitHub annotations
exit-code int Exit status code based on actionlint exit status
exit-message string Exit status message based on actionlint exit status
total-errors int Total number of errors found during the linting
total-files int Total number of checked files
cache-hit bool GitHub cache has been used?

👥 Contributing

Contributions to the project are welcome! Please follow Contributing Guide.

🛡️ License

This project is distributed under the terms of the MIT license.

actionlint's People

Contributors

bhundven avatar dariuszporowski avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

actionlint's Issues

🚀 [feature]: auto-expand the Results group on failures

🚀 Feature description

Do not have the Results group collapsed by default when a job fails, that way the actual error information is available right away.

🔈 Motivation

While the expand feature is great for extra information like the Verbose group, the normal behavior when debugging failures in GitHub Actions (beyond seeing annotations) would be to click on the failing job in the workflow, which automatically expands the failed step and you'll normally see the error directly in the output. Having the Results group collapsed by default makes it less obvious what the issue is, and requires an additional click to get the information you want. The other formatting from niceHeader is great though.

🛰 Alternatives

No response

📎 Additional context

No response

📜 Code of Conduct

  • I agree to follow this project's Code of Conduct.

🚀 [feature]: move to JS action

🚀 Feature description

Action uses composite action type and actions/github-script - it's a good solution for PoC, but for long-term it's not the best solution.

🔈 Motivation

  • improve Secure Supply Chain
  • testing experience
  • strict to package version

🛰 Alternatives

No response

📎 Additional context

No response

📜 Code of Conduct

  • I agree to follow this project's Code of Conduct.

🐛 [bug]: Can't pass -ignore flag

🐛 What happened?

In one of my workflows, I am using an action with dynamic outputs. Actionlint reports those (as they are not explicitly declared) with the error message

property "deprecated_tests_failure_pattern" is not defined in object type {conclusion: string; outcome: string; outputs: {string => string}} [expression]

I would like to ignore them. Locally, I use

 actionlint -ignore 'property ".+" is not defined in object type'

to achieve this. I tried passing the string to the "flags" input of your action, using

      - name: Run actionlint
        id: actionlint
        uses: raven-actions/actionlint@v1
        with:
          flags: '-ignore "property \".+\" is not defined in object type"'

but I am getting an error "could not read "type"": open type": no such file or directory"

I am no javascript expert, but I assume this is due to https://github.com/raven-actions/actionlint/blob/main/action.yml#L355 splitting the "flags" at every space, completely ignoring the quotes.

🔬 How to reproduce?

Use an action with dynamic output (e.g. https://github.com/joernott/load_testplan/tree/main) and run actionlint on it

🏗️ Code Sample / Log

No response

🌌 Environment (actionlint action)

v1.0.2

🌌 Environment (actionlint)

1.6.26

🌌 Environment (GitHub Runner OS)

Linux

📷 Screenshots

No response

📈 Expected behavior

There should be a way to pass multiple ignore patterns to the action, e.g. with a dedicated "input" input.

📎 Additional context

No response

📜 Code of Conduct

  • I agree to follow this project's Code of Conduct.

🐛 [bug]: using v1 gives node16 deprecation warnings

🐛 What happened?

We start seeing deprecation warnings aboud node16 when using raven-actions/actionlint@v1:

Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/cache@v3. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.

🔬 How to reproduce?

Call actionlint action

🏗️ Code Sample / Log

[...]
  actionlint:
    needs: ['init', 'begin_report_phase']
    if: ${{ always() && needs.init.outputs.actionlint_skip != 'true' }}
    runs-on: ${{ fromJSON(inputs.runs_on) }}
    steps:
      - name: Install npm on private runner
        if: ${{ inputs.runs_on != '"ubuntu-latest"'}}
        run: |
          NPM=$(type -p 'npm'||true)
          if [ -z "${NPM}" ]; then
            echo -e "\033[0;35m###  Installing npm ###\033[0m"
            sudo DEBIAN_FRONTEND=noninteractive apt-get -qq update
            sudo apt-get -qq install npm
          fi

      - name: Checkout
        id: checkout
        uses: actions/checkout@v4

      - name: Run actionlint
        id: actionlint
        uses: raven-actions/actionlint@v1

🌌 Environment (actionlint action)

1.0.3

🌌 Environment (actionlint)

1.6.26-Linux-X64

🌌 Environment (GitHub Runner OS)

Linux

📷 Screenshots

No response

📈 Expected behavior

actions/cache is upgraded to v4 to remove the warning

📎 Additional context

No response

📜 Code of Conduct

  • I agree to follow this project's Code of Conduct.

🐛 [bug]: Unable to set URL of actionlint

🐛 What happened?

Environmnet:

  • Github Enterprise Server
  • actions-sync to sync actions to a local org in our github enterprise

The action is trying to look for the latest version of rhysd/actionlint on our local GHES instance. Of course it is not there. I don't see a way to set the url to point at https://github.com/ instead.

🔬 How to reproduce?

See code sample/log

🏗️ Code Sample / Log

Workflow:

  actionlint:
    name: 'ActionLint'
    runs-on: [self-hosted]
      steps:
        - uses: actions/checkout@v3
        - uses: axon-actions/actionlint@v1

Output:

RequestError [HttpError]: Not Found
    at /runner/_work/_actions/actions/github-script/v6/dist/index.js:6842:21
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async getToolReleaseLatest (eval at callAsyncFunction (/runner/_work/_actions/actions/github-script/v6/dist/index.js:15143:16), <anonymous>:58:20)
    at async eval (eval at callAsyncFunction (/runner/_work/_actions/actions/github-script/v6/dist/index.js:15143:16), <anonymous>:77:7)
    at async main (/runner/_work/_actions/actions/github-script/v6/dist/index.js:15236:20) {
  status: 404,
  response: {
    url: 'https://<redacted url for GHES>/api/v3/repos/rhysd/actionlint/releases/latest',
    status: 404,
    headers: {
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
      connection: 'close',
      'content-encoding': 'gzip',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Wed, 01 Nov 2023 16:51:34 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'GitHub.com',
      'strict-transport-security': 'max-age=31536000; includeSubdomains',
      'transfer-encoding': 'chunked',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-enterprise-version': '3.8.10',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': '3cb06c66-301c-488c-9774-5f7382604551',
      'x-runtime-rack': '0.024953',
      'x-xss-protection': '0'
    },
    data: {
      message: 'Not Found',
      documentation_url: 'https://docs.github.com/[email protected]/rest/reference/repos#get-the-latest-release'
    }
  },
  request: {
    method: 'GET',
    url: 'https://<redacted url for GHES>/api/v3/repos/rhysd/actionlint/releases/latest',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'actions/github-script octokit-core.js/3.6.0 Node.js/16.20.1 (linux; x64)',
      authorization: 'token [REDACTED]'
    },
    request: { agent: [Agent], hook: [Function: bound bound register] }
  }
}
Error: Unhandled error: HttpError: Not Found

🌌 Environment (actionlint action)

1.0.2

🌌 Environment (actionlint)

1.6.26

🌌 Environment (GitHub Runner OS)

Linux

📷 Screenshots

No response

📈 Expected behavior

It would by default pull from github.com, and allow you to set the URL of your github instance in case you do want to use a local version of rhysd/actionlint

📎 Additional context

No response

📜 Code of Conduct

  • I agree to follow this project's Code of Conduct.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.