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

feat: generate manual page automatically with cobra/doc #2352

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

ittner
Copy link
Contributor

@ittner ittner commented Jun 5, 2024

Add a command line switch "--man-page" to print an automatically generated manual page to stdout.

@ittner ittner requested a review from a team as a code owner June 5, 2024 14:18
Copy link
Contributor

mergify bot commented Jun 5, 2024

@ittner this pull request has failed checks 🛠

@mergify mergify bot added the needs-work Extra attention is needed label Jun 5, 2024
@ChristopherHX
Copy link
Contributor

It would be nice to see the example output in the pr description.

I will rerun the CI later, to get the coverage result. Tests are passing, except for coverage which we see later.

The cmd package usually has coverage problems due to missing tests in the area, if the coverage is red only cplee (owner) can ignore the failure

Copy link

codecov bot commented Jun 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.64%. Comparing base (5a80a04) to head (0802e7e).
Report is 109 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2352       +/-   ##
===========================================
+ Coverage   61.56%   76.64%   +15.07%     
===========================================
  Files          53       62        +9     
  Lines        9002     8177      -825     
===========================================
+ Hits         5542     6267      +725     
+ Misses       3020     1345     -1675     
- Partials      440      565      +125     

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

@mergify mergify bot removed the needs-work Extra attention is needed label Jun 6, 2024
@ChristopherHX
Copy link
Contributor

Hmm, transcript from the man cli.

I could not figure out how to display the man page using your cli flag without seeing man page source code or storing it inside a file

act(1)                                                                                                                                                               act(1)

NAME
       act - Run GitHub actions locally by specifying the event name (e.g. push) or an action name directly.

SYNOPSIS
       **act [event name to run] [flags]

       If no event name passed, will default to "on: push" If actions handles only one event it will be used as default instead of "on: push"**

DESCRIPTION
       Run GitHub actions locally by specifying the event name (e.g. push) or an action name directly.

OPTIONS
       --action-cache-path="/home/codespace/.cache/act"      Defines the path where the actions get cached and host workspaces created.

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

       -a, --actor="nektos/act"      user that triggered the event

       --artifact-server-addr="172.16.5.4"      Defines the address to which the artifact server binds.

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

       --artifact-server-port="34567"      Defines the port where the artifact server listens.

       -b, --bind[=false]      bind working directory to container, rather than copy

       --bug-report[=false]      Display system information for bug report

       --cache-server-addr="172.16.5.4"      Defines the address to which the cache server binds.

       --cache-server-path="/home/codespace/.cache/actcache"      Defines the path where the cache server stores caches.

       --cache-server-port=0      Defines the port where the artifact server listens. 0 means a randomly available port.

       --container-architecture=""      Architecture which should be used to run containers, e.g.: linux/amd64. If not specified, will use host default  architecture.  Re‐
       quires Docker server API Version 1.41+. Ignored on earlier Docker server platforms.

       --container-cap-add=[]      kernel capabilities to add to the workflow containers (e.g. --container-cap-add SYS_PTRACE)

       --container-cap-drop=[]      kernel capabilities to remove from the workflow containers (e.g. --container-cap-drop SYS_PTRACE)

       --container-daemon-socket=""      URI to Docker Engine socket (e.g.: unix://~/.docker/run/docker.sock or - to disable bind mounting the socket)

       --container-options=""      Custom docker container options for the job container without an options property in the job definition

       --defaultbranch=""      the name of the main branch

       --detect-event[=false]      Use first event type from workflow as event that triggered the workflow

       -C, --directory="."       working directory

       -n, --dryrun[=false]      disable container creation, validates only workflow correctness

       --env=[]      env to make available to actions with optional value (e.g. --env myenv=foo or --env myenv)

       --env-file=".env"      environment file to read and use as env in the containers

       -e, --eventpath=""      path to event JSON file

       --github-instance="github.com"      GitHub instance to use. Don't use this if you are not using GitHub Enterprise Server.

       -g, --graph[=false]      draw workflows

       -h, --help[=false]      help for act

       --input=[]      action input to make available to actions (e.g. --input myinput=foo)

       --input-file=".input"      input file to read and use as action input

       --insecure-secrets[=false]      NOT RECOMMENDED! Doesn't hide secrets while printing logs.

       -j, --job=""      run a specific job ID

       --json[=false]      Output logs in json format

       -l, --list[=false]      list workflows

       --local-repository=[]        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)

       --log-prefix-job-id[=false]      Output the job id within non-json logs instead of the entire name

       --man-page[=false]      Print a generated manual page to stdout

       --matrix=[]      specify which matrix configuration to include (e.g. --matrix java:13

       --network="host"      Sets a docker network name. Defaults to host.

       --no-cache-server[=false]      Disable cache server

       --no-recurse[=false]      Flag to disable running workflows from subdirectories of specified path in '--workflows'/'-W' flag

       --no-skip-checkout[=false]      Do not skip actions/checkout

       -P, --platform=[]      custom image to use per platform (e.g. -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04)

       --privileged[=false]      use privileged mode

       -p, --pull[=true]      pull docker image(s) even if already present

       -q, --quiet[=false]      disable logging of output from steps

       --rebuild[=true]      rebuild local action docker image(s) even if already present

       --remote-name="origin"      git remote name that will be used to retrieve url of git repo

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

       --replace-ghe-action-with-github-com=[]       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)

       -r, --reuse[=false]      don't remove container(s) on successfully completed workflow(s) to maintain state between runs

       --rm[=false]      automatically remove container(s)/volume(s) after a workflow(s) failure

       -s, --secret=[]      secret to make available to actions with optional value (e.g. -s mysecret=foo or -s mysecret)

       --secret-file=".secrets"      file with list of secrets to read from (e.g. --secret-file .secrets)

       --use-gitignore[=true]      Controls whether paths specified in .gitignore should be copied into container

       --use-new-action-cache[=false]      Enable using the new Action Cache for storing Actions locally

       --userns=""      user namespace to use

       --var=[]      variable to make available to actions with optional value (e.g. --var myvar=foo or --var myvar)

       --var-file=".vars"      file with list of vars to read from (e.g. --var-file .vars)

       -v, --verbose[=false]      verbose output

       --version[=false]      version for act

       -w, --watch[=false]      watch the contents of the local repo and run when files change

       -W, --workflows="./.github/workflows/"      path to workflow file(s)

