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

Detect available flags for extensions #2557

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ChristopherHX
Copy link
Contributor

Currently you would need to parse the help text, but using this feature you don't need to reassemble all informations.

@ChristopherHX ChristopherHX requested a review from a team as a code owner December 6, 2024 19:25
Copy link
Contributor

github-actions bot commented Dec 6, 2024

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ EDITORCONFIG editorconfig-checker 3 0 0.02s
✅ REPOSITORY gitleaks yes no 2.42s
✅ REPOSITORY git_diff yes no 0.01s
✅ REPOSITORY grype yes no 9.18s
✅ REPOSITORY secretlint yes no 1.18s
✅ REPOSITORY trivy-sbom yes no 0.11s
✅ REPOSITORY trufflehog yes no 4.61s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@ChristopherHX
Copy link
Contributor Author

FYI @SanjulaGanepola this lands in the next Runner.Client release in parallel where it is available earlier.

I look into integrating this into your VSCode extension, try to run this flag and if it works stop using hardcoded options database.

E.g. if an option is unsupported highlight and disable it.

This can be later added to my own extension stay tuned.

@ChristopherHX
Copy link
Contributor Author

this is the output of this flag

/workspaces/act (draft-dump-as-json) $ ./act --list-options
[{"name":"action-cache-path","default":"/home/codespace/.cache/act","type":"string","description":"Defines the path where the actions get cached and host workspaces created."},{"name":"action-offline-mode","default":"false","type":"bool","description":"If action contents exists, it will not be fetch and pull again. If turn on this,will turn off force pull"},{"name":"actor","default":"nektos/act","type":"string","description":"user that triggered the event"},{"name":"artifact-server-addr","default":"10.0.2.117","type":"string","description":"Defines the address to which the artifact server binds."},{"name":"artifact-server-path","default":"","type":"string","description":"Defines the path where the artifact server stores uploads and retrieves downloads from. If not specified the artifact server will not start."},{"name":"artifact-server-port","default":"34567","type":"string","description":"Defines the port where the artifact server listens."},{"name":"bind","default":"false","type":"bool","description":"bind working directory to container, rather than copy"},{"name":"bug-report","default":"false","type":"bool","description":"Display system information for bug report"},{"name":"cache-server-addr","default":"10.0.2.117","type":"string","description":"Defines the address to which the cache server binds."},{"name":"cache-server-path","default":"/home/codespace/.cache/actcache","type":"string","description":"Defines the path where the cache server stores caches."},{"name":"cache-server-port","default":"0","type":"uint16","description":"Defines the port where the artifact server listens. 0 means a randomly available port."},{"name":"container-architecture","default":"","type":"string","description":"Architecture which should be used to run containers, e.g.: linux/amd64. If not specified, will use host default architecture. Requires Docker server API Version 1.41+. Ignored on earlier Docker server platforms."},{"name":"container-cap-add","default":"[]","type":"stringArray","description":"kernel capabilities to add to the workflow containers (e.g. --container-cap-add SYS_PTRACE)"},{"name":"container-cap-drop","default":"[]","type":"stringArray","description":"kernel capabilities to remove from the workflow containers (e.g. --container-cap-drop SYS_PTRACE)"},{"name":"container-daemon-socket","default":"","type":"string","description":"URI to Docker Engine socket (e.g.: unix://~/.docker/run/docker.sock or - to disable bind mounting the socket)"},{"name":"container-options","default":"","type":"string","description":"Custom docker container options for the job container without an options property in the job definition"},{"name":"defaultbranch","default":"","type":"string","description":"the name of the main branch"},{"name":"detect-event","default":"false","type":"bool","description":"Use first event type from workflow as event that triggered the workflow"},{"name":"directory","default":".","type":"string","description":"working directory"},{"name":"dryrun","default":"false","type":"bool","description":"disable container creation, validates only workflow correctness"},{"name":"env","default":"[]","type":"stringArray","description":"env to make available to actions with optional value (e.g. --env myenv=foo or --env myenv)"},{"name":"env-file","default":".env","type":"string","description":"environment file to read and use as env in the containers"},{"name":"eventpath","default":"","type":"string","description":"path to event JSON file"},{"name":"github-instance","default":"github.com","type":"string","description":"GitHub instance to use. Only use this when using GitHub Enterprise Server."},{"name":"graph","default":"false","type":"bool","description":"draw workflows"},{"name":"help","default":"false","type":"bool","description":"help for act"},{"name":"input","default":"[]","type":"stringArray","description":"action input to make available to actions (e.g. --input myinput=foo)"},{"name":"input-file","default":".input","type":"string","description":"input file to read and use as action input"},{"name":"insecure-secrets","default":"false","type":"bool","description":"NOT RECOMMENDED! Doesn't hide secrets while printing logs."},{"name":"job","default":"","type":"string","description":"run a specific job ID"},{"name":"json","default":"false","type":"bool","description":"Output logs in json format"},{"name":"list","default":"false","type":"bool","description":"list workflows"},{"name":"list-options","default":"false","type":"bool","description":"Print a json structure of compatible options"},{"name":"local-repository","default":"[]","type":"stringArray","description":"Replaces the specified repository and ref with a local folder (e.g. https://github.com/test/test@v0=/home/act/test or test/test@v0=/home/act/test, the latter matches any hosts or protocols)"},{"name":"log-prefix-job-id","default":"false","type":"bool","description":"Output the job id within non-json logs instead of the entire name"},{"name":"man-page","default":"false","type":"bool","description":"Print a generated manual page to stdout"},{"name":"matrix","default":"[]","type":"stringArray","description":"specify which matrix configuration to include (e.g. --matrix java:13"},{"name":"network","default":"host","type":"string","description":"Sets a docker network name. Defaults to host."},{"name":"no-cache-server","default":"false","type":"bool","description":"Disable cache server"},{"name":"no-recurse","default":"false","type":"bool","description":"Flag to disable running workflows from subdirectories of specified path in '--workflows'/'-W' flag"},{"name":"no-skip-checkout","default":"false","type":"bool","description":"Do not skip actions/checkout"},{"name":"platform","default":"[]","type":"stringArray","description":"custom image to use per platform (e.g. -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04)"},{"name":"privileged","default":"false","type":"bool","description":"use privileged mode"},{"name":"pull","default":"true","type":"bool","description":"pull docker image(s) even if already present"},{"name":"quiet","default":"false","type":"bool","description":"disable logging of output from steps"},{"name":"rebuild","default":"true","type":"bool","description":"rebuild local action docker image(s) even if already present"},{"name":"remote-name","default":"origin","type":"string","description":"git remote name that will be used to retrieve url of git repo"},{"name":"replace-ghe-action-token-with-github-com","default":"","type":"string","description":"If you are using replace-ghe-action-with-github-com  and you want to use private actions on GitHub, you have to set personal access token"},{"name":"replace-ghe-action-with-github-com","default":"[]","type":"stringArray","description":"If you are using GitHub Enterprise Server and allow specified actions from GitHub (github.com), you can set actions on this. (e.g. --replace-ghe-action-with-github-com =github/super-linter)"},{"name":"reuse","default":"false","type":"bool","description":"don't remove container(s) on successfully completed workflow(s) to maintain state between runs"},{"name":"rm","default":"false","type":"bool","description":"automatically remove container(s)/volume(s) after a workflow(s) failure"},{"name":"secret","default":"[]","type":"stringArray","description":"secret to make available to actions with optional value (e.g. -s mysecret=foo or -s mysecret)"},{"name":"secret-file","default":".secrets","type":"string","description":"file with list of secrets to read from (e.g. --secret-file .secrets)"},{"name":"use-gitignore","default":"true","type":"bool","description":"Controls whether paths specified in .gitignore should be copied into container"},{"name":"use-new-action-cache","default":"false","type":"bool","description":"Enable using the new Action Cache for storing Actions locally"},{"name":"userns","default":"","type":"string","description":"user namespace to use"},{"name":"var","default":"[]","type":"stringArray","description":"variable to make available to actions with optional value (e.g. --var myvar=foo or --var myvar)"},{"name":"var-file","default":".vars","type":"string","description":"file with list of vars to read from (e.g. --var-file .vars)"},{"name":"verbose","default":"false","type":"bool","description":"verbose output"},{"name":"version","default":"false","type":"bool","description":"version for act"},{"name":"watch","default":"false","type":"bool","description":"watch the contents of the local repo and run when files change"},{"name":"workflows","default":"./.github/workflows/","type":"string","description":"path to workflow file(s)"}]

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.

