|
| 1 | +# Developing |
| 2 | + |
| 3 | +## Setting up a development environment |
| 4 | + |
| 5 | +### Setup a GitHub account accessible via SSH |
| 6 | + |
| 7 | +GitHub is used for project Source Code Management (SCM) using the SSH protocol for authentication. |
| 8 | + |
| 9 | +1. Create [a GitHub account](https://github.com/join) if you do not already have one. |
| 10 | +1. Setup |
| 11 | +[GitHub access via SSH](https://help.github.com/articles/connecting-to-github-with-ssh/) |
| 12 | + |
| 13 | +### Install tools |
| 14 | + |
| 15 | +You must install these tools: |
| 16 | + |
| 17 | +1. [`git`](https://help.github.com/articles/set-up-git/): For source control |
| 18 | + |
| 19 | +1. [`go`](https://golang.org/doc/install): The language this SDK is built in. |
| 20 | + > **Note** Golang [version v1.18](https://golang.org/dl/) or higher is required. |
| 21 | +
|
| 22 | +1. [`make`](https://www.gnu.org/software/make/): not stricly required but handy to run |
| 23 | + tests with a single command. |
| 24 | + |
| 25 | +### Setup a fork |
| 26 | + |
| 27 | +The Tekton project requires that you develop (commit) code changes to branches that belong to a fork of the `tektoncd/pipeline` repository in your GitHub account before submitting them as Pull Requests (PRs) to the actual project repository. |
| 28 | + |
| 29 | +1. [Create a fork](https://help.github.com/articles/fork-a-repo/) of the `tektoncd/pipeline` repository in your GitHub account. |
| 30 | + |
| 31 | +1. Create a clone of your fork on your local machine: |
| 32 | + |
| 33 | + ```shell |
| 34 | + git clone [email protected]: ${YOUR_GITHUB_USERNAME}/sdk-go.git |
| 35 | + ``` |
| 36 | + |
| 37 | +1. Configure `git` remote repositories |
| 38 | + |
| 39 | + Adding `cdevents/sdk-go` as the `upstream` and your fork as the `origin` remote repositories to your `.git/config` sets you up nicely for regularly [syncing your fork](https://help.github.com/articles/syncing-a-fork/) and submitting pull requests. |
| 40 | + |
| 41 | + 1. Change into the project directory |
| 42 | + |
| 43 | + ```shell |
| 44 | + cd sdk-go |
| 45 | + ``` |
| 46 | + |
| 47 | + 1. Configure sdk-go as the `upstream` repository |
| 48 | + |
| 49 | + ```shell |
| 50 | + git remote add upstream [email protected]:cdevents/sdk-go.git |
| 51 | +
|
| 52 | + # Optional: Prevent accidental pushing of commits by changing the upstream URL to `no_push` |
| 53 | + git remote set-url --push upstream no_push |
| 54 | + ``` |
| 55 | + |
| 56 | + 1. Configure your fork as the `origin` repository |
| 57 | + |
| 58 | + ```shell |
| 59 | + git remote add origin [email protected]:${YOUR_GITHUB_USERNAME}/sdk-go.git |
| 60 | + ``` |
| 61 | + |
| 62 | +## Developing, building and testing |
| 63 | + |
| 64 | +Make target all defined to run unit tests, format imports, format go code and run the linter. |
| 65 | + |
| 66 | +To format the go code and imports: |
| 67 | + |
| 68 | +```shell |
| 69 | +$ make fmt |
| 70 | +``` |
| 71 | + |
| 72 | +To run the go linter: |
| 73 | + |
| 74 | +```shell |
| 75 | +$ make lint |
| 76 | +``` |
| 77 | + |
| 78 | +To run unit tests: |
| 79 | +```shell |
| 80 | +$ make test |
| 81 | +``` |
| 82 | + |
| 83 | +To run all targets, before creating a commit: |
| 84 | + |
| 85 | +```shell |
| 86 | +make all |
| 87 | +``` |
| 88 | + |
0 commit comments