Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I support verification on the server #1279

Closed
laterdayi opened this issue Mar 30, 2023 · 7 comments · Fixed by #1303
Closed

How do I support verification on the server #1279

laterdayi opened this issue Mar 30, 2023 · 7 comments · Fixed by #1303

Comments

@laterdayi
Copy link

How do I support verification on the server

@iiroj
Copy link
Member

iiroj commented Mar 30, 2023

Hello, what do you mean by this?

Lint-staged is designed to be used for running tasks on staged files, which typically means it's used as a commit linter. This doesn't really apply on server environment, and I guess you could just run linters on all files instead.

However, we did recently add the --diff=main...my-ref option which can be used to run against files that have changed between main and my-ref (for example).

Does this answer your question?

@laterdayi
Copy link
Author

@iiroj Performing lint on all files on the server will cause unnecessary operations. I hope to only verify whether the currently submitted files are correct on the server

@iiroj
Copy link
Member

iiroj commented Mar 30, 2023

For this case the --diff command should work for you. 👍

@iiroj
Copy link
Member

iiroj commented Mar 30, 2023

You can find a GitHub Actions example in this other issue: #1198

@laterdayi
Copy link
Author

@iiroj I would like to ask if it is supported to be used in jenkins pipeline + pre commit

@amusingaxl
Copy link

I'm trying to use this Github Action:

name: lint

on:
  pull_request:
    branches:
      - master

jobs:
  linters:
    strategy:
      fail-fast: true

    name: Linters
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: ${{ env.NODE_VERSION }}
          cache: 'yarn'

      - name: Install packages
        run: |
          yarn install --pure-lockfile

      - name: Run lint-staged
        run: yarn lint-staged --diff="origin/${GITHUB_BASE_REF}...origin/${GITHUB_HEAD_REF}"

However, I'm getting an error like this:

Run yarn lint-staged --diff="origin/${GITHUB_BASE_REF}...origin/${GITHUB_HEAD_REF}"
yarn run v1.22.19
$ /home/runner/work/endgame-toolkit/endgame-toolkit/node_modules/.bin/lint-staged --diff=origin/master...origin/feat/sdao-token
[STARTED] Preparing lint-staged...
[STARTED] Running tasks for staged files...
[SKIPPED] Running tasks for staged files...
[STARTED] Applying modifications from tasks...
[SKIPPED] 
[SKIPPED]   ✖ lint-staged failed due to a git error.
[STARTED] Cleaning up temporary files...
[SKIPPED] 
[SKIPPED]   ✖ lint-staged failed due to a git error.

  ✖ lint-staged failed due to a git error.
  Any lost modifications can be restored from a git stash:

    > git stash list
    stash@{0}: automatic lint-staged backup
    > git stash apply --index stash@{0}

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.

Any ideas why?

@elias-pap
Copy link
Contributor

@amusingaxl as a workaround, you can try passing --no-stash explicitly until #1303 is merged. Like here: https://github.com/elias-pap/youtube-share-clip/blob/main/.github/workflows/ci.yml#L25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants