Cheatlist for forgefriends development

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
  • main → reset to upstream
    • merge base-activitypub

Publishing a forgefriends release

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.

image

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.

4 Likes

24 posts were merged into an existing topic: Recurring forgefriends rebase on Gitea

Notes on this week merge with gitea.

  • User settings were merged and the forgefriends backport is not longer needed, it was reverted. The samantic is slightly different and the forgefriends code was adapted.
  • Conflicts had to be resolved as a result of three refactors impacting the forgefriends code (1, 2, 3)

The cheatlist was updated with instructions on how to rebuild test-env.

Added a note about:

TAGS="bindata sqlite sqlite_unlock_notify" make backend

which is not run by default if manually running the integration tests.

The projectbase merge request is discarded. This is the kind of tightly coupled integration that requires a level of communication that is not currently happening between Gitea and forgefriends.

The rebasing instructions were updated accordingly (version 51 → 52).

Fixed the cheatlist: s|integrations/sqlite.ini|tests/sqlite.ini|