### Setup PostgreSQL Database for Testing Source: https://github.com/forgejo/forgejo/blob/forgejo/tests/e2e/README.md Start a PostgreSQL Docker container for end-to-end testing. The container will be automatically stopped when you press Ctrl+C. ```bash docker run -e POSTGRES_DB=test -e POSTGRES_PASSWORD=password -p 5432:5432 --rm --name pgsql postgres:latest #(Ctrl-c to stop the database) ``` -------------------------------- ### Setup MySQL Database for Testing Source: https://github.com/forgejo/forgejo/blob/forgejo/tests/e2e/README.md Start a MySQL Docker container for end-to-end testing. The container will be automatically stopped when you press Ctrl+C. ```bash docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:latest #(Ctrl-c to stop the database) ``` -------------------------------- ### Install Monitoring Tools Source: https://github.com/forgejo/forgejo/blob/forgejo/contrib/gitea-monitoring-mixin/README.md Install the necessary Go tools for managing and building Grafana dashboards with Gitea Mixin. Ensure you have a working Go environment. ```bash go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest go install github.com/google/go-jsonnet/cmd/jsonnet@latest # or in brew: brew install go-jsonnet ``` ```bash go install github.com/monitoring-mixins/mixtool/cmd/mixtool@latest go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest ``` -------------------------------- ### Start Forgejo Web Server Source: https://context7.com/forgejo/forgejo/llms.txt Starts the Forgejo HTTP server. Can be configured with custom ports, config files, and verbose logging. ```bash forgejo web ``` ```bash forgejo web --port 8080 ``` ```bash forgejo web --config /etc/forgejo/app.ini ``` ```bash forgejo web --verbose ``` -------------------------------- ### Install Playwright Dependencies Source: https://github.com/forgejo/forgejo/blob/forgejo/tests/e2e/README.md Install system libraries required by Playwright and download the necessary browser binaries for automated testing. ```bash npx playwright install-deps ``` -------------------------------- ### Get a Wiki Page Source: https://context7.com/forgejo/forgejo/llms.txt Retrieves a specific wiki page by its title. Requires an authorization token. ```bash curl -s "https://codeberg.org/api/v1/repos/alice/my-new-project/wiki/page/Setup-Guide" \ -H "Authorization: token $TOKEN" ``` -------------------------------- ### Manage webhooks Source: https://context7.com/forgejo/forgejo/llms.txt Creates, lists, edits, and deletes repository webhooks for event-driven integrations. This example shows how to create a webhook. ```APIDOC ## POST /repos/{owner}/{repo}/hooks ### Description Creates a repository webhook. ### Method POST ### Endpoint /repos/{owner}/{repo}/hooks ### Parameters #### Request Body - **type** (string) - Required - The type of the webhook (e.g., "forgejo"). - **config** (object) - Required - Configuration for the webhook. - **url** (string) - Required - The URL to send webhook delivery requests to. - **content_type** (string) - Optional - The content type of the delivery requests (e.g., "json"). - **secret** (string) - Optional - The secret to use for signing webhook deliveries. - **events** (array of strings) - Optional - A list of events that trigger the webhook. - **active** (boolean) - Optional - Whether the webhook is active. ### Request Example ```json { "type": "forgejo", "config": { "url": "https://ci.example.com/webhook", "content_type": "json", "secret": "my_webhook_secret" }, "events": ["push", "pull_request", "release"], "active": true } ``` ### Response #### Success Response (201 Created) - **id** (integer) - The unique identifier of the webhook. - **type** (string) - The type of the webhook. - **config** (object) - The configuration of the webhook. - **active** (boolean) - Whether the webhook is active. #### Response Example ```json { "id": 10, "type": "forgejo", "config": { "url": "https://ci.example.com/webhook", ... }, "active": true, ... } ``` ``` -------------------------------- ### Setup and Run MySQL Integration Tests Source: https://github.com/forgejo/forgejo/blob/forgejo/tests/integration/README.md Set up a MySQL database using Docker and then run integration tests, specifying connection details via environment variables. ```shell docker run -e MYSQL_DATABASE=test -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -p 3306:3306 --rm --name mysql mysql:latest #(Ctrl-c to stop the database) ``` ```shell TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test?multiStatements=true TEST_MYSQL_USERNAME=root TEST_MYSQL_PASSWORD='' make test-mysql ``` -------------------------------- ### Setup and Run PostgreSQL Integration Tests with S3 Source: https://github.com/forgejo/forgejo/blob/forgejo/tests/integration/README.md Set up PostgreSQL and an S3 server using Docker. Then, run integration tests, configuring database and S3 connection details via environment variables. ```shell docker run -e "POSTGRES_DB=test" -e POSTGRES_PASSWORD=postgres -e POSTGRESQL_FSYNC=off -e POSTGRESQL_EXTRA_FLAGS="-c full_page_writes=off" -p 5432:5432 --rm --name pgsql data.forgejo.org/oci/bitnami/postgresql:16 #(Ctrl-c to stop) ``` ```shell docker run -e MINIO_ROOT_USER=123456 -e MINIO_ROOT_PASSWORD=12345678 -p 9000:9000 --rm --name minio data.forgejo.org/oci/bitnami/minio:2024.8.17 #(Ctrl-c to stop) ``` ```shell TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres TEST_S3_HOST=localhost:9000 make 'test-pgsql#Test' ``` -------------------------------- ### Run Forgejo Container with Install Lock Source: https://github.com/forgejo/forgejo/blob/forgejo/RELEASE-NOTES.md Use the FORGEJO__security__INSTALL_LOCK environment variable when running a Forgejo container to enable the installation lock. This is a backward-compatible alternative to GITEA__security__INSTALL_LOCK. ```bash docker run --name forgejo -e FORGEJO__security__INSTALL_LOCK=true codeberg.org/forgejo/forgejo:1.18.1-0 ``` -------------------------------- ### Create a Wiki Page Source: https://context7.com/forgejo/forgejo/llms.txt Creates a new wiki page for a repository. The content must be base64-encoded. Requires an authorization token and specific content type. ```bash CONTENT=$(echo -n "# Setup Guide\n\nInstall dependencies with `go mod tidy`." | base64) curl -s -X POST "https://codeberg.org/api/v1/repos/alice/my-new-project/wiki/new" \ -H "Authorization: token $TOKEN" \ -H "Content-Type: application/json" \ -d "{ \"title\": \"Setup Guide\", \"content_base64\": \"$CONTENT\", \"message\": \"Add setup guide\" }" ``` -------------------------------- ### Get user info Source: https://context7.com/forgejo/forgejo/llms.txt Retrieves public profile information for a given user. ```APIDOC ## API: Get user info Returns public profile information for any user by their username. ### Method GET ### Endpoint `/api/v1/users/{username}` ### Response #### Success Response (200) - **id** (integer) - The user's ID. - **login** (string) - The user's login name. - **full_name** (string) - The user's full name. - **avatar_url** (string) - The URL of the user's avatar. - **html_url** (string) - The URL of the user's profile page. - **created** (string) - The date and time the user account was created. - **is_admin** (boolean) - Whether the user is an administrator. ### Request Example ```bash curl -s "https://codeberg.org/api/v1/users/alice" ``` ### Response Example ```json { "id": 42, "login": "alice", "full_name": "Alice Example", "avatar_url": "https://codeberg.org/avatars/...", "html_url": "https://codeberg.org/alice", "created": "2022-03-14T00:00:00Z", "is_admin": false } ``` ``` -------------------------------- ### Get running version Source: https://context7.com/forgejo/forgejo/llms.txt Returns the version string of the running Forgejo instance. ```APIDOC ## GET /api/v1/version ### Description Returns the version string of the running Forgejo instance. ### Method GET ### Endpoint /api/v1/version ### Request Example ```bash curl -s https://codeberg.org/api/v1/version ``` ### Response #### Success Response (200) - **version** (string) - The version of the Forgejo instance. ### Response Example ```json { "version":"15.0.1" } ``` ``` -------------------------------- ### Create a New Repository Source: https://context7.com/forgejo/forgejo/llms.txt Create a new repository for the authenticated user. Options include setting it as private, initializing with a commit, specifying a default branch, gitignore template, and license. ```bash curl -s -X POST "https://codeberg.org/api/v1/user/repos" \ -H "Authorization: token $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "my-new-project", "description": "A project created via API", "private": false, "auto_init": true, "default_branch": "main", "gitignores": "Go", "license": "MIT" }' # { "id": 999, "full_name": "alice/my-new-project", "clone_url": "https://codeberg.org/alice/my-new-project.git", ... } ``` -------------------------------- ### List deploy keys for a repository Source: https://context7.com/forgejo/forgejo/llms.txt Lists all deploy keys associated with a specific repository. Requires authentication. ```bash # List deploy keys curl -s "https://codeberg.org/api/v1/repos/alice/my-new-project/keys" \ -H "Authorization: token $TOKEN" ``` -------------------------------- ### Get NodeInfo Source: https://context7.com/forgejo/forgejo/llms.txt Retrieves NodeInfo, which provides metadata about the Forgejo instance for federation purposes. ```APIDOC ## GET /api/v1/nodeinfo ### Description Fetches NodeInfo, a standardized way to expose instance metadata for discovery and federation purposes within the Fediverse. ### Method GET ### Endpoint /api/v1/nodeinfo ``` -------------------------------- ### Create a Webhook Source: https://context7.com/forgejo/forgejo/llms.txt Creates a repository webhook for event-driven integrations. Requires configuration for URL, content type, secret, and events to subscribe to. ```bash curl -s -X POST "https://codeberg.org/api/v1/repos/alice/my-new-project/hooks" \ -H "Authorization: token $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "type": "forgejo", "config": { "url": "https://ci.example.com/webhook", "content_type": "json", "secret": "my_webhook_secret" }, "events": ["push", "pull_request", "release"], "active": true }' ``` -------------------------------- ### Get Instance Actor Source: https://context7.com/forgejo/forgejo/llms.txt Retrieves the ActivityPub actor for the instance, representing the server-level identity. ```APIDOC ## GET /api/v1/activitypub/actor ### Description Fetches the ActivityPub actor object for the Forgejo instance. This represents the server's identity in the Fediverse. ### Method GET ### Endpoint /api/v1/activitypub/actor ### Headers - **Accept**: application/activity+json ``` -------------------------------- ### Run Full End-to-End Test Suite (SQLite) Source: https://github.com/forgejo/forgejo/blob/forgejo/tests/e2e/README.md Execute the complete suite of end-to-end tests using the SQLite database backend. ```bash make test-e2e-sqlite ``` -------------------------------- ### Get repository archive Source: https://context7.com/forgejo/forgejo/llms.txt Downloads a ZIP or tar.gz archive of a repository at a given ref. ```APIDOC ## GET /repos/{owner}/{repo}/archive/{archive_name}.{format} ### Description Downloads a ZIP or tar.gz archive of a repository at a given ref. ### Method GET ### Endpoint /repos/{owner}/{repo}/archive/{archive_name}.{format} ### Parameters #### Path Parameters - **archive_name** (string) - Required - The name of the branch, tag, or commit SHA to archive. - **format** (string) - Required - The archive format: 'zip' or 'tar.gz'. ### Response #### Success Response (200 OK) - The content of the repository archive (ZIP or tar.gz). ``` -------------------------------- ### Get a branch Source: https://context7.com/forgejo/forgejo/llms.txt Retrieves a single branch along with its effective branch protection rules. ```APIDOC ## GET /api/v1/repos/{owner}/{repo}/branches/{branch} ### Description Retrieves a single branch along with its effective branch protection rules. ### Method GET ### Endpoint /api/v1/repos/{owner}/{repo}/branches/{branch} ### Parameters #### Path Parameters - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. - **branch** (string) - Required - The name of the branch. #### Header Parameters - **Authorization** (string) - Optional - Bearer token in the format `token YOUR_PERSONAL_ACCESS_TOKEN` for private repositories. ### Request Example ```bash TOKEN="your_personal_access_token" curl -s "https://codeberg.org/api/v1/repos/alice/my-new-project/branches/main" \ -H "Authorization: token $TOKEN" ``` ### Response #### Success Response (200) - **name** (string) - The name of the branch. ### Response Example ```json { "name": "main", ``` ``` -------------------------------- ### Clean Frontend Build Source: https://github.com/forgejo/forgejo/blob/forgejo/tests/e2e/README.md Run this command to perform a clean build of the frontend assets. This is necessary whenever frontend code (JavaScript, CSS) is modified. ```bash make clean frontend ``` -------------------------------- ### Get repository details Source: https://context7.com/forgejo/forgejo/llms.txt Retrieves metadata for a specific repository using its owner and name. ```APIDOC ## GET /api/v1/repos/{owner}/{repo} ### Description Retrieves metadata for a specific repository by owner and repo name. ### Method GET ### Endpoint /api/v1/repos/{owner}/{repo} ### Parameters #### Path Parameters - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. #### Header Parameters - **Authorization** (string) - Optional - Bearer token in the format `token YOUR_PERSONAL_ACCESS_TOKEN` for private repositories. ### Request Example ```bash TOKEN="your_personal_access_token" curl -s "https://codeberg.org/api/v1/repos/alice/my-new-project" \ -H "Authorization: token $TOKEN" ``` ### Response #### Success Response (200) - **id** (integer) - The repository's unique identifier. - **full_name** (string) - The repository's full name (owner/name). - **empty** (boolean) - Indicates if the repository is empty. - **private** (boolean) - Indicates if the repository is private. - **fork** (boolean) - Indicates if the repository is a fork. - **default_branch** (string) - The name of the default branch. - **stars_count** (integer) - The number of stars the repository has received. - **forks_count** (integer) - The number of times the repository has been forked. - **open_issues_count** (integer) - The number of open issues. ### Response Example ```json { "id": 999, "full_name": "alice/my-new-project", "empty": false, "private": false, "fork": false, "default_branch": "main", "stars_count": 0, "forks_count": 0, "open_issues_count": 0, ... } ``` ``` -------------------------------- ### Create Wiki Page Source: https://context7.com/forgejo/forgejo/llms.txt Creates a new wiki page for a repository. The content must be provided in base64 encoding. ```APIDOC ## POST /api/v1/repos/{owner}/{repo}/wiki/new ### Description Creates a new wiki page within a specified repository. The page content needs to be base64 encoded. ### Method POST ### Endpoint /api/v1/repos/{owner}/{repo}/wiki/new ### Parameters #### Path Parameters - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. #### Request Body - **title** (string) - Required - The title of the wiki page. - **content_base64** (string) - Required - The base64 encoded content of the wiki page. - **message** (string) - Optional - A commit message for the creation of the wiki page. ``` -------------------------------- ### Configuring Default Preferred Licenses Source: https://github.com/forgejo/forgejo/blob/forgejo/release-notes-published/up-to-and-including-8.0.0.md Set the default preferred licenses for new repositories using the `repository.PREFERRED_LICENSES` configuration setting. Ensure the values are valid SPDX license identifiers. ```ini [repository] PREFERRED_LICENSES = "Apache-2.0, MIT" ``` -------------------------------- ### Get Wiki Page Source: https://context7.com/forgejo/forgejo/llms.txt Retrieves a specific wiki page from a repository. The page title should be URL-encoded. ```APIDOC ## GET /api/v1/repos/{owner}/{repo}/wiki/page/{page_title} ### Description Retrieves the content and metadata of a specific wiki page from a repository. ### Method GET ### Endpoint /api/v1/repos/{owner}/{repo}/wiki/page/{page_title} ### Parameters #### Path Parameters - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. - **page_title** (string) - Required - The URL-encoded title of the wiki page. ``` -------------------------------- ### Clean Build and Test Execution Source: https://github.com/forgejo/forgejo/blob/forgejo/tests/integration/README.md Perform a clean build and then run integration tests for SQLite, PostgreSQL, or MySQL backends. ```shell make clean build ``` ```shell make test-sqlite make test-pgsql make test-mysql ``` -------------------------------- ### Get NodeInfo for Instance Metadata Source: https://context7.com/forgejo/forgejo/llms.txt Retrieves instance metadata for ActivityPub federation. No authorization required. ```bash curl -s "https://codeberg.org/api/v1/nodeinfo" ``` -------------------------------- ### Get user information Source: https://context7.com/forgejo/forgejo/llms.txt Retrieves public profile information for a given user by their username. No authentication is required. ```bash curl -s "https://codeberg.org/api/v1/users/alice" ```