Project coverage is 68.65%. Comparing base (5a80a04) to head (9feaddb).
Report is 137 commits behind head on master.

Files with missing lines Patch % Lines
cmd/root.go 0.00% 13 Missing ⚠️
cmd/notices.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2557      +/-   ##
==========================================
+ Coverage   61.56%   68.65%   +7.08%     
==========================================
  Files          53       71      +18     
  Lines        9002    10935    +1933     
==========================================
+ Hits         5542     7507    +1965     
+ Misses       3020     2865     -155     
- Partials      440      563     +123     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@SanjulaGanepola SanjulaGanepola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an awesome change. In reviewing the JSON output, I noticed that the description for the action-offline-mode does not make sense. Can this description be improved?

@ChristopherHX
Copy link
Contributor Author

Can this description be improved?

For clarity, also adding this here as well

For your mentioned descriptions updates please just file a PR to change these here:

act/cmd/root.go

Lines 47 to 106 in 9c7f103

rootCmd.Flags().BoolP("watch", "w", false, "watch the contents of the local repo and run when files change")
rootCmd.Flags().BoolP("list", "l", false, "list workflows")
rootCmd.Flags().BoolP("graph", "g", false, "draw workflows")
rootCmd.Flags().StringP("job", "j", "", "run a specific job ID")
rootCmd.Flags().BoolP("bug-report", "", false, "Display system information for bug report")
rootCmd.Flags().BoolP("man-page", "", false, "Print a generated manual page to stdout")
rootCmd.Flags().StringVar(&input.remoteName, "remote-name", "origin", "git remote name that will be used to retrieve url of git repo")
rootCmd.Flags().StringArrayVarP(&input.secrets, "secret", "s", []string{}, "secret to make available to actions with optional value (e.g. -s mysecret=foo or -s mysecret)")
rootCmd.Flags().StringArrayVar(&input.vars, "var", []string{}, "variable to make available to actions with optional value (e.g. --var myvar=foo or --var myvar)")
rootCmd.Flags().StringArrayVarP(&input.envs, "env", "", []string{}, "env to make available to actions with optional value (e.g. --env myenv=foo or --env myenv)")
rootCmd.Flags().StringArrayVarP(&input.inputs, "input", "", []string{}, "action input to make available to actions (e.g. --input myinput=foo)")
rootCmd.Flags().StringArrayVarP(&input.platforms, "platform", "P", []string{}, "custom image to use per platform (e.g. -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04)")
rootCmd.Flags().BoolVarP(&input.reuseContainers, "reuse", "r", false, "don't remove container(s) on successfully completed workflow(s) to maintain state between runs")
rootCmd.Flags().BoolVarP(&input.bindWorkdir, "bind", "b", false, "bind working directory to container, rather than copy")
rootCmd.Flags().BoolVarP(&input.forcePull, "pull", "p", true, "pull docker image(s) even if already present")
rootCmd.Flags().BoolVarP(&input.forceRebuild, "rebuild", "", true, "rebuild local action docker image(s) even if already present")
rootCmd.Flags().BoolVarP(&input.autodetectEvent, "detect-event", "", false, "Use first event type from workflow as event that triggered the workflow")
rootCmd.Flags().StringVarP(&input.eventPath, "eventpath", "e", "", "path to event JSON file")
rootCmd.Flags().StringVar(&input.defaultBranch, "defaultbranch", "", "the name of the main branch")
rootCmd.Flags().BoolVar(&input.privileged, "privileged", false, "use privileged mode")
rootCmd.Flags().StringVar(&input.usernsMode, "userns", "", "user namespace to use")
rootCmd.Flags().BoolVar(&input.useGitIgnore, "use-gitignore", true, "Controls whether paths specified in .gitignore should be copied into container")
rootCmd.Flags().StringArrayVarP(&input.containerCapAdd, "container-cap-add", "", []string{}, "kernel capabilities to add to the workflow containers (e.g. --container-cap-add SYS_PTRACE)")
rootCmd.Flags().StringArrayVarP(&input.containerCapDrop, "container-cap-drop", "", []string{}, "kernel capabilities to remove from the workflow containers (e.g. --container-cap-drop SYS_PTRACE)")
rootCmd.Flags().BoolVar(&input.autoRemove, "rm", false, "automatically remove container(s)/volume(s) after a workflow(s) failure")
rootCmd.Flags().StringArrayVarP(&input.replaceGheActionWithGithubCom, "replace-ghe-action-with-github-com", "", []string{}, "If you are using GitHub Enterprise Server and allow specified actions from GitHub (github.com), you can set actions on this. (e.g. --replace-ghe-action-with-github-com =github/super-linter)")
rootCmd.Flags().StringVar(&input.replaceGheActionTokenWithGithubCom, "replace-ghe-action-token-with-github-com", "", "If you are using replace-ghe-action-with-github-com and you want to use private actions on GitHub, you have to set personal access token")
rootCmd.Flags().StringArrayVarP(&input.matrix, "matrix", "", []string{}, "specify which matrix configuration to include (e.g. --matrix java:13")
rootCmd.PersistentFlags().StringVarP(&input.actor, "actor", "a", "nektos/act", "user that triggered the event")
rootCmd.PersistentFlags().StringVarP(&input.workflowsPath, "workflows", "W", "./.github/workflows/", "path to workflow file(s)")
rootCmd.PersistentFlags().BoolVarP(&input.noWorkflowRecurse, "no-recurse", "", false, "Flag to disable running workflows from subdirectories of specified path in '--workflows'/'-W' flag")
rootCmd.PersistentFlags().StringVarP(&input.workdir, "directory", "C", ".", "working directory")
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "verbose output")
rootCmd.PersistentFlags().BoolVar(&input.jsonLogger, "json", false, "Output logs in json format")
rootCmd.PersistentFlags().BoolVar(&input.logPrefixJobID, "log-prefix-job-id", false, "Output the job id within non-json logs instead of the entire name")
rootCmd.PersistentFlags().BoolVarP(&input.noOutput, "quiet", "q", false, "disable logging of output from steps")
rootCmd.PersistentFlags().BoolVarP(&input.dryrun, "dryrun", "n", false, "disable container creation, validates only workflow correctness")
rootCmd.PersistentFlags().StringVarP(&input.secretfile, "secret-file", "", ".secrets", "file with list of secrets to read from (e.g. --secret-file .secrets)")
rootCmd.PersistentFlags().StringVarP(&input.varfile, "var-file", "", ".vars", "file with list of vars to read from (e.g. --var-file .vars)")
rootCmd.PersistentFlags().BoolVarP(&input.insecureSecrets, "insecure-secrets", "", false, "NOT RECOMMENDED! Doesn't hide secrets while printing logs.")
rootCmd.PersistentFlags().StringVarP(&input.envfile, "env-file", "", ".env", "environment file to read and use as env in the containers")
rootCmd.PersistentFlags().StringVarP(&input.inputfile, "input-file", "", ".input", "input file to read and use as action input")
rootCmd.PersistentFlags().StringVarP(&input.containerArchitecture, "container-architecture", "", "", "Architecture which should be used to run containers, e.g.: linux/amd64. If not specified, will use host default architecture. Requires Docker server API Version 1.41+. Ignored on earlier Docker server platforms.")
rootCmd.PersistentFlags().StringVarP(&input.containerDaemonSocket, "container-daemon-socket", "", "", "URI to Docker Engine socket (e.g.: unix://~/.docker/run/docker.sock or - to disable bind mounting the socket)")
rootCmd.PersistentFlags().StringVarP(&input.containerOptions, "container-options", "", "", "Custom docker container options for the job container without an options property in the job definition")
rootCmd.PersistentFlags().StringVarP(&input.githubInstance, "github-instance", "", "github.com", "GitHub instance to use. Only use this when using GitHub Enterprise Server.")
rootCmd.PersistentFlags().StringVarP(&input.artifactServerPath, "artifact-server-path", "", "", "Defines the path where the artifact server stores uploads and retrieves downloads from. If not specified the artifact server will not start.")
rootCmd.PersistentFlags().StringVarP(&input.artifactServerAddr, "artifact-server-addr", "", common.GetOutboundIP().String(), "Defines the address to which the artifact server binds.")
rootCmd.PersistentFlags().StringVarP(&input.artifactServerPort, "artifact-server-port", "", "34567", "Defines the port where the artifact server listens.")
rootCmd.PersistentFlags().BoolVarP(&input.noSkipCheckout, "no-skip-checkout", "", false, "Do not skip actions/checkout")
rootCmd.PersistentFlags().BoolVarP(&input.noCacheServer, "no-cache-server", "", false, "Disable cache server")
rootCmd.PersistentFlags().StringVarP(&input.cacheServerPath, "cache-server-path", "", filepath.Join(CacheHomeDir, "actcache"), "Defines the path where the cache server stores caches.")
rootCmd.PersistentFlags().StringVarP(&input.cacheServerAddr, "cache-server-addr", "", common.GetOutboundIP().String(), "Defines the address to which the cache server binds.")
rootCmd.PersistentFlags().Uint16VarP(&input.cacheServerPort, "cache-server-port", "", 0, "Defines the port where the artifact server listens. 0 means a randomly available port.")
rootCmd.PersistentFlags().StringVarP(&input.actionCachePath, "action-cache-path", "", filepath.Join(CacheHomeDir, "act"), "Defines the path where the actions get cached and host workspaces created.")
rootCmd.PersistentFlags().BoolVarP(&input.actionOfflineMode, "action-offline-mode", "", false, "If action contents exists, it will not be fetch and pull again. If turn on this,will turn off force pull")
rootCmd.PersistentFlags().StringVarP(&input.networkName, "network", "", "host", "Sets a docker network name. Defaults to host.")
rootCmd.PersistentFlags().BoolVarP(&input.useNewActionCache, "use-new-action-cache", "", false, "Enable using the new Action Cache for storing Actions locally")
rootCmd.PersistentFlags().StringArrayVarP(&input.localRepository, "local-repository", "", []string{}, "Replaces the specified repository and ref with a local folder (e.g. https://github.com/test/test@v0=/home/act/test or test/test@v0=/home/act/test, the latter matches any hosts or protocols)")

Flag used in SanjulaGanepola/github-local-actions#117

Copy link
Contributor

mergify bot commented Dec 24, 2024

This pull request has been removed from the queue for the following reason: checks failed.

The merge conditions cannot be satisfied due to failing checks:

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.

If you want to requeue this pull request, you need to post a comment with the text: @mergifyio requeue

Copy link
Contributor

mergify bot commented Dec 24, 2024

@ChristopherHX this pull request has failed checks 🛠

@mergify mergify bot added the needs-work Extra attention is needed label Dec 24, 2024
@pull-request-size pull-request-size bot added size/S and removed size/M labels Dec 24, 2024
Copy link
Contributor

mergify bot commented Dec 24, 2024

@ChristopherHX this pull request has failed checks 🛠

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-work Extra attention is needed size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants