summaryrefslogtreecommitdiff
path: root/doc/beginners_guide.md
blob: 38d76adbc4767577b443396d742d94f2bd505623 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
---
stage: Create
group: Source Code
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
---

# Beginner's guide to GitLab Shell contributions

In order to build the binaries a single `make` command can be run:

```shell
make
```

If the command fails due to an error in `gssapi`, make sure that a `Kerberos` implementation is installed. For MacOS it's:

```shell
brew install heimdal
```

It may also require specifying `CGO_CFLAGS`:

```shell
CGO_CFLAGS="-I/opt/homebrew/opt/heimdal/include" make
```

## Check

Checks if GitLab API access and Redis via internal API can be reached:

```shell
make check
```

## Compile

Builds the `gitlab-shell` binaries, placing them into `bin/`.

```shell
make compile
```

## Install

Builds the `gitlab-shell` binaries and installs them onto the file system. The
default location is `/usr/local`, but you can change the location by setting the `PREFIX`
and `DESTDIR` environment variables.

```shell
make install
```

## Setup

This command is intended for use when installing GitLab from source on a single
machine. It compiles the GitLab Shell binaries, and ensures that
various paths on the file system exist with the correct permissions. Do not run
this command unless your installation method documentation instructs you to.

```shell
make setup
```

## Testing

Run tests:

```shell
bundle install
make test
```

Run Gofmt:

```shell
make verify
```

Run both test and verify (the default Makefile target):

```shell
bundle install
make validate
```

## Gitaly

Some tests need a Gitaly server. The
[`docker-compose.yml`](../docker-compose.yml) file runs Gitaly on port 8075.
To tell the tests where Gitaly is, set `GITALY_CONNECTION_INFO`:

```plaintext
export GITALY_CONNECTION_INFO='{"address": "tcp://localhost:8075", "storage": "default"}'
make test
```

If no `GITALY_CONNECTION_INFO` is set, the test suite still runs, but any
tests requiring Gitaly are skipped. The tests always run in the CI environment.

## Logging Guidelines

In general, you can determine the structure, but not content, of a GitLab Shell
or `gitlab-sshd` session by inspecting the logs. Some guidelines:

- We use [`gitlab.com/gitlab-org/labkit/log`](https://pkg.go.dev/gitlab.com/gitlab-org/labkit/log)
  for logging.
- Always include a correlation ID.
- Log messages should be invariant and unique. Include accessory information in
  fields, using `log.WithField`, `log.WithFields`, or `log.WithError`.
- Log both success cases and error cases.
- Logging too much is better than not logging enough. If a message seems too
  verbose, consider reducing the log level before removing the message.