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

Respect the default working-directory of a job #369

Closed
loshz opened this issue Nov 17, 2021 · 3 comments
Closed

Respect the default working-directory of a job #369

loshz opened this issue Nov 17, 2021 · 3 comments
Labels

Comments

@loshz
Copy link

loshz commented Nov 17, 2021

When setting the default working-directory of a job, golangci-lint-action does not respect this parameter.

For example, I have the following project structure:

├── .github
│   └── workflows
│       └── ci.yml
├── some_dir
│   ├── .golangci.yml
│   ├── go.mod
│   ├── main.go
│   └── README.md
└── README.md

And a configured GitHub actions job:

jobs:
  lint:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: some_dir
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-go@v2
        with:
          go-version: 1.17
      - uses: golangci/golangci-lint-action@v2
        with:
          version: v1.43

To which I receive the following error:

Running [/home/runner/golangci-lint-1.43.0-linux-amd64/golangci-lint run --out-format=github-actions] in [] ...
level=error msg="Running error: context loading failed: no go files to analyze"

This is because golangci-lint run is still being ran from the root directory. If I pass the working-directory arg to the GH action, it works as expected:

- uses: golangci/golangci-lint-action@v2
  with:
    version: v1.43
    working-directory: some_dir

As I can see the --path-prefix flag being passed:

 Running [/home/runner/golangci-lint-1.43.0-linux-amd64/golangci-lint run --out-format=github-actions --path-prefix=some_dir] in [/home/runner/work/some_proj/some_dir] ...
  golangci-lint found no issues
  Ran golangci-lint in 3177ms
@SVilgelm
Copy link
Member

PR is always welcome

@epicstar

This comment was marked as off-topic.

switchupcb added a commit to switchupcb/disgo that referenced this issue Jul 5, 2023
* update linter commands

* lint examples

* fix generator linter

* fix linter examples and generator working directory

golangci/golangci-lint-action#369
@ldez ldez added enhancement New feature or request declined and removed enhancement New feature or request labels May 4, 2024
@ldez
Copy link
Member

ldez commented May 4, 2024

The run.working-directory is only for steps with run.
The step with uses doesn't support it.

There is no way to get this information (it's neither inside the GitHub context nor inside the env vars)

So the only solution is to use with.working-directory.

@ldez ldez closed this as completed May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants