1# Azure SDK for Go Contributing Guide
2
3Thank you for your interest in contributing to Azure SDK for Go.
4
5- For reporting bugs, requesting features, or asking for support, please file an issue in the [issues](https://github.com/Azure/azure-sdk-for-go/issues) section of the project.
6
7- If you would like to become an active contributor to this project please follow the instructions provided in [Microsoft Azure Projects Contribution Guidelines](https://azure.github.io/azure-sdk/policies_opensource.html).
8
9- To make code changes, or contribute something new, please follow the [GitHub Forks / Pull requests model](https://help.github.com/articles/fork-a-repo/): Fork the repo, make the change and propose it back by submitting a pull request.
10
11## Pull Requests
12
13- **DO** follow the API design and implementation [Go Guidelines](https://azure.github.io/azure-sdk/golang_introduction.html).
14  - When submitting large changes or features, **DO** have an issue or spec doc that describes the design, usage, and motivating scenario.
15- **DO** submit all code changes via pull requests (PRs) rather than through a direct commit. PRs will be reviewed and potentially merged by the repo maintainers after a peer review that includes at least one maintainer.
16- **DO** review your own PR to make sure there are no unintended changes or commits before submitting it.
17- **DO NOT** submit "work in progress" PRs. A PR should only be submitted when it is considered ready for review and subsequent merging by the contributor.
18  - If the change is work-in-progress or an experiment, **DO** start off as a temporary draft PR.
19- **DO** give PRs short-but-descriptive names (e.g. "Improve code coverage for Azure.Core by 10%", not "Fix #1234") and add a description which explains why the change is being made.
20- **DO** refer to any relevant issues, and include [keywords](https://help.github.com/articles/closing-issues-via-commit-messages/) that automatically close issues when the PR is merged.
21- **DO** tag any users that should know about and/or review the change.
22- **DO** ensure each commit successfully builds. The entire PR must pass all tests in the Continuous Integration (CI) system before it'll be merged.
23- **DO** address PR feedback in an additional commit(s) rather than amending the existing commits, and only rebase/squash them when necessary. This makes it easier for reviewers to track changes.
24- **DO** assume that ["Squash and Merge"](https://github.com/blog/2141-squash-your-commits) will be used to merge your commit unless you request otherwise in the PR.
25- **DO NOT** mix independent, unrelated changes in one PR. Separate real product/test code changes from larger code formatting/dead code removal changes. Separate unrelated fixes into separate PRs, especially if they are in different modules or files that otherwise wouldn't be changed.
26- **DO** comment your code focusing on "why", where necessary. Otherwise, aim to keep it self-documenting with appropriate names and style.
27- **DO** add [GoDoc style comments](https://azure.github.io/azure-sdk/golang_introduction.html#documentation-style) when adding new APIs or modifying header files.
28- **DO** make sure there are no typos or spelling errors, especially in user-facing documentation.
29- **DO** verify if your changes have impact elsewhere. For instance, do you need to update other docs or exiting markdown files that might be impacted?
30- **DO** add relevant unit tests to ensure CI will catch future regressions.
31
32## Merging Pull Requests (for project contributors with write access)
33
34- **DO** use ["Squash and Merge"](https://github.com/blog/2141-squash-your-commits) by default for individual contributions unless requested by the PR author.
35  Do so, even if the PR contains only one commit. It creates a simpler history than "Create a Merge Commit".
36  Reasons that PR authors may request "Merge and Commit" may include (but are not limited to):
37
38  - The change is easier to understand as a series of focused commits. Each commit in the series must be buildable so as not to break `git bisect`.
39  - Contributor is using an e-mail address other than the primary GitHub address and wants that preserved in the history. Contributor must be willing to squash
40    the commits manually before acceptance.
41
42## Developer Guide
43
44### Repo structure
45
46Most packages under the `services` directory in the SDK are generated from [Azure API specs][azure_rest_specs]
47using [Azure/autorest.go][] and [Azure/autorest][]. These generated packages depend on the HTTP client implemented at [Azure/go-autorest][]. Therefore when contributing, please make sure you do not change anything under the `services` directory.
48
49[azure_rest_specs]: https://github.com/Azure/azure-rest-api-specs
50[azure/autorest]: https://github.com/Azure/autorest
51[azure/autorest.go]: https://github.com/Azure/autorest.go
52[azure/go-autorest]: https://github.com/Azure/go-autorest
53
54For bugs or feature requests you can submit them using the [Github issues page][issues] and filling the appropriate template.
55
56### Codespaces
57
58Codespaces is new technology that allows you to use a container as your development environment. This repo provides a Codespaces container which is supported by both GitHub Codespaces and VS Code Codespaces.
59
60#### GitHub Codespaces
61
621. From the Azure SDK GitHub repo, click on the "Code -> Open with Codespaces" button.
631. Open a Terminal. The development environment will be ready for you. Continue to [Building and Testing](https://github.com/Azure/azure-sdk-for-go/blob/main/CONTRIBUTING.md#building-and-testing).
64
65#### VS Code Codespaces
66
671. Install the [VS Code Remote Extension Pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack)
681. When you open the Azure SDK for Go repo in VS Code, it will prompt you to open the project in the Dev Container. If it does not prompt you, then hit CTRL+P, and select "Remote-Containers: Open Folder in Container..."
691. Open a Terminal. The development environment will be ready for you. Continue to [Building and Testing](https://github.com/Azure/azure-sdk-for-go/blob/main/CONTRIBUTING.md#building-and-testing).
70
71### Building and Testing
72
73#### Building
74
75SDKs are either old (track 1) or new (track 2):
76
77- Old (Track 1) SDKs are found in the services/ and profiles/ top level folders.
78    - CI is in /azure-pipelines.yml
79- New (Track 2) SDKs are found in the sdk/ top level folder.
80    - CI is in /eng/pipelines/templates/steps/build.yml
81
82To build, run `go build` from the respective SDK directory.
83
84There currently is not a repository wide way to build or regenerate code.
85
86#### Testing
87
88To test, run 'go test' from the respective directory.
89