No description
Find a file
2025-01-30 23:33:14 +01:00
README.md Update README.md 2025-01-30 23:33:14 +01:00

Based on a Proxmox container with Ubuntu 22.04

Package installation

Note: We need a git >= 2.48 for Forgejo 10.0.0 to run the tests.

sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt upgrade

sudo apt -y install net-tools mariadb-server mariadb-client git git-lfs make curl git-annex build-essential libatk1.0-0 libatk-bridge2.0-0 libcups2 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libxkbcommon0 libpango-1.0-0 libcairo2 libasound2 libatspi2.0-0 libx11-xcb1 libxcursor1 libgtk-3-0 libpangocairo-1.0-0 libcairo-gobject2 libgdk-pixbuf-2.0-0 libvpx7 libevent-2.1-7 libopus0 gstreamer1.0-plugins-base libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 flite1-dev libwebpdemux2 libavif13 libharfbuzz-icu0 libwebpmux3 libenchant-2-2 libsecret-1-0 libhyphen0 libmanette-0.2-0 libgles2 libx264-163 woff2 libwoff1 libgstreamer-gl1.0-0 libgstreamer-plugins-bad1.0-0 fakeroot dpkg-dev gcc libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip wget curl autoconf automake libtool pkg-config libpcre2-dev asciidoc xmlto docbook2x install-info ghc cabal-install libncurses5-dev libbz2-dev zlib1g-dev libmagic-dev libgsasl7-dev libxml2-dev liblzma-dev rsync postgresql-all

Install go lang >= 1.23

sudo bash
cd /root 
wget https://go.dev/dl/go1.23.4.linux-amd64.tar.gz
rm -rf /usr/local/go
tar -C /usr/local -xzf go1.23.4.linux-amd64.tar.gz

Put into the users .bashrc

Create git user

sudo adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git

Do this as user git

Add this to the .bashrc of the git user

export PATH=$PATH:/usr/local/go/bin
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

If necessary change to user git:

sudo -u git bash

Install nodejs 22

cd ~
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm install 22

Some checks if nodejs 22 is okay

node -v # Should print "v22.13.0"
nvm current # Should print "v22.13.0"
npm -v # Should print "10.9.2"

Prepare forgejo

cd ~
mkdir -p forgejo_test
cd forgejo_test
git clone https://codeberg.org/forgejo/forgejo.git
cd forgejo
make build

Run make test

cd ~
cd forgejo_test
cd forgejo
make test

Run make test-frontend

cd ~
cd forgejo_test
cd forgejo
make test-frontend

Run make test-backend

cd ~
cd forgejo_test
cd forgejo
make test-backend

Run end-2-end test with sqlite

cd ~
cd forgejo_test
cd forgejo
make test-e2e-sqlite

Run end-2-end test with mariadb

Initial setup

sudo systemctl enable mariadb
sudo systemctl start mariadb
sudo mysql_secure_installation

Use the settings:

Switch to unix_socket authentication [Y/n] Y
Change the root password? [Y/n] n
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Creating an example database

sudo mysql

Under mysql we create the test database:

SET old_passwords=0;
CREATE USER 'forgejotest'@'%' IDENTIFIED BY 'forgejotest';
CREATE DATABASE forgejotest CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_bin';
GRANT ALL PRIVILEGES ON forgejotest.* TO 'forgejotest';
FLUSH PRIVILEGES;
exit

We need to make sure that Makefile has the correct values for the MariaDB database:

TEST_MYSQL_HOST ?= 127.0.0.1:3306
TEST_MYSQL_DBNAME ?= forgejotest?multiStatements=true
TEST_MYSQL_USERNAME ?= forgejotest
TEST_MYSQL_PASSWORD ?= forgejotest

Run the test:

cd ~
cd forgejo_test
cd forgejo
make test-e2e-mysql

Run end-2-end test with PostgreSQL

We create the test database:

  1. We connect to the database
sudo -u postgres psql
  1. Create the test user
CREATE ROLE forgejotest WITH LOGIN PASSWORD 'forgejotest';
  1. Create the database

This is the goal:

CREATE DATABASE forgejotest WITH OWNER forgejotest TEMPLATE template0 ENCODING UTF8 LC_COLLATE 'en_US.utf8' LC_CTYPE 'en_US.utf8';

This is the fallback option:

CREATE DATABASE forgejotest WITH OWNER forgejotest TEMPLATE template0 ENCODING UTF8 LC_COLLATE 'C.utf8' LC_CTYPE 'C.utf8';
  1. Use \q to close the postgres console.

  2. Add the permissions for a local connection

echo "local    forgejotest    forgejotest                   scram-sha-256" >> /etc/postgresql/14/main/pg_hba.conf
echo "host     forgejotest    forgejotest    127.0.0.1/32   scram-sha-256" >> /etc/postgresql/14/main/pg_hba.conf
echo "host     forgejotest    forgejotest    ::1/128        scram-sha-256" >> /etc/postgresql/14/main/pg_hba.conf
  1. Test if everything worked out.
psql -U forgejotest -d forgejotest -h localhost

We need to make sure that Makefile has the correct values for the PGSQL database:

TEST_PGSQL_HOST ?= 127.0.0.1:5432
TEST_PGSQL_DBNAME ?= forgejotest
TEST_PGSQL_USERNAME ?= forgejotest
TEST_PGSQL_PASSWORD ?= forgejotest
TEST_PGSQL_SCHEMA ?= gtestschema

If you haven't install MinIO, you need to add this parameter:

TEST_STORAGE_TYPE ?= local
cd ~
cd forgejo_test
cd forgejo
make test-e2e-pgsql