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-f3 → rebase onto base-development
- base-f3 → reset to upstream
- merge feature-f3
- base-activitypub → reset to upstream
- merge Ta180m PRs that are mature Enough and follow the latest evolution from the main branch
- merge base-development
- main → reset to upstream
- merge base-activitypub
Publishing a forgefriends release
- Add a tag to the forgefriends repository
- It will build and upload the docker image to hub.docker.com
- Verify the forgefriends installation instructions are working
The credentials to the docker hub are set in the CI/CD part of the project so they can be available from environment variables in the gitlab-ci.yml
jobs.
Gitea documentation
Local development tree checkout
In the following the remotes are setup as follows:
$ git remote -v
gitea GitHub - go-gitea/gitea: Git with a cup of tea, painless self-hosted git service (fetch)
gitea GitHub - go-gitea/gitea: Git with a cup of tea, painless self-hosted git service (push)
loic ssh://git@lab.forgefriends.org:2222/dachary/forgefriends.git (fetch)
loic ssh://git@lab.forgefriends.org:2222/dachary/forgefriends.git (push)
origin forgefriends / Forgefriends · GitLab (fetch)
origin forgefriends / Forgefriends · GitLab (push)
Show forgefriends commits only (ignore commits originating from Gitea)
git log --oneline --no-merges gitea/main..origin/main
Running tests
Note: prior to running tests, the bindata may need to be generated with TAGS="bindata sqlite sqlite_unlock_notify" make backend
- 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=tests/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=tests/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.
Working with Emacs and Magit
Generating ascii banners
Avoiding database migration conflicts
Rebuilding gitea/test_env:linux-amd64
When running tests with docker run .. -user gitea gitea/test_env:linux-amd64
as explained above, the id of the gitea user in the image is 1000 by default but it may not match the id of the current user and tests will fail because they do not have permission to write in the bind mounted directories. The test-env
image can be rebuilt from scratch so that it matches the current user as follows, from the root of the the test-env repository repository:
docker build --tag gitea/test_env:linux-amd64 --build-arg GITEA_ID=$(id -u) --build-arg GITEA_GID=$(id -g)
See the test-env repository for more information.