forgefriends development maintenance guide
The upstream branch is updated from the Gitea main branch. Feature branches must be be rebased, base branches are reset to upstream and the feature branches it contains are merged into it. The order of the following list matters.
- upstream → pulled from Gitea main
- feature-gitlab-ci → rebase onto upstream
- feature-licensing → rebase onto upstream
- feature-development-environment → rebase onto upstream
- base-development → reset to upstream
- merge feature-licensing
- merge feature-gitlab-ci
- merge feature-development-environment
- feature-go-fed → rebase onto upstream
- feature-projectbase → rebase onto base-development
- feature-fff → rebase onto base-development
- base-activitypub → reset to upstream
- merge feature-go-fed
- merge feature-projectbase
- feature-activitypub → rebase onto base-activitypub
- main → reset to upstream
- merge feature-activitypub
- merge feature-fff
Gitea documentation
Local development tree checkout
In the following the remotes are setup as follows:
$ git remote -v
gitea https://github.com/go-gitea/gitea (fetch)
gitea https://github.com/go-gitea/gitea (push)
loic ssh://git@lab.forgefriends.org:2222/dachary/forgefriends.git (fetch)
loic ssh://git@lab.forgefriends.org:2222/dachary/forgefriends.git (push)
origin https://lab.forgefriends.org/forgefriends/forgefriends.git (fetch)
origin https://lab.forgefriends.org/forgefriends/forgefriends.git (push)
Show forgefriends commits only (ignore commits originating from Gitea)
git log --oneline --no-merges gitea/main..origin/main
Every week sync with gitea
- git fetch gitea
- git checkout -b wip-gitea-merge origin/main
- git merge gitea/main
- git push loic/wip-gitea-merge
- create merge request with subject “Merge remote-tracking branch ‘gitea/main’ into main”
- merge when tests pass
Running tests
- All tests
time drone exec --pipeline testing-amd64 .gitlab-ci-drone.yml
firefox coverage.html - Only integration tests
docker run --rm -ti -e TEST_TAGS='bindata sqlite sqlite_unlock_notify' -e GOPATH=/tmp/cache/go-path -e GOCACHE=/tmp/cache/go-build --volume=$(pwd)/..:/tmp/cache --volume $(pwd):/drone/src --workdir /drone/src --user gitea gitea/test_env:linux-amd64 bash -c 'make integrations.sqlite.test generate-ini-sqlite && GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test'
- Only unit tests with SQL statements displayed
docker run --rm -ti -e GOPATH=/tmp/cache/go-path -e GOCACHE=/tmp/cache/go-build --volume=$(pwd)/..:/tmp/cache -e GITEA_UNIT_TESTS_LOG_SQL=1 -e TAGS="bindata sqlite sqlite_unlock_notify" --user gitea -v $(pwd):/drone/src --workdir=/drone/src gitea/test_env:linux-amd64 make unit-test-coverage
- Only unit tests with coverage
docker run --rm -ti -e GOPATH=/tmp/cache/go-path -e GOCACHE=/tmp/cache/go-build --volume=$(pwd)/..:/tmp/cache -e TAGS="bindata sqlite sqlite_unlock_notify" --user gitea -v $(pwd):/drone/src --workdir=/drone/src gitea/test_env:linux-amd64 make unit-test-coverage
docker run --rm -e GOPATH=/tmp/cache/go-path -e GOCACHE=/tmp/cache/go-build --volume=$(pwd)/..:/tmp/cache --volume $(pwd):/drone/src --workdir /drone/src --user gitea gitea/test_env:linux-amd64 go tool cover -html=coverage.out -o coverage.html
firefox coverage.html
- A specific test only
docker run --rm -ti -e GOPATH=/tmp/cache/go-path -e GOCACHE=/tmp/cache/go-build --volume=$(pwd)/..:/tmp/cache -e TAGS="bindata sqlite sqlite_unlock_notify" --user gitea -v $(pwd):/drone/src --workdir=/drone/src gitea/test_env:linux-amd64 make GOTESTFLAGS='-run "^TestGetFeeds1"'' GO_PACKAGES=code.gitea.io/gitea/models unit-test-coverage
- A specific unit test in verbose mode
docker run -ti --rm -e GOTESTFLAGS='-v -run "^TestGetFeeds1"'' -e GO_PACKAGES=code.gitea.io/gitea/modules/foobar -e GOPATH=/tmp/cache/go-path -e GOCACHE=/tmp/cache/go-build --volume=$(pwd)/..:/tmp/cache --volume $(pwd):/drone/src --workdir /drone/src --user gitea gitea/test_env:linux-amd64 make unit-test-coverage
- A specific integration test in verbose mode to see log.Error, fmt.Printnl…
docker run --rm -ti -e TEST_TAGS='bindata sqlite sqlite_unlock_notify' -e GOPATH=/tmp/cache/go-path -e GOCACHE=/tmp/cache/go-build --volume=$(pwd)/..:/tmp/cache --volume $(pwd):/drone/src --workdir /drone/src --user gitea gitea/test_env:linux-amd64 bash -c 'make integrations.sqlite.test generate-ini-sqlite && GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.v -test.run TestActivityPubPerson'
- A specific unit test without caching (note the -count=1, that’s what disables caching)
docker run -ti --rm -e GOPATH=/tmp/cache/go-path -e GOCACHE=/tmp/cache/go-build --volume=$(pwd)/..:/tmp/cache --volume $(pwd):/drone/src --workdir /drone/src --user gitea gitea/test_env:linux-amd64 env GOTESTFLAGS=-count=1 GITEA_UNIT_TESTS_VERBOSE=true GO_PACKAGES=code.gitea.io/gitea/models make 'test#TestRepository_HasWiki'
- Rebuild the bindata after migration/schemas is modified
docker run -ti --rm -e TAGS='bindata sqlite sqlite_unlock_notify' -e GOPATH=/tmp/cache/go-path -e GOCACHE=/tmp/cache/go-build --volume=$(pwd)/..:/tmp/cache --volume $(pwd):/drone/src --workdir /drone/src --user gitea gitea/test_env:linux-amd64 make backend
Getting code from a given PR
Creating a branch
PR=16834 ; git fetch gitea pull/$PR/head:pr-$PR
Creating a diff with the content of the PR
PR=16834 ; git diff gitea/main…pr-$PR > /tmp/$PR.patch
GitLab runner pitfalls
Because of this bug it is not possible to cancel a running job and expect it to be terminated. It will run to the end.