Code Monkey home page Code Monkey logo

stylua-action's Introduction

StyLua GitHub Action stylua-action status

GitHub Action to run StyLua, a Lua code formatter.

Installs the StyLua binary (from GitHub releases), and caches it. Any StyLua command can then be run.

NOTE: We recommend using a toolchain manager such as aftman to manage StyLua, as it allows you to define the version used throughout your project - both on the command line, and in GitHub actions.

Usage

- uses: actions/checkout@v4
- uses: JohnnyMorganz/stylua-action@v4
  with:
    token: ${{ secrets.GITHUB_TOKEN }}
    version: latest # NOTE: we recommend pinning to a specific version in case of formatting changes
    # CLI arguments
    args: --check .

Parameters

token (Required)

GitHub token. Required since the binary is downloaded from GitHub releases (to speed download)

args (Required)

The arguments to pass to the StyLua binary

version (Required)

The version of StyLua to use. Follows semver syntax. Alternatively, supply latest to use the latest available release.

NOTE: using latest may cause the action to fail if StyLua updates and the formatting changes!

Based off https://github.com/Roblox/setup-foreman, licensed under MIT

stylua-action's People

Contributors

dundargoc avatar johnnymorganz avatar rcloran avatar vil02 avatar wancup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar

stylua-action's Issues

Please provide a git tag that points to the latest stable version

It's possible to choose the latest commit by just specifying the main branch, but it'd be nice to have a way to point to the latest stable version. The official github actions does this by manually moving their v1, v2, v3... tags to point to the latest stable versions (example). Another common way to do this is to use the git tag latest if one doesn't want to mess with multiple versions.

Somewhat related: the @v1 in the README example doesn't work because there is no git tag "v1".

Semver version specifiers not working as expected

I was hoping to be able to write something like "version: ^0.17.1" in my workflow config to get behaviour slightly tighter than specifying "latest", but without having to update that config as often. Unfortunately that doesn't work. It looks like the reason is because the input is passed through semver.clean(), which cleans a version number, not a range specifier.

> semver.clean(" 0.17")
null
> semver.clean(" 0.17.1")
'0.17.1'
> semver.clean("=0.17")
null
> semver.clean("=0.17.1")
'0.17.1'
> semver.clean(" ~0.17")
null

From my experimentation it looks like semver.satisfies() is pretty tolerant of input variations (at least as tolerant as .clean()), so I don't think any cleaning is necessary.

The documentation (README.md) says it follows semver syntax, which is what prompted me to think I could use a range specifier. If it's not your intent to allow version ranges, it'd be neat to have the README updated. I'd be happy to take a stab at the change if you want, but I'm not a TypeScript or JavaScript person so this is all pretty new to me.

Also it looks like the changes from 7b40065 didn't make it into the built code in dist/, so the behaviour is still as before that change (which made searching for the error message in the source pretty confusing :))

[question] how to push commit back after stylua workflow

i use simple congfig, but I can’t figure out how to return the formatted code to Github

name: Stylua check

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the "master" branch
  push:
    branches: [ "rework" ]
  pull_request:
    branches: [ "rework" ]

jobs:
  integration:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v3
    - name: stylua
      uses: JohnnyMorganz/stylua-action@v3
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        version: latest # NOTE: we recommend pinning to a specific version in case of formatting changes
        args: -g '*.lua' -- .

run command give error. code 2

[Request] allow disabling the warning about pinning the version

Currently we get the following warning when using stylua-action:

No version provided, or version provided is malformed, using latest release version. We recommend pinning the version explicitly to handle changes in formatting.

I assumed that this warning would go away when we explicitly pinned the version to latest, but that didn't seem to work. Is this intended behaviour? If so, is there another way to disable the warning? We have considered the warning and have come to the conclusion that using the latest version is a risk we're willing to take, even if pinning the version is safer.

Doesn't commit

this is my workflow.yml

on:
  push:
    branches:
    - main

jobs:
  stylua:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - uses: JohnnyMorganz/[email protected]
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        args: --verify -g '*.lua' -g '*.iy' -- .

    - uses: EndBug/add-and-commit@v9
      with:
        add: "."
        committer_name: GitHub Actions
        committer_email: [email protected]

it works if i run the command stylua --verify -g '*.lua' -g '*.iy' -- . locally but not in GitHub actions

Can be used to just install stylua?

Hello, thanks for this extension.

I am in a situation where I need to install stylua so my test scripts can run it, but I don't want to run anything outside of it. Is it possible for this action to just install stylua without executing anything and just make stylua bin available?

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.