HISTORY
       6-Jun-2024 Auto generated by spf13/cobra

act 0.2.63                                                                        Jun 2024                                                                           act(1)

...I'm still undecided about this feature

@ittner
Copy link
Contributor Author

ittner commented Jun 13, 2024

...I'm still undecided about this feature

Hi @ChristopherHX !

A bit of rationale for this feature: I'm looking into packaging act for Debian and Ubuntu and manpages are required by both distro policies. I can imagine other distros having similar requirements.

Of course, manpages can be written manually (at the risk of leaving them outdated as the CLI changes) or I can keep a local patch use it to generate the pages when needed, but this code seems more useful if it is shared among potential users. Hugo and others uses a similar approach for generating man-pages, for example.

I though about having it optionally write the output to a file but I fear this can introduce more complexity that needed for potential users, as they will need to remember or look into another options instead of just redirecting with the shell... but perhaps my fear is undeserved and the output to a file is welcome.

Copy link
Contributor

mergify bot commented Jun 17, 2024

@ittner this pull request is now in conflict 😩

@mergify mergify bot added the conflict PR has conflicts label Jun 17, 2024
Add a command line switch "--man-page" to print an automatically
generated manual page to stdout.
@mergify mergify bot removed the conflict PR has conflicts label Jun 17, 2024
@ittner
Copy link
Contributor Author

ittner commented Jun 17, 2024

Branch rebased to fix new conflict on go.sum/mod.

Copy link
Contributor

@ChristopherHX ChristopherHX left a comment

Choose a reason for hiding this comment

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

Thank your for outlining you intention here, we could technically hide the flag from help as this is more a packaging extension than a feature for people using act

I'm not blocking your plan to make it an official debian/ubuntu package, but be aware I already had the situation that tools like podman/buildah lacked bug fixes for thing fixed over 6 months ago

So a ppa is actually more important for people like me, I have scripts to host it with GitHub Pages

The auto merge of dependable bot updates is unfortunate for any PR that changes dependencies, especially if they would be open for an extended amount of time

@@ -81,6 +82,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/russross/blackfriday

Note for reviewer: New dependency, last updated 4 years ago

@mergify mergify bot merged commit 013c0d4 into nektos:master Sep 11, 2024
12 checks passed
sebastien-perpignane pushed a commit to sebastien-perpignane/act that referenced this pull request Sep 15, 2024
Add a command line switch "--man-page" to print an automatically
generated manual page to stdout.

Co-authored-by: ChristopherHX <christopher.homberger@web.de>
sebastien-perpignane pushed a commit to sebastien-perpignane/act that referenced this pull request Sep 15, 2024
Add a command line switch "--man-page" to print an automatically
generated manual page to stdout.

Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants