From b8e37e4237b381d5b37b525071f9d6564923e4db Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Mon, 4 Dec 2023 14:40:57 +0100 Subject: [PATCH] Add page to document how to set up a dev environment --- docs/developer/development-environment.md | 44 +++++++++++++++++++++++ docs/developer/index.md | 1 + 2 files changed, 45 insertions(+) create mode 100644 docs/developer/development-environment.md diff --git a/docs/developer/development-environment.md b/docs/developer/development-environment.md new file mode 100644 index 00000000..219f2d53 --- /dev/null +++ b/docs/developer/development-environment.md @@ -0,0 +1,44 @@ +--- +title: 'Development environment' +license: 'Apache-2.0' +origin_url: 'https://github.com/go-gitea/gitea/blob/ec1feedbf582b05b6a5e8c59fb2457f25d053ba2/docs/content/development/hacking-on-gitea.en-us.md' +--- + +This page lists a few options to set up a productive development environment for working on Forgejo. + +## VS Codium + +[VS Codium](https://vscodium.com/) is an open source version of the Visual Studio Code IDE. +The [Go integration for Visual Studio Code](https://code.visualstudio.com/docs/languages/go) works +with VS Codium and is a viable tool to work on Forgejo. + +First, run `cp -r contrib/ide/vscode .vscode` to create new directory `.vscode` with the contents of folder [contrib/ide/vscode](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/contrib/ide/vscode) at the root of the repository. Then, open the project directory in VS Codium. + +You can now use `Ctrl`+`Shift`+`B` to build the gitea executable and `F5` to run it in debug mode. + +Tests can be run by clicking on the `run test` or `debug test` button above their declaration. + +Go code is formatted automatically when saved. + +## Emacs + +Emacs has [a Go mode](https://github.com/dominikh/go-mode.el) that can likely be used to work on Forgejo's code base. +Do you know how to configure it properly? Why not document that here? + +## Vim + +Vim has [a Go plugin](https://github.com/fatih/vim-go) that can likely be used to work on Forgejo's code base. +Do you know how to configure it properly? Why not document that here? + +## GoLand + +Clicking the `Run Application` arrow on the function `func main()` in `/main.go` +can quickly start a debuggable Gitea instance. + +The `Output Directory` in `Run/Debug Configuration` MUST be set to the +gitea project directory (which contains `main.go` and `go.mod`), +otherwise, the started instance's working directory is a GoLand's temporary directory +and prevents Gitea from loading dynamic resources (eg: templates) in a development environment. + +To run unit tests with SQLite in GoLand, set `-tags sqlite,sqlite_unlock_notify` +in `Go tool arguments` of `Run/Debug Configuration`. diff --git a/docs/developer/index.md b/docs/developer/index.md index 9b496eaf..e3a0fb27 100644 --- a/docs/developer/index.md +++ b/docs/developer/index.md @@ -12,6 +12,7 @@ their needs. - [Sustainability and funding](https://codeberg.org/forgejo/sustainability) - For contributors - [Compiling from source](./from-source/) + - [Development environment](./development-environment/) - [Interface customization](./customization/) - [Architecture overview](./architecture/) - [Developer Certificate of Origin (DCO)](./dco/)