Skip to content

Commit

Permalink
docs: Add common guidelines and instructions
Browse files Browse the repository at this point in the history
Closes #33
Closes #39
  • Loading branch information
radeksimko committed Mar 24, 2020
1 parent 67b503b commit 5d11776
Show file tree
Hide file tree
Showing 10 changed files with 454 additions and 105 deletions.
5 changes: 5 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Code of Conduct

HashiCorp Community Guidelines apply to you when interacting with the community here on GitHub and contributing code.

Please read the full text at https://www.hashicorp.com/community-guidelines
212 changes: 212 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
# Contributing to Terraform Language Server

## Reporting Feedback

Terraform Language Server is an open source project and we appreciate
contributions of various kinds, including bug reports and fixes,
enhancement proposals, documentation updates, and user experience feedback.

To record a bug report, enhancement proposal, or give any other product
feedback, please [open a GitHub issue](https://github.com/hashicorp/terraform-ls/issues/new/choose)
using the most appropriate issue template. Please do fill in all of the
information the issue templates request, because we've seen from experience that
this will maximize the chance that we'll be able to act on your feedback.

**All communication on GitHub, the community forum, and other HashiCorp-provided
communication channels is subject to
[the HashiCorp community guidelines](https://www.hashicorp.com/community-guidelines).**

## Scope

This repository contains the source code only for Terraform Language Server,
which in turn relies on other projects that have their own repositories.

[Terraform CLI/core has its own repository.](https://github.com/hashicorp/terraform)

The HashiCorp-maintained Terraform providers are open source but are **not**
in this repository; instead, they are each in their own repository in
[the `terraform-providers` organization](https://github.com/terraform-providers)
on GitHub.

This repository also does **not** include the source code for some other parts of
the Terraform product including Terraform Cloud, Terraform Enterprise, and the
Terraform Registry. Those components are not open source, though if you have
feedback about them (including bug reports) please do feel free to
[open a GitHub issue in the core repository](https://github.com/hashicorp/terraform/issues/new/choose).

## Development

If you wish to work on the source code, you'll first need to install
the [Go](https://golang.org/) compiler and the version control system
[Git](https://git-scm.com/).

Refer to the file [`.go-version`](.go-version) to see which version of Go
the Language Server is currently built with. Other versions will often work,
but if you run into any build or testing problems please try with the specific
Go version indicated. You can optionally simplify the installation of multiple
specific versions of Go on your system by installing
[`goenv`](https://github.com/syndbg/goenv), which reads `.go-version` and
automatically selects the correct Go version.

Use Git to clone this repository into a location of your choice. Dependencies
are tracked via [Go Modules](https://blog.golang.org/using-go-modules),
and so you should _not_ clone it inside your `GOPATH`.

Switch into the root directory of the cloned repository and build
the Language Server using the Go toolchain in the standard way:

```
cd terraform-ls
go install .
```

Once the compilation process succeeds, you can find a `terraform-ls` executable in
the Go executable directory. If you haven't overridden it with the `GOBIN`
environment variable, the executable directory is the `bin` directory inside
the directory returned by the following command:

```
go env GOPATH
```

If you are planning to make changes to the source code, you should run the
unit test suite before you start to make sure everything is initially passing:

```
go test ./...
```

As you make your changes, you can re-run the above command to ensure that the
tests are _still_ passing. If you are working only on a specific Go package,
you can speed up your testing cycle by testing only that single package, or
packages under a particular package prefix:

```
go test ./internal/terraform/exec/...
go test ./langserver
```

## External Dependencies

Terraform uses [Go Modules]((https://blog.golang.org/using-go-modules))
for dependency management, but currently uses "vendoring" to include
copies of all of the external library dependencies in the repository
to allow builds to complete even if third-party dependency sources
are unavailable.

If you need to add a new dependency to Terraform or update the selected version
for an existing one, use `go get` from the root of the Terraform repository
as follows:

```
go get github.com/hashicorp/hcl/[email protected]
```

This command will download the requested version (2.0.0 in the above example)
and record that version selection in the `go.mod` file. It will also record
checksums for the module in the `go.sum`.

To complete the dependency change, clean up any redundancy in the module
metadata files and resynchronize the `vendor` directory with the new package
selections by running the following commands:

```
go mod tidy
go mod vendor
```

To ensure that the vendoring has worked correctly, be sure to run the unit
test suite at least once in _vendoring_ mode, where Go will use the vendored
dependencies to build the test programs:

```
go test -mod=vendor ./...
```

Because dependency changes affect a shared, top-level file, they are more likely
than some other change types to become conflicted with other proposed changes
during the code review process. For that reason, and to make dependency changes
more visible in the change history, we prefer to record dependency changes as
separate commits that include only the results of the above commands and the
minimal set of changes to the Language Server's own code for compatibility
with the new version:

```
git add go.mod go.sum vendor
git commit -m "vendor: go get github.com/hashicorp/hcl/[email protected]"
```

You can then make use of the new or updated dependency in new code added in
subsequent commits.

### Licensing Policy

Our dependency licensing policy excludes proprietary licenses and "copyleft"-style
licenses. We accept the common Mozilla Public License v2, MIT License,
and BSD licenses. We will consider other open source licenses
in similar spirit to those three, but if you plan to include such a dependency
in a contribution we'd recommend opening a GitHub issue first to discuss what
you intend to implement and what dependencies it will require so that the
maintainer team can review the relevant licenses to for whether
they meet our licensing needs.

## Debugging

[PacketSender](https://packetsender.com) enables you to open a TCP socket with a server, when launched as such.
Approximate steps of debugging follow.

- Install PacketSender (e.g. on MacOS via `brew cask install packet-sender`)
- Launch LS in TCP mode: `terraform-ls serve -port=8080`
- Send any requests via PacketSender
- Set `Address` to `127.0.0.1`
- Set `Port` to `8080`
- Tick `Persistent TCP`
- Hit the `Send` button (which opens the TCP connection)
- Paste or type request in LSP format (see below) & hit `Send`

Examples of formatted requests follow.

```
Content-Length: 164\n\n{"jsonrpc":"2.0","params":{"textDocument":{"uri":"file:///var/path/to/file/main.tf"},"position":{"line":1,"character":0}},"method":"textDocument/completion","id":2}
```
```
Content-Length: 72\n\n{"jsonrpc":"2.0","params":{"id":2},"method":"$/cancelRequest","id":null}
```
```
Content-Length: 47\n\n{"jsonrpc":"2.0","method":"shutdown","id":null}
```

Keep in mind that each TCP session receives an isolated context,
so you cannot cancel requests you didn't start yourself

## Proposing a Change

If you'd like to contribute a code change, we'd love to review a GitHub pull request.

In order to be respectful of the time of community contributors, we prefer to
discuss potential changes in GitHub issues prior to implementation. That will
allow us to give design feedback up front and set expectations about the scope
of the change, and, for larger changes, how best to approach the work such that
the maintainer team can review it and merge it along with other concurrent work.

If the bug you wish to fix or enhancement you wish to implement isn't already
covered by a GitHub issue that contains feedback from the maintainer team,
please do start a discussion (either in
[a new GitHub issue](https://github.com/hashicorp/terraform-ls/issues/new/choose)
or an existing one, as appropriate) before you invest significant development
time. If you mention your intent to implement the change described in your
issue, the maintainer team can prioritize including implementation-related
feedback in the subsequent discussion.

Most changes will involve updates to the test suite, and changes to the
documentation. The maintainer team can advise on different testing strategies
for specific scenarios, and may ask you to revise the specific phrasing of
your proposed documentation prose to match better with the standard "voice" of
Terraform's documentation.

This repository is primarily maintained by a small team at HashiCorp along with
their other responsibilities, so unfortunately we cannot always respond
promptly to pull requests, particularly if they do not relate to an existing
GitHub issue where the maintainer team has already participated. We _are_
grateful for all contributions however, and will give feedback on pull requests
as soon as we're able to.
72 changes: 72 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
name: Bug report
about: Let us know about an unexpected error, a crash, or an incorrect behavior.

---

### Server Version
<!--
Run `terraform-ls --version` to show the version, and paste the result between the ``` marks below.
If you are not running the latest version, please try upgrading because your issue may have already been fixed.
-->
```
```

### Terraform Version
<!--
Run `terraform -v to show the version, and paste the result between the ``` marks below.
Make sure you are running the same binary that the language server would normally pick up from $PATH
if you have more than one version installed on your system
-->
```
```

### Client Version
<!--
Please share what IDE and/or plugin which interacts with the server
e.g. Sublime Text (LSP plugin) v0.9.7
-->
```
```

### Terraform Configuration Files
<!--
Paste the relevant parts of your Terraform configuration between the ``` marks below.
For large Terraform configs, please use a service like Dropbox and share a link to the ZIP file.
For security, you can also encrypt the files using HashiCorp's GPG public key published at
https://www.hashicorp.com/security#secure-communications
-->

```hcl
```

### Log Output
<!--
Full debug output can be obtained by launching server with particular flag (e.g. -log-file)
Please follow instructions in docs/TROUBLESHOOTING.md
Please create a GitHub Gist containing the debug output. Please do *NOT* paste
the debug output in the issue, since it may be long.
Debug output may contain sensitive information. Please review it before posting publicly, and if you are concerned feel free to encrypt the files using HashiCorp's GPG public key published at
https://www.hashicorp.com/security#secure-communications
-->

### Expected Behavior
<!-- What should have happened? -->

### Actual Behavior
<!-- What actually happened? -->

### Steps to Reproduce
<!--
Please list the full steps required to reproduce the issue, for example:
1. Open a folder in IDE XYZ
2. Open file example.tf from that folder
3. Trigger autocompletion on line 5, column 1 (1-indexed)
-->
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
blank_issues_enabled: false
contact_links:
- name: Provider-related Feedback and Questions
url: https://github.com/terraform-providers
about: Each provider (e.g. AWS, Azure, GCP, Oracle, K8S, etc.) has its own repository, any provider related issues or questions should be directed to appropriate provider repository.
- name: Provider Development Feedback and Questions
url: https://github.com/hashicorp/terraform-plugin-sdk/issues/new/choose
about: Plugin SDK has its own repository, any SDK and provider development related issues or questions should be directed there.
- name: Terraform Language or Workflow Feedback and Questions
url: https://github.com/hashicorp/terraform/issues/new/choose
about: Terraform Core has its own repository, any language (HCL) or workflow related issues or questions should be directed there.
- name: Terraform Language or Workflow Questions
url: https://discuss.hashicorp.com/c/terraform-core
about: Please ask and answer language or workflow related questions through the Terraform Core Community Forum.
55 changes: 55 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
name: Feature request
about: Suggest a new feature or other enhancement.
labels: enhancement
---

### Current Version
<!--
Run `terraform-ls --version` to show the version, and paste the result between the ``` marks below.
If you are not running the latest version, please try upgrading because your issue may have already been fixed.
-->
```
```

### Use-cases
<!--
In order to properly evaluate a feature request, it is necessary to understand the use-cases for it.
Please describe below the _end goal_ you are trying to achieve that has led you to request this feature.
Please keep this section focused on the problem and not on the suggested solution. We'll get to that in a moment, below!
-->

### Attempted Solutions
<!--
If you've already tried to solve the problem within server's existing features and found a limitation that prevented you from succeeding, please describe it below in as much detail as possible.
Ideally, this would include real configuration snippets that you tried, actions you performed (e.g. autocompletion in a particular position in that snippet), and what results you got in each case.
Please remove any sensitive information such as passwords before sharing configuration snippets and command lines.
--->

### Proposal
<!--
If you have an idea for a way to address the problem via a change to existing features, please describe it below.
In this section, it's helpful to include specific examples of how what you are suggesting might look in configuration files, or on the command line, since that allows us to understand the full picture of what you are proposing.
If you're not sure of some details, don't worry! When we evaluate the feature request we may suggest modifications as necessary to work within the design constraints of Language Server.
-->

### Related LSP methods
<!--
Please mention if you know your request is related to any particular LSP method, e.g. textDocument/completion
Specification with all methods is available at
https://microsoft.github.io/language-server-protocol/specifications/specification-current/
-->

### References
<!--
Are there any other GitHub issues, whether open or closed, that are related to the problem you've described above or to the suggested solution? If so, please create a list below that mentions each of them. For example:
- #6017
-->
4 changes: 4 additions & 0 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Vulnerability Reporting

Please disclose security vulnerabilities responsibly by following the procedure
described at https://www.hashicorp.com/security#vulnerability-reporting
4 changes: 4 additions & 0 deletions .github/SUPPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Support

If you have questions about Terraform Language Server usage, please feel free to create a topic
on [the official community forum](https://discuss.hashicorp.com/c/terraform-core).
Loading

0 comments on commit 5d11776

Please sign in to comment.