github.com/pdmccormick/importable-docker-buildx@v0.0.0-20240426161518-e47091289030/.github/CONTRIBUTING.md (about)

     1  # Contribute to the Buildx project
     2  
     3  This page contains information about reporting issues as well as some tips and
     4  guidelines useful to experienced open source contributors.
     5  
     6  ## Reporting security issues
     7  
     8  The project maintainers take security seriously. If you discover a security
     9  issue, please bring it to their attention right away!
    10  
    11  **Please _DO NOT_ file a public issue**, instead send your report privately to
    12  [security@docker.com](mailto:security@docker.com).
    13  
    14  Security reports are greatly appreciated and we will publicly thank you for it.
    15  We also like to send gifts—if you're into schwag, make sure to let
    16  us know. We currently do not offer a paid security bounty program, but are not
    17  ruling it out in the future.
    18  
    19  
    20  ## Reporting other issues
    21  
    22  A great way to contribute to the project is to send a detailed report when you
    23  encounter an issue. We always appreciate a well-written, thorough bug report,
    24  and will thank you for it!
    25  
    26  Check that [our issue database](https://github.com/docker/buildx/issues)
    27  doesn't already include that problem or suggestion before submitting an issue.
    28  If you find a match, you can use the "subscribe" button to get notified on
    29  updates. Do *not* leave random "+1" or "I have this too" comments, as they
    30  only clutter the discussion, and don't help resolving it. However, if you
    31  have ways to reproduce the issue or have additional information that may help
    32  resolving the issue, please leave a comment.
    33  
    34  Include the steps required to reproduce the problem if possible and applicable.
    35  This information will help us review and fix your issue faster. When sending
    36  lengthy log-files, consider posting them as an attachment, instead of posting
    37  inline.
    38  
    39  **Do not forget to remove sensitive data from your logfiles before submitting**
    40   (you can replace those parts with "REDACTED").
    41  
    42  ### Pull requests are always welcome
    43  
    44  Not sure if that typo is worth a pull request? Found a bug and know how to fix
    45  it? Do it! We will appreciate it.
    46  
    47  If your pull request is not accepted on the first try, don't be discouraged! If
    48  there's a problem with the implementation, hopefully you received feedback on
    49  what to improve.
    50  
    51  We're trying very hard to keep Buildx lean and focused. We don't want it to
    52  do everything for everybody. This means that we might decide against
    53  incorporating a new feature. However, there might be a way to implement that
    54  feature *on top of* Buildx.
    55  
    56  ### Design and cleanup proposals
    57  
    58  You can propose new designs for existing features. You can also design
    59  entirely new features. We really appreciate contributors who want to refactor or
    60  otherwise cleanup our project.
    61  
    62  ### Sign your work
    63  
    64  The sign-off is a simple line at the end of the explanation for the patch. Your
    65  signature certifies that you wrote the patch or otherwise have the right to pass
    66  it on as an open-source patch. The rules are pretty simple: if you can certify
    67  the below (from [developercertificate.org](http://developercertificate.org/)):
    68  
    69  ```
    70  Developer Certificate of Origin
    71  Version 1.1
    72  
    73  Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
    74  1 Letterman Drive
    75  Suite D4700
    76  San Francisco, CA, 94129
    77  
    78  Everyone is permitted to copy and distribute verbatim copies of this
    79  license document, but changing it is not allowed.
    80  
    81  Developer's Certificate of Origin 1.1
    82  
    83  By making a contribution to this project, I certify that:
    84  
    85  (a) The contribution was created in whole or in part by me and I
    86      have the right to submit it under the open source license
    87      indicated in the file; or
    88  
    89  (b) The contribution is based upon previous work that, to the best
    90      of my knowledge, is covered under an appropriate open source
    91      license and I have the right under that license to submit that
    92      work with modifications, whether created in whole or in part
    93      by me, under the same open source license (unless I am
    94      permitted to submit under a different license), as indicated
    95      in the file; or
    96  
    97  (c) The contribution was provided directly to me by some other
    98      person who certified (a), (b) or (c) and I have not modified
    99      it.
   100  
   101  (d) I understand and agree that this project and the contribution
   102      are public and that a record of the contribution (including all
   103      personal information I submit with it, including my sign-off) is
   104      maintained indefinitely and may be redistributed consistent with
   105      this project or the open source license(s) involved.
   106  ```
   107  
   108  Then you just add a line to every git commit message:
   109  
   110      Signed-off-by: Joe Smith <joe.smith@email.com>
   111  
   112  **Use your real name** (sorry, no pseudonyms or anonymous contributions.)
   113  
   114  If you set your `user.name` and `user.email` git configs, you can sign your
   115  commit automatically with `git commit -s`.
   116  
   117  ### Run the unit- and integration-tests
   118  
   119  Running tests:
   120  
   121  ```bash
   122  make test
   123  ```
   124  
   125  This runs all unit and integration tests, in a containerized environment.
   126  Locally, every package can be tested separately with standard Go tools, but
   127  integration tests are skipped if local user doesn't have enough permissions or
   128  worker binaries are not installed.
   129  
   130  ```bash
   131  # run unit tests only
   132  make test-unit
   133  
   134  # run integration tests only
   135  make test-integration
   136  
   137  # test a specific package
   138  TESTPKGS=./bake make test
   139  
   140  # run all integration tests with a specific worker
   141  TESTFLAGS="--run=//worker=remote -v" make test-integration
   142  
   143  # run a specific integration test
   144  TESTFLAGS="--run /TestBuild/worker=remote/ -v" make test-integration
   145  
   146  # run a selection of integration tests using a regexp
   147  TESTFLAGS="--run /TestBuild.*/worker=remote/ -v" make test-integration
   148  ```
   149  
   150  > **Note**
   151  >
   152  > Set `TEST_KEEP_CACHE=1` for the test framework to keep external dependant
   153  > images in a docker volume if you are repeatedly calling `make test`. This
   154  > helps to avoid rate limiting on the remote registry side.
   155  
   156  > **Note**
   157  >
   158  > Set `TEST_DOCKERD=1` for the test framework to enable the docker workers,
   159  > specifically the `docker` and `docker-container` drivers.
   160  >
   161  > The docker tests cannot be run in parallel, so require passing `--parallel=1`
   162  > in `TESTFLAGS`.
   163  
   164  > **Note**
   165  >
   166  > If you are working behind a proxy, you can set some of or all
   167  > `HTTP_PROXY=http://ip:port`, `HTTPS_PROXY=http://ip:port`, `NO_PROXY=http://ip:port`
   168  > for the test framework to specify the proxy build args.
   169  
   170  
   171  ### Run the helper commands
   172  
   173  To enter a demo container environment and experiment, you may run:
   174  
   175  ```
   176  $ make shell
   177  ```
   178  
   179  To validate PRs before submitting them you should run:
   180  
   181  ```
   182  $ make validate-all
   183  ```
   184  
   185  To generate new vendored files with go modules run:
   186  
   187  ```
   188  $ make vendor
   189  ```
   190  
   191  
   192  ### Conventions
   193  
   194  - Fork the repository and make changes on your fork in a feature branch
   195  - Submit tests for your changes. See [run the unit- and integration-tests](#run-the-unit--and-integration-tests)
   196    for details.
   197  - [Sign your work](#sign-your-work)
   198  
   199  Write clean code. Universally formatted code promotes ease of writing, reading,
   200  and maintenance. Always run `gofmt -s -w file.go` on each changed file before
   201  committing your changes. Most editors have plug-ins that do this automatically.
   202  
   203  Pull request descriptions should be as clear as possible and include a
   204  reference to all the issues that they address. Be sure that the [commit
   205  messages](#commit-messages) also contain the relevant information.
   206  
   207  ### Successful Changes
   208  
   209  Before contributing large or high impact changes, make the effort to coordinate
   210  with the maintainers of the project before submitting a pull request. This
   211  prevents you from doing extra work that may or may not be merged.
   212  
   213  Large PRs that are just submitted without any prior communication are unlikely
   214  to be successful.
   215  
   216  While pull requests are the methodology for submitting changes to code, changes
   217  are much more likely to be accepted if they are accompanied by additional
   218  engineering work. While we don't define this explicitly, most of these goals
   219  are accomplished through communication of the design goals and subsequent
   220  solutions. Often times, it helps to first state the problem before presenting
   221  solutions.
   222  
   223  Typically, the best methods of accomplishing this are to submit an issue,
   224  stating the problem. This issue can include a problem statement and a
   225  checklist with requirements. If solutions are proposed, alternatives should be
   226  listed and eliminated. Even if the criteria for elimination of a solution is
   227  frivolous, say so.
   228  
   229  Larger changes typically work best with design documents. These are focused on
   230  providing context to the design at the time the feature was conceived and can
   231  inform future documentation contributions.
   232  
   233  ### Commit Messages
   234  
   235  Commit messages must start with a capitalized and short summary (max. 50 chars)
   236  written in the imperative, followed by an optional, more detailed explanatory
   237  text which is separated from the summary by an empty line.
   238  
   239  Commit messages should follow best practices, including explaining the context
   240  of the problem and how it was solved, including in caveats or follow up changes
   241  required. They should tell the story of the change and provide readers
   242  understanding of what led to it.
   243  
   244  If you're lost about what this even means, please see [How to Write a Git
   245  Commit Message](http://chris.beams.io/posts/git-commit/) for a start.
   246  
   247  In practice, the best approach to maintaining a nice commit message is to
   248  leverage a `git add -p` and `git commit --amend` to formulate a solid
   249  changeset. This allows one to piece together a change, as information becomes
   250  available.
   251  
   252  If you squash a series of commits, don't just submit that. Re-write the commit
   253  message, as if the series of commits was a single stroke of brilliance.
   254  
   255  That said, there is no requirement to have a single commit for a PR, as long as
   256  each commit tells the story. For example, if there is a feature that requires a
   257  package, it might make sense to have the package in a separate commit then have
   258  a subsequent commit that uses it.
   259  
   260  Remember, you're telling part of the story with the commit message. Don't make
   261  your chapter weird.
   262  
   263  ### Review
   264  
   265  Code review comments may be added to your pull request. Discuss, then make the
   266  suggested modifications and push additional commits to your feature branch. Post
   267  a comment after pushing. New commits show up in the pull request automatically,
   268  but the reviewers are notified only when you comment.
   269  
   270  Pull requests must be cleanly rebased on top of master without multiple branches
   271  mixed into the PR.
   272  
   273  > **Git tip**: If your PR no longer merges cleanly, use `rebase master` in your
   274  > feature branch to update your pull request rather than `merge master`.
   275  
   276  Before you make a pull request, squash your commits into logical units of work
   277  using `git rebase -i` and `git push -f`. A logical unit of work is a consistent
   278  set of patches that should be reviewed together: for example, upgrading the
   279  version of a vendored dependency and taking advantage of its now available new
   280  feature constitute two separate units of work. Implementing a new function and
   281  calling it in another file constitute a single logical unit of work. The very
   282  high majority of submissions should have a single commit, so if in doubt: squash
   283  down to one.
   284  
   285  - After every commit, [make sure the test suite passes](#run-the-unit--and-integration-tests).
   286    Include documentation changes in the same pull request so that a revert would
   287    remove all traces of the feature or fix.
   288  - Include an issue reference like `closes #XXXX` or `fixes #XXXX` in the PR
   289    description that close an issue. Including references automatically closes
   290    the issue on a merge.
   291  - Do not add yourself to the `AUTHORS` file, as it is regenerated regularly
   292    from the Git history.
   293  - See the [Coding Style](#coding-style) for further guidelines.
   294  
   295  
   296  ### Merge approval
   297  
   298  Project maintainers use LGTM (Looks Good To Me) in comments on the code review to
   299  indicate acceptance, or use the Github review approval feature.
   300  
   301  
   302  ## Coding Style
   303  
   304  Unless explicitly stated, we follow all coding guidelines from the Go
   305  community. While some of these standards may seem arbitrary, they somehow seem
   306  to result in a solid, consistent codebase.
   307  
   308  It is possible that the code base does not currently comply with these
   309  guidelines. We are not looking for a massive PR that fixes this, since that
   310  goes against the spirit of the guidelines. All new contributions should make a
   311  best effort to clean up and make the code base better than they left it.
   312  Obviously, apply your best judgement. Remember, the goal here is to make the
   313  code base easier for humans to navigate and understand. Always keep that in
   314  mind when nudging others to comply.
   315  
   316  The rules:
   317  
   318  1. All code should be formatted with `gofmt -s`.
   319  2. All code should pass the default levels of
   320     [`golint`](https://github.com/golang/lint).
   321  3. All code should follow the guidelines covered in [Effective
   322     Go](http://golang.org/doc/effective_go.html) and [Go Code Review
   323     Comments](https://github.com/golang/go/wiki/CodeReviewComments).
   324  4. Comment the code. Tell us the why, the history and the context.
   325  5. Document _all_ declarations and methods, even private ones. Declare
   326     expectations, caveats and anything else that may be important. If a type
   327     gets exported, having the comments already there will ensure it's ready.
   328  6. Variable name length should be proportional to its context and no longer.
   329     `noCommaALongVariableNameLikeThisIsNotMoreClearWhenASimpleCommentWouldDo`.
   330     In practice, short methods will have short variable names and globals will
   331     have longer names.
   332  7. No underscores in package names. If you need a compound name, step back,
   333     and re-examine why you need a compound name. If you still think you need a
   334     compound name, lose the underscore.
   335  8. No utils or helpers packages. If a function is not general enough to
   336     warrant its own package, it has not been written generally enough to be a
   337     part of a util package. Just leave it unexported and well-documented.
   338  9. All tests should run with `go test` and outside tooling should not be
   339     required. No, we don't need another unit testing framework. Assertion
   340     packages are acceptable if they provide _real_ incremental value.
   341  10. Even though we call these "rules" above, they are actually just
   342      guidelines. Since you've read all the rules, you now know that.
   343  
   344  If you are having trouble getting into the mood of idiomatic Go, we recommend
   345  reading through [Effective Go](https://golang.org/doc/effective_go.html). The
   346  [Go Blog](https://blog.golang.org) is also a great resource.