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

Support 'go install ./...' ? #297

Closed
adamchainz opened this issue Apr 28, 2023 · 6 comments
Closed

Support 'go install ./...' ? #297

adamchainz opened this issue Apr 28, 2023 · 6 comments

Comments

@adamchainz
Copy link

The current .pre-commit-hooks.yaml file allows running actionlint through pre-commit's system and docker languages. These are both ways of skipping pre-commit's packaging system.

pre-commit has a golang language, and in recent version 3.0.0 it gained the ability to bootstrap golang. This allows users to compile and run native golang tools without any setup other than pre-commit. It would be neat if actionlint supported this style of running, since it would avoid teams needing to all install actionlint themselves, or Docker.

I just tried using actionlint under pre-commit with golang, just this change:

--- .pre-commit-hooks.yaml
+++ .pre-commit-hooks.yaml
@@ -2,7 +2,7 @@
 - id: actionlint
   name: Lint GitHub Actions workflow files
   description: Runs actionlint to lint GitHub Actions workflow files
-  language: system
+  language: golang
   types: ["yaml"]
   files: "^.github/workflows/"
   entry: actionlint

It fails though, with:

An unexpected error has occurred: CalledProcessError: command: ('/opt/homebrew/bin/go', 'install', './...')
return code: 1
stdout: (none)
stderr:
    go: downloading github.com/yuin/goldmark v1.5.4
    go: downloading gopkg.in/yaml.v3 v3.0.1
    go: downloading github.com/fatih/color v1.15.0
    go: downloading github.com/mattn/go-colorable v0.1.13
    go: downloading github.com/mattn/go-runewidth v0.0.14
    go: downloading github.com/robfig/cron v1.2.0
    go: downloading golang.org/x/sync v0.1.0
    go: downloading golang.org/x/sys v0.6.0
    go: downloading github.com/mattn/go-isatty v0.0.18
    go: downloading github.com/rivo/uniseg v0.4.4
    package github.com/rhysd/actionlint/playground
    	imports syscall/js: build constraints exclude all Go files in /opt/homebrew/Cellar/go/1.20.3/libexec/src/syscall/js

pre-commit runs go install ./..., but this fails in the actinolint repo. I'm afraid I don't know anything about Go, so that's where I stop. I imagine the repository may need a little rearrangement, or a rule added to not install the playground by default... Anyway I would just like to see this happen to make it a little bit easier to run actionlint.

@Freed-Wu
Copy link
Contributor

Freed-Wu commented May 24, 2023

It works for me.

# ...
  - repo: https://github.com/Freed-Wu/actionlint
    rev: v1.6.25
    hooks:
      - id: actionlint
$ pre-commit run -a
[INFO] Initializing environment for https://github.com/Freed-Wu/actionlint.
...
Lint GitHub Actions workflow files............................................Passed
...

Environments:

$ go version
go version go1.20.4 linux/amd64
$ uname -r
6.3.2-arch1-1

@dokempf
Copy link

dokempf commented May 25, 2023

@Freed-Wu Please, I already told you in #301: The v1.6.25 tag of your fork does not include your change to golang. You are not testing what you think you do.

@Freed-Wu
Copy link
Contributor

#297 (comment) This comment is written before #301 (comment), at that time, I haven't known this bug. Now it should be fixed.

@rhysd
Copy link
Owner

rhysd commented Jun 10, 2023

pre-commit runs go install ./..., but this fails in the actinolint repo.

It looks a problem of pre-commit. The package path ./... should be configurable in pre-commit side. Changing main package path means largely changing package structure of this repository. It affects all packages which is using actionlint as Go library. It should not be changed only for avoiding the problem of pre-commit.

@rhysd rhysd closed this as completed Jun 10, 2023
@rhysd rhysd reopened this Jun 10, 2023
@rhysd
Copy link
Owner

rhysd commented Jun 10, 2023

I may be able to add some build tag to excluding the Wasm package.

@rhysd rhysd closed this as completed in c9ea498 Jun 10, 2023
@rhysd
Copy link
Owner

rhysd commented Jun 10, 2023

I added //go:build wasm tag to the module under playground directory. Now go install ./... should work.

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

No branches or pull requests

4 participants