### Start PostgreSQL and MinIO Containers for Integration Tests Source: https://github.com/go-gitea/gitea/blob/main/docs/testing.md Starts throwaway PostgreSQL and MinIO containers for integration tests. Press Ctrl-C to stop and remove them. ```bash docker run -e "POSTGRES_DB=test" -e "POSTGRES_USER=postgres" -e "POSTGRES_PASSWORD=postgres" -p 5432:5432 --rm --name pgsql postgres:latest docker run --rm -p 9000:9000 -e MINIO_ROOT_USER=123456 -e MINIO_ROOT_PASSWORD=12345678 --name minio bitnamilegacy/minio:2023.8.31 ``` -------------------------------- ### Start MySQL Container for Integration Tests Source: https://github.com/go-gitea/gitea/blob/main/docs/testing.md Starts a throwaway MySQL database container for integration tests. Press Ctrl-C to stop and remove it. ```bash docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:latest ``` -------------------------------- ### Start MSSQL Container for Integration Tests Source: https://github.com/go-gitea/gitea/blob/main/docs/testing.md Starts a throwaway MSSQL database container for integration tests. Press Ctrl-C to stop and remove it. ```bash docker run -e "ACCEPT_EULA=Y" -e "MSSQL_PID=Standard" -e "SA_PASSWORD=MwantsaSecurePassword1" -p 1433:1433 --rm --name mssql microsoft/mssql-server-linux:latest ``` -------------------------------- ### Install jsonnet-bundler and jsonnet Source: https://github.com/go-gitea/gitea/blob/main/contrib/grafana-monitoring-mixin/README.md Installs the necessary tools for managing jsonnet dependencies and processing jsonnet files. ```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 ``` -------------------------------- ### Install mixtool and jsonnetfmt Source: https://github.com/go-gitea/gitea/blob/main/contrib/grafana-monitoring-mixin/README.md Installs tools for linting and formatting jsonnet files, essential for maintaining code quality. ```bash go install github.com/monitoring-mixins/mixtool/cmd/mixtool@latest go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest ``` -------------------------------- ### Install Gitea Dependencies Source: https://github.com/go-gitea/gitea/blob/main/docs/build-setup.md Run this make command to fetch all necessary dependencies for building and testing Gitea. Alternatively, use group-specific commands like `make deps-frontend`. ```bash make deps ``` -------------------------------- ### Conventional Commits Examples Source: https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md Examples demonstrating the application of Conventional Commits for various types of changes. ```text fix(web): prevent avatar upload crash on empty file feat(api): add pagination to repo hooks list enhance(repo): improve diff toolbar spacing ci(workflows): lint PR titles in CI ``` -------------------------------- ### Gitea PR Merge Queue Example Source: https://github.com/go-gitea/gitea/blob/main/docs/community-governance.md This is an example of how PRs are ordered in the merge queue when they have the 'reviewed/wait-merge' label. It shows the sorting criteria used. ```bash https://github.com/go-gitea/gitea/pulls?q=is%3Apr+label%3Areviewed%2Fwait-merge+sort%3Acreated-asc+is%3Aopen ``` -------------------------------- ### Package Import Alias Example Source: https://github.com/go-gitea/gitea/blob/main/docs/guidelines-backend.md Demonstrates how to use snake_case import aliases to disambiguate packages with shared names from different layers. ```go import user_service "gitea.dev/services/user" ``` -------------------------------- ### Run Integration Tests Source: https://github.com/go-gitea/gitea/blob/main/docs/testing.md Execute integration tests against a real database. Git LFS must be installed. The database is selected via GITEA_TEST_DATABASE; defaults to SQLite. ```bash make test-integration ``` -------------------------------- ### Run Go Build Tools Source: https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md Run `make fmt` before committing to ensure code conforms to Gitea's styleguide. For linting and testing, use `make lint` or specific targets like `make lint-backend`. ```bash make fmt ``` ```bash make lint ``` ```bash make lint-backend ``` ```bash make lint-frontend ``` -------------------------------- ### Build Windows Binary with Bindata and Gogit Source: https://github.com/go-gitea/gitea/blob/main/docs/build-source.md Builds a Windows binary of Gitea, including all assets and using the 'gogit' tag for experimental Git command variants. This is useful for resolving some Windows-specific performance issues. ```bash GOOS=windows TAGS="bindata gogit" make build ``` -------------------------------- ### Build Gitea for Development Source: https://github.com/go-gitea/gitea/blob/main/docs/development.md Run this command to build Gitea for local development. No special build tags are required. ```bash make build ``` -------------------------------- ### Python Code Block Example Source: https://github.com/go-gitea/gitea/blob/main/modules/markup/jupyter/jupyter-test.ipynb A simple Python code block example. This is a standard way to include executable code within documentation or notebooks. ```python print('code block') ``` -------------------------------- ### Empty Permissions Mapping Example Source: https://github.com/go-gitea/gitea/blob/main/services/actions/token_permission_design.md Illustrates the explicit definition of an empty permissions block in a workflow, which results in revoking all token permissions for the job. ```yaml permissions: {} ``` -------------------------------- ### Create and push development tag Source: https://github.com/go-gitea/gitea/blob/main/docs/release-management.md Used for big version releases to initiate the build process. ```bash git tag -s -F release.notes vMAJOR.MINOR.0-dev ``` ```bash git push origin vMAJOR.MINOR.0-dev ``` -------------------------------- ### Cross Build for Linux ARM64 Source: https://github.com/go-gitea/gitea/blob/main/docs/build-source.md Cross-builds Gitea for a Linux ARM64 architecture using Golang's toolchain variables. Ensure you have the necessary cross-compilation tools installed. ```bash GOOS=linux GOARCH=arm64 TAGS="bindata" make build ``` -------------------------------- ### XORM SyncWithOptions for Partial Migrations Source: https://github.com/go-gitea/gitea/blob/main/docs/guidelines-backend.md Explains the necessity of using SyncWithOptions(IgnoreDrop...) for partial table migrations to avoid unintended data loss. ```go // Partial table migrations must use SyncWithOptions(IgnoreDrop...) // rather than a plain Sync. ``` -------------------------------- ### Read-Only Fomantic Dropdown HTML Source: https://github.com/go-gitea/gitea/blob/main/web_src/js/modules/fomantic/aria.md Example of a read-only Fomantic UI dropdown structure. Note that focus management for ARIA active descendant might be imperfect when the focus is on the main element. ```html ``` -------------------------------- ### Run Integration Tests with PostgreSQL and MinIO Source: https://github.com/go-gitea/gitea/blob/main/docs/testing.md Configure and run integration tests against a PostgreSQL database with MinIO for object storage. Ensure containers are running. ```bash GITEA_TEST_DATABASE=pgsql TEST_MINIO_ENDPOINT=localhost:9000 TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=postgres TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-integration ``` -------------------------------- ### Searchable Fomantic Dropdown HTML Source: https://github.com/go-gitea/gitea/blob/main/web_src/js/modules/fomantic/aria.md Example of a Fomantic UI dropdown with a search input. This structure is suitable for combobox-like behavior where users can type to filter options. Focus is on the search input. ```html ``` -------------------------------- ### Run Single Backend Unit Test Source: https://github.com/go-gitea/gitea/blob/main/docs/testing.md Run a specific backend unit test using `go test` with the `-run` flag or the `make` command with the `#` selector. ```bash go test -run '^TestName$' ./modulepath/ ``` ```bash make test-backend#TestName ``` -------------------------------- ### Example Workflow Permissions in YAML Source: https://github.com/go-gitea/gitea/blob/main/services/actions/token_permission_design.md Demonstrates how to define granular permissions within a Gitea Actions workflow YAML file. It shows the mapping of the 'contents' scope to 'Code' and 'Releases', and how granular scopes take priority. ```yaml permissions: contents: write code: read ``` -------------------------------- ### Run Integration Tests with MySQL Source: https://github.com/go-gitea/gitea/blob/main/docs/testing.md Configure and run integration tests against a MySQL database. Ensure the MySQL container is running. ```bash GITEA_TEST_DATABASE=mysql TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root TEST_MYSQL_PASSWORD='' make test-integration ```