diff --git a/.air.toml b/.air.toml index d13f8c4f99..de97bd8b29 100644 --- a/.air.toml +++ b/.air.toml @@ -8,6 +8,15 @@ delay = 1000 include_ext = ["go", "tmpl"] include_file = ["main.go"] include_dir = ["cmd", "models", "modules", "options", "routers", "services"] -exclude_dir = ["modules/git/tests", "services/gitdiff/testdata", "modules/avatar/testdata", "models/fixtures", "models/migrations/fixtures", "modules/migration/file_format_testdata", "modules/avatar/identicon/testdata"] +exclude_dir = [ + "models/fixtures", + "models/migrations/fixtures", + "modules/avatar/identicon/testdata", + "modules/avatar/testdata", + "modules/git/tests", + "modules/migration/file_format_testdata", + "routers/private/tests", + "services/gitdiff/testdata", +] exclude_regex = ["_test.go$", "_gen.go$"] stop_on_error = true diff --git a/.deadcode-out b/.deadcode-out index 3290e6102a..940551da04 100644 --- a/.deadcode-out +++ b/.deadcode-out @@ -84,7 +84,6 @@ package "code.gitea.io/gitea/models/repo" func (*releaseSorter).Swap func SortReleases func FindReposMapByIDs - func RepositoryListOfMap func (SearchOrderBy).String func IsErrTopicNotExist func (ErrTopicNotExist).Error @@ -162,9 +161,6 @@ package "code.gitea.io/gitea/modules/cache" package "code.gitea.io/gitea/modules/charset" func (*BreakWriter).Write -package "code.gitea.io/gitea/modules/context" - func GetPrivateContext - package "code.gitea.io/gitea/modules/emoji" func ReplaceCodes @@ -181,6 +177,7 @@ package "code.gitea.io/gitea/modules/git" func (ErrExecTimeout).Error func (ErrUnsupportedVersion).Error func SetUpdateHook + func GetObjectFormatOfRepo func openRepositoryWithDefaultContext func IsTagExist func ToEntryMode @@ -192,6 +189,7 @@ package "code.gitea.io/gitea/modules/gitgraph" package "code.gitea.io/gitea/modules/gitrepo" func GetBranchCommitID + func GetWikiDefaultBranch package "code.gitea.io/gitea/modules/graceful" func (*Manager).TerminateContext @@ -224,7 +222,6 @@ package "code.gitea.io/gitea/modules/markup/markdown" func IsSummary func IsTaskCheckBoxListItem func IsIcon - func IsColorPreview func RenderRawString package "code.gitea.io/gitea/modules/markup/markdown/math" @@ -274,13 +271,19 @@ package "code.gitea.io/gitea/modules/sync" package "code.gitea.io/gitea/modules/testlogger" func (*testLoggerWriterCloser).pushT - func (*testLoggerWriterCloser).Write + func (*testLoggerWriterCloser).Log + func (*testLoggerWriterCloser).recordError + func (*testLoggerWriterCloser).printMsg func (*testLoggerWriterCloser).popT - func (*testLoggerWriterCloser).Close func (*testLoggerWriterCloser).Reset func PrintCurrentTest func Printf func NewTestLoggerWriter + func (*TestLogEventWriter).Base + func (*TestLogEventWriter).GetLevel + func (*TestLogEventWriter).GetWriterName + func (*TestLogEventWriter).GetWriterType + func (*TestLogEventWriter).Run package "code.gitea.io/gitea/modules/timeutil" func GetExecutableModTime @@ -292,11 +295,9 @@ package "code.gitea.io/gitea/modules/translation" func (MockLocale).TrString func (MockLocale).Tr func (MockLocale).TrN + func (MockLocale).TrSize func (MockLocale).PrettyNumber -package "code.gitea.io/gitea/modules/util" - func UnsafeStringToBytes - package "code.gitea.io/gitea/modules/util/filebuffer" func CreateFromReader @@ -315,6 +316,9 @@ package "code.gitea.io/gitea/routers/web/org" func getActionIssues func UpdateIssueProject +package "code.gitea.io/gitea/services/context" + func GetPrivateContext + package "code.gitea.io/gitea/services/convert" func ToSecret @@ -326,7 +330,6 @@ package "code.gitea.io/gitea/services/pull" package "code.gitea.io/gitea/services/repository" func IsErrForkAlreadyExist - func UpdateRepositoryUnits package "code.gitea.io/gitea/services/repository/archiver" func ArchiveRepository diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9e290fb6a5..1b1b66c7dd 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,11 +4,13 @@ "features": { // installs nodejs into container "ghcr.io/devcontainers/features/node:1": { - "version":"20" + "version": "20" }, "ghcr.io/devcontainers/features/git-lfs:1.1.0": {}, "ghcr.io/devcontainers-contrib/features/poetry:2": {}, - "ghcr.io/devcontainers/features/python:1": {} + "ghcr.io/devcontainers/features/python:1": { + "version": "3.12" + } }, "customizations": { "vscode": { @@ -22,7 +24,7 @@ "DavidAnson.vscode-markdownlint", "Vue.volar", "ms-azuretools.vscode-docker", - "zixuanchen.vitest-explorer", + "vitest.explorer", "qwtel.sqlite-viewer", "GitHub.vscode-pull-request-github" ] diff --git a/.dockerignore b/.dockerignore index 80cbeb040c..4c14a94620 100644 --- a/.dockerignore +++ b/.dockerignore @@ -14,7 +14,7 @@ _test # MS VSCode .vscode -__debug_bin +__debug_bin* # Architecture specific extensions/prefixes *.[568vq] @@ -62,7 +62,6 @@ cpu.out /data /indexers /log -/public/img/avatar /tests/integration/gitea-integration-* /tests/integration/indexers-* /tests/e2e/gitea-e2e-* @@ -71,13 +70,13 @@ cpu.out /tests/e2e/test-artifacts /tests/e2e/test-snapshots /tests/*.ini -/node_modules /yarn.lock /yarn-error.log /npm-debug.log* /public/assets/js /public/assets/css /public/assets/fonts +/public/assets/img/avatar /public/assets/img/webpack /vendor /web_src/fomantic/node_modules diff --git a/.eslintrc.yaml b/.eslintrc.yaml index ed0309dbea..99ce2e97d6 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -12,6 +12,7 @@ plugins: - "@eslint-community/eslint-plugin-eslint-comments" - "@stylistic/eslint-plugin-js" - eslint-plugin-array-func + - eslint-plugin-github - eslint-plugin-i - eslint-plugin-jquery - eslint-plugin-no-jquery @@ -41,10 +42,6 @@ overrides: worker: true rules: no-restricted-globals: [2, addEventListener, blur, close, closed, confirm, defaultStatus, defaultstatus, error, event, external, find, focus, frameElement, frames, history, innerHeight, innerWidth, isFinite, isNaN, length, locationbar, menubar, moveBy, moveTo, name, onblur, onerror, onfocus, onload, onresize, onunload, open, opener, opera, outerHeight, outerWidth, pageXOffset, pageYOffset, parent, print, removeEventListener, resizeBy, resizeTo, screen, screenLeft, screenTop, screenX, screenY, scroll, scrollbars, scrollBy, scrollTo, scrollX, scrollY, status, statusbar, stop, toolbar, top] - - files: ["build/generate-images.js"] - rules: - i/no-unresolved: [0] - i/no-extraneous-dependencies: [0] - files: ["*.config.*"] rules: i/no-unused-modules: [0] @@ -122,7 +119,7 @@ rules: "@stylistic/js/arrow-spacing": [2, {before: true, after: true}] "@stylistic/js/block-spacing": [0] "@stylistic/js/brace-style": [2, 1tbs, {allowSingleLine: true}] - "@stylistic/js/comma-dangle": [2, only-multiline] + "@stylistic/js/comma-dangle": [2, always-multiline] "@stylistic/js/comma-spacing": [2, {before: false, after: true}] "@stylistic/js/comma-style": [2, last] "@stylistic/js/computed-property-spacing": [2, never] @@ -170,7 +167,7 @@ rules: "@stylistic/js/semi-spacing": [2, {before: false, after: true}] "@stylistic/js/semi-style": [2, last] "@stylistic/js/space-before-blocks": [2, always] - "@stylistic/js/space-before-function-paren": [0] + "@stylistic/js/space-before-function-paren": [2, {anonymous: ignore, named: never, asyncArrow: always}] "@stylistic/js/space-in-parens": [2, never] "@stylistic/js/space-infix-ops": [2] "@stylistic/js/space-unary-ops": [2] @@ -209,6 +206,29 @@ rules: func-names: [0] func-style: [0] getter-return: [2] + github/a11y-aria-label-is-well-formatted: [0] + github/a11y-no-title-attribute: [0] + github/a11y-no-visually-hidden-interactive-element: [0] + github/a11y-role-supports-aria-props: [0] + github/a11y-svg-has-accessible-name: [0] + github/array-foreach: [0] + github/async-currenttarget: [2] + github/async-preventdefault: [2] + github/authenticity-token: [0] + github/get-attribute: [0] + github/js-class-name: [0] + github/no-blur: [0] + github/no-d-none: [0] + github/no-dataset: [2] + github/no-dynamic-script-tag: [2] + github/no-implicit-buggy-globals: [2] + github/no-inner-html: [0] + github/no-innerText: [2] + github/no-then: [2] + github/no-useless-passive: [2] + github/prefer-observers: [2] + github/require-passive-events: [2] + github/unescaped-html-literal: [0] grouped-accessor-pairs: [2] guard-for-in: [0] id-blacklist: [0] @@ -259,20 +279,20 @@ rules: i/unambiguous: [0] init-declarations: [0] jquery/no-ajax-events: [2] - jquery/no-ajax: [0] + jquery/no-ajax: [2] jquery/no-animate: [2] - jquery/no-attr: [0] + jquery/no-attr: [2] jquery/no-bind: [2] jquery/no-class: [0] jquery/no-clone: [2] jquery/no-closest: [0] - jquery/no-css: [0] + jquery/no-css: [2] jquery/no-data: [0] jquery/no-deferred: [2] jquery/no-delegate: [2] jquery/no-each: [0] jquery/no-extend: [2] - jquery/no-fade: [0] + jquery/no-fade: [2] jquery/no-filter: [0] jquery/no-find: [0] jquery/no-global-eval: [2] @@ -283,15 +303,15 @@ rules: jquery/no-in-array: [2] jquery/no-is-array: [2] jquery/no-is-function: [2] - jquery/no-is: [0] + jquery/no-is: [2] jquery/no-load: [2] - jquery/no-map: [0] + jquery/no-map: [2] jquery/no-merge: [2] jquery/no-param: [2] jquery/no-parent: [0] jquery/no-parents: [0] jquery/no-parse-html: [2] - jquery/no-prop: [0] + jquery/no-prop: [2] jquery/no-proxy: [2] jquery/no-ready: [2] jquery/no-serialize: [2] @@ -372,12 +392,12 @@ rules: no-irregular-whitespace: [2] no-iterator: [2] no-jquery/no-ajax-events: [2] - no-jquery/no-ajax: [0] + no-jquery/no-ajax: [2] no-jquery/no-and-self: [2] no-jquery/no-animate-toggle: [2] no-jquery/no-animate: [2] - no-jquery/no-append-html: [0] - no-jquery/no-attr: [0] + no-jquery/no-append-html: [2] + no-jquery/no-attr: [2] no-jquery/no-bind: [2] no-jquery/no-box-model: [2] no-jquery/no-browser: [2] @@ -389,7 +409,7 @@ rules: no-jquery/no-constructor-attributes: [2] no-jquery/no-contains: [2] no-jquery/no-context-prop: [2] - no-jquery/no-css: [0] + no-jquery/no-css: [2] no-jquery/no-data: [0] no-jquery/no-deferred: [2] no-jquery/no-delegate: [2] @@ -420,14 +440,14 @@ rules: no-jquery/no-is-numeric: [2] no-jquery/no-is-plain-object: [2] no-jquery/no-is-window: [2] - no-jquery/no-is: [0] + no-jquery/no-is: [2] no-jquery/no-jquery-constructor: [0] no-jquery/no-live: [2] no-jquery/no-load-shorthand: [2] no-jquery/no-load: [2] no-jquery/no-map-collection: [0] no-jquery/no-map-util: [2] - no-jquery/no-map: [0] + no-jquery/no-map: [2] no-jquery/no-merge: [2] no-jquery/no-node-name: [2] no-jquery/no-noop: [2] @@ -442,7 +462,7 @@ rules: no-jquery/no-parse-html: [2] no-jquery/no-parse-json: [2] no-jquery/no-parse-xml: [2] - no-jquery/no-prop: [0] + no-jquery/no-prop: [2] no-jquery/no-proxy: [2] no-jquery/no-ready-shorthand: [2] no-jquery/no-ready: [2] @@ -463,7 +483,7 @@ rules: no-jquery/no-visibility: [2] no-jquery/no-when: [2] no-jquery/no-wrap: [2] - no-jquery/variable-pattern: [0] + no-jquery/variable-pattern: [2] no-label-var: [2] no-labels: [0] # handled by no-restricted-syntax no-lone-blocks: [2] diff --git a/.forgejo/cascading-pr-end-to-end b/.forgejo/cascading-pr-end-to-end index 975888b245..d7a6b46b48 100755 --- a/.forgejo/cascading-pr-end-to-end +++ b/.forgejo/cascading-pr-end-to-end @@ -5,17 +5,29 @@ set -ex end_to_end=$1 end_to_end_pr=$2 forgejo=$3 -forgejo_pr=$4 +forgejo_pr_or_ref=$4 + +cd $forgejo +full_version=$(make show-version-full) +minor_version=$(make show-version-minor) -head_url=$(jq --raw-output .head.repo.html_url < $forgejo_pr) -test "$head_url" != null -branch=$(jq --raw-output .head.ref < $forgejo_pr) -test "$branch" != null cd $end_to_end -echo $head_url $branch 7.0.0+0-gitea-1.22.0 > forgejo/sources/1.22 + +if ! test -f forgejo/sources/$minor_version ; then + echo "FAIL: forgejo/sources/$minor_version does not exist in the end-to-end repository" + false +fi + date > last-upgrade -base_url=$(jq --raw-output .base.repo.html_url < $forgejo_pr) -test "$base_url" != null -test "$GITHUB_RUN_NUMBER" -echo $base_url/actions/runs/$GITHUB_RUN_NUMBER/artifacts/forgejo > forgejo/binary-url +if test -f "$forgejo_pr_or_ref" ; then + forgejo_pr=$forgejo_pr_or_ref + head_url=$(jq --raw-output .head.repo.html_url < $forgejo_pr) + test "$head_url" != null + branch=$(jq --raw-output .head.ref < $forgejo_pr) + test "$branch" != null + echo $head_url $branch $full_version > forgejo/sources/$minor_version +else + forgejo_ref=$forgejo_pr_or_ref + echo $GITHUB_SERVER_URL/$GITHUB_REPOSITORY ${forgejo_ref#refs/heads/} $full_version > forgejo/sources/$minor_version +fi diff --git a/.forgejo/cascading-release-end-to-end b/.forgejo/cascading-release-end-to-end index 7b43c89ed8..08ad8a4431 100755 --- a/.forgejo/cascading-release-end-to-end +++ b/.forgejo/cascading-release-end-to-end @@ -9,4 +9,14 @@ forgejo_ref=$4 cd $end_to_end date > last-upgrade -echo $FORGEJO_BINARY > forgejo/binary-url +organizations=lib/ORGANIZATIONS +if ! test -f $organizations ; then + echo "$organizations file not found" + false +fi +# +# do not include forgejo-experimental so that 7.0-test is found +# in forgejo-integration where it was just built instead of +# forgejo-experimental which was published by the previous build +# +echo forgejo forgejo-integration > $organizations diff --git a/.forgejo/workflows/backport.yml b/.forgejo/workflows/backport.yml new file mode 100644 index 0000000000..da064feff3 --- /dev/null +++ b/.forgejo/workflows/backport.yml @@ -0,0 +1,83 @@ +# Copyright 2024 The Forgejo Authors +# SPDX-License-Identifier: MIT +# +# To modify this workflow: +# +# - change pull_request_target: to pull_request: +# so that it runs from a pull request instead of the default branch +# +# - push it to the wip-ci-backport branch on the forgejo repository +# otherwise it will not have access to the secrets required to push +# the PR +# +# - open a pull request targetting wip-ci-backport that includes a change +# that can be backported without conflict in v1.21 and set the +# `backport/v1.21` label. +# +# - once it works, open a pull request for the sake of keeping track +# of the change even if the PR won't run it because it will use +# whatever is in the default branch instead +# +# - after it is merged, double check it works by setting a +# `backport/v1.21` label on a merged pull request that can be backported +# without conflict. +# +on: + pull_request_target: + types: + - closed + - labeled + +jobs: + backporting: + if: > + !startsWith(vars.ROLE, 'forgejo-') && ( + github.event.pull_request.merged + && + contains(toJSON(github.event.pull_request.labels), 'backport/v') + ) + runs-on: docker + container: + image: 'docker.io/node:20-bookworm' + steps: + - name: event info + run: | + cat <<'EOF' + ${{ toJSON(github) }} + EOF + - name: Fetch labels + id: fetch-labels + shell: bash + run: | + set -x + echo "Labels retrieved below" + export DEBIAN_FRONTEND=noninteractive + apt-get update -qq + apt-get -q install -qq -y jq + filtered_labels=$(echo "$LABELS" | jq -c 'map(select(.name | startswith("backport/v")))') + echo "FILTERED_LABELS=${filtered_labels}" >> $GITHUB_ENV + env: + LABELS: ${{ toJSON(github.event.pull_request.labels) }} + - name: Extract targets + id: extract-targets + shell: bash + run: | + set -x + targets="$(echo $FILTERED_LABELS | jq -c '[.[] | .name | sub("backport/"; "")]')" + echo "targets=$(echo $targets)" >> $GITHUB_OUTPUT + + - name: Printing info + shell: bash + run: | + echo "targets: ${{ steps.extract-targets.outputs.targets }}" + echo "target-branch: ${{ fromJSON(steps.extract-targets.outputs.targets)[0] }}" + echo "pull-request: ${{ github.event.pull_request.url }}" + + - uses: https://code.forgejo.org/forgejo/git-backporting@b2554a678d5ea2814f0df3abad2ac4fcdee2d81f + with: + target-branch: ${{ fromJSON(steps.extract-targets.outputs.targets)[0] }}/forgejo + strategy: ort + strategy-option: find-renames + cherry-pick-options: -x + auth: ${{ secrets.BACKPORT_TOKEN }} + pull-request: ${{ github.event.pull_request.url }} diff --git a/.forgejo/workflows/build-release-integration.yml b/.forgejo/workflows/build-release-integration.yml index cdcbf32627..610b8f0520 100644 --- a/.forgejo/workflows/build-release-integration.yml +++ b/.forgejo/workflows/build-release-integration.yml @@ -9,6 +9,8 @@ on: - docker/** - .forgejo/workflows/build-release.yml - .forgejo/workflows/build-release-integration.yml + branches-ignore: + - renovate/** pull_request: paths: - Makefile @@ -110,7 +112,7 @@ jobs: # # Push a commit to a branch that triggers the build of a test release # - version=forgejo-test + version=1.2-test ( git clone $url/root/forgejo /tmp/forgejo cd /tmp/forgejo diff --git a/.forgejo/workflows/build-release.yml b/.forgejo/workflows/build-release.yml index b2f3757980..f8cd69850c 100644 --- a/.forgejo/workflows/build-release.yml +++ b/.forgejo/workflows/build-release.yml @@ -14,8 +14,6 @@ # secrets.CASCADE_DESTINATION_TOKEN: scope read:user, write:repository, write:issue # vars.CASCADE_DESTINATION_DOER: forgejo-ci # -name: Build release - on: push: tags: 'v[0-9]+.[0-9]+.*' @@ -30,6 +28,8 @@ jobs: if: vars.ROLE == 'forgejo-integration' || github.repository_owner == 'root' steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Sanitize the name of the repository id: repository @@ -43,7 +43,7 @@ jobs: - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" check-latest: true - name: version from ref @@ -53,8 +53,12 @@ jobs: set -x ref="${{ github.ref }}" if [[ $ref =~ ^refs/heads/ ]] ; then - version=${ref#refs/heads/} - version=${version%/forgejo}-test + if test "$ref" = "refs/heads/forgejo" ; then + version=$(git tag -l --sort=version:refname --merged | grep -v -e '-test$' | tail -1 | sed -E -e 's/^(v[0-9]+\.[0-9]+).*/\1/')-test + else + version=${ref#refs/heads/} + version=${version%/forgejo}-test + fi override=true fi if [[ $ref =~ ^refs/tags/ ]] ; then @@ -66,6 +70,7 @@ jobs: exit 1 fi version=${version#v} + git describe --exclude '*-test' --tags --always echo "sha=${{ github.sha }}" >> "$GITHUB_OUTPUT" echo "version=$version" >> "$GITHUB_OUTPUT" echo "override=$override" >> "$GITHUB_OUTPUT" @@ -81,6 +86,18 @@ jobs: ENDVAR EOF + - name: cache node_modules + id: node + uses: https://code.forgejo.org/actions/cache@v3 + with: + path: | + node_modules + key: node-${{ steps.release-info.outputs.version }} + + - name: skip if node cache hit + if: steps.node.outputs.cache-hit != 'true' + run: echo no hit + - name: Build sources run: | set -x @@ -177,7 +194,7 @@ jobs: - name: end-to-end tests if: ${{ secrets.TOKEN != '' && vars.ROLE == 'forgejo-integration' }} - uses: https://code.forgejo.org/actions/cascading-pr@v1 + uses: https://code.forgejo.org/actions/cascading-pr@v2 with: origin-url: ${{ env.GITHUB_SERVER_URL }} origin-repo: ${{ github.repository }} @@ -186,8 +203,28 @@ jobs: destination-url: https://code.forgejo.org destination-fork-repo: ${{ vars.CASCADE_DESTINATION_DOER }}/end-to-end destination-repo: forgejo/end-to-end - destination-branch: forgejo-pr + destination-branch: main destination-token: ${{ secrets.CASCADE_DESTINATION_TOKEN }} update: .forgejo/cascading-release-end-to-end - env: - FORGEJO_BINARY: "${{ env.GITHUB_SERVER_URL }}/${{ github.repository }}/releases/download/v${{ steps.release-info.outputs.version }}/forgejo-${{ steps.release-info.outputs.version }}-linux-amd64" + + - name: copy to experimental + if: vars.ROLE == 'forgejo-integration' && secrets.TOKEN != '' + run: | + if test "${{ vars.VERBOSE }}" = true ; then + set -x + fi + tag=v${{ steps.release-info.outputs.version }} + url=https://any:${{ secrets.TOKEN }}@codeberg.org + if test "${{ steps.release-info.outputs.override }}" = "true" ; then + curl -sS -X DELETE $url/api/v1/repos/forgejo-experimental/forgejo/releases/tags/$tag > /dev/null + curl -sS -X DELETE $url/api/v1/repos/forgejo-experimental/forgejo/tags/$tag > /dev/null + fi + # actions/checkout@v3 sets http.https://codeberg.org/.extraheader with the automatic token. + # Get rid of it so it does not prevent using the token that has write permissions + git config --local --unset http.https://codeberg.org/.extraheader + if test -f .git/shallow ; then + echo "unexptected .git/shallow file is present" + echo "it suggests a checkout --depth X was used which may prevent pushing the commit" + echo "it happens when actions/checkout is called without depth: 0" + fi + git push $url/forgejo-experimental/forgejo ${{ steps.release-info.outputs.sha }}:refs/tags/$tag diff --git a/.forgejo/workflows/cascade-setup-end-to-end.yml b/.forgejo/workflows/cascade-setup-end-to-end.yml index 235211f18a..dcca2404d9 100644 --- a/.forgejo/workflows/cascade-setup-end-to-end.yml +++ b/.forgejo/workflows/cascade-setup-end-to-end.yml @@ -1,5 +1,23 @@ +# Copyright 2024 The Forgejo Authors # SPDX-License-Identifier: MIT +# +# To modify this workflow: +# +# - push it to the wip-ci-end-to-end branch on the forgejo repository +# otherwise it will not have access to the secrets required to push +# the cascading PR +# +# - once it works, open a pull request for the sake of keeping track +# of the change even if the PR won't run it because it will use +# whatever is in the default branch instead +# +# - after it is merged, double check it works by setting the +# run-end-to-end-test on a pull request (any pull request will doe +# on: + push: + branches: + - 'wip-ci-end-to-end' pull_request_target: types: - labeled @@ -20,58 +38,37 @@ jobs: cat <<'EOF' ${{ toJSON(github.event.pull_request.labels.*.name) }} EOF - - build: - if: ${{ !startsWith(vars.ROLE, 'forgejo-') && github.event.action == 'label_updated' && contains(github.event.pull_request.labels.*.name, 'run-end-to-end-tests') }} - runs-on: docker - container: - image: 'docker.io/node:20-bookworm' - steps: - - uses: https://code.forgejo.org/actions/checkout@v3 - with: - fetch-depth: '0' - show-progress: 'false' - - name: adduser forgejo - run: | - git config --add safe.directory '*' - git config user.email "you@example.com" - git config user.name "Your Name" - adduser --quiet --comment forgejo --disabled-password forgejo - chown -R forgejo:forgejo . - - uses: https://code.forgejo.org/actions/setup-go@v4 - with: - go-version: "1.21" - - name: make deps-backend - run: | - su forgejo -c 'make deps-backend' - - name: make forgejo - run: | - su forgejo -c 'make generate-backend static-executable && ln gitea forgejo' - env: - TAGS: bindata sqlite sqlite_unlock_notify - - uses: actions/upload-artifact@v3 - with: - name: forgejo - path: forgejo + cat <<'EOF' + ${{ toJSON(github.event) }} + EOF cascade: - if: ${{ !startsWith(vars.ROLE, 'forgejo-') && github.event.action == 'label_updated' && contains(github.event.pull_request.labels.*.name, 'run-end-to-end-tests') }} - needs: [build] + if: > + !startsWith(vars.ROLE, 'forgejo-') && ( + github.event_name == 'push' || + ( + github.event.action == 'label_updated' && contains(github.event.pull_request.labels.*.name, 'run-end-to-end-tests') + ) + ) runs-on: docker container: image: node:20-bookworm steps: - uses: actions/checkout@v4 - - uses: actions/cascading-pr@v1 + with: + fetch-depth: '0' + show-progress: 'false' + - uses: actions/cascading-pr@v2 with: origin-url: ${{ env.GITHUB_SERVER_URL }} origin-repo: ${{ github.repository }} origin-token: ${{ secrets.END_TO_END_CASCADING_PR_ORIGIN }} origin-pr: ${{ github.event.pull_request.number }} + origin-ref: ${{ github.event_name == 'push' && github.event.ref || '' }} destination-url: https://code.forgejo.org destination-fork-repo: cascading-pr/end-to-end destination-repo: forgejo/end-to-end - destination-branch: forgejo-pr + destination-branch: main destination-token: ${{ secrets.END_TO_END_CASCADING_PR_DESTINATION }} close-merge: true update: .forgejo/cascading-pr-end-to-end diff --git a/.forgejo/workflows/e2e.yml b/.forgejo/workflows/e2e.yml index 2104f6a067..c1321b0a8e 100644 --- a/.forgejo/workflows/e2e.yml +++ b/.forgejo/workflows/e2e.yml @@ -17,7 +17,7 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v4 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "~1.21" + go-version: "1.22" check-latest: true - run: | apt-get -qq update diff --git a/.forgejo/workflows/publish-release.yml b/.forgejo/workflows/publish-release.yml index 1afa941952..674c1c2704 100644 --- a/.forgejo/workflows/publish-release.yml +++ b/.forgejo/workflows/publish-release.yml @@ -42,16 +42,19 @@ jobs: - uses: actions/checkout@v3 - name: copy & sign - uses: https://code.forgejo.org/forgejo/forgejo-build-publish/publish@v1 + uses: https://code.forgejo.org/forgejo/forgejo-build-publish/publish@v4 with: - forgejo: ${{ vars.FORGEJO }} + from-forgejo: ${{ vars.FORGEJO }} + to-forgejo: ${{ vars.FORGEJO }} from-owner: ${{ vars.FROM_OWNER }} to-owner: ${{ vars.TO_OWNER }} repo: ${{ vars.REPO }} - ref-name: ${{ github.ref_name }} release-notes: "See https://codeberg.org/forgejo/forgejo/src/branch/forgejo/RELEASE-NOTES.md#{ANCHOR}" - doer: ${{ vars.DOER }} - token: ${{ secrets.TOKEN }} + ref-name: ${{ github.ref_name }} + sha: ${{ github.sha }} + from-token: ${{ secrets.TOKEN }} + to-doer: ${{ vars.DOER }} + to-token: ${{ secrets.TOKEN }} gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }} verbose: ${{ vars.VERBOSE }} @@ -61,7 +64,7 @@ jobs: if: vars.ROLE == 'forgejo-experimental' && secrets.OVH_APP_KEY != '' uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" check-latest: true - name: update the _release.experimental DNS record if: vars.ROLE == 'forgejo-experimental' && secrets.OVH_APP_KEY != '' diff --git a/.forgejo/workflows/renovate.yml b/.forgejo/workflows/renovate.yml new file mode 100644 index 0000000000..a9687db81a --- /dev/null +++ b/.forgejo/workflows/renovate.yml @@ -0,0 +1,61 @@ +# +# The 2am run will rebase what needs rebasing & trigger the CI +# The 4am run will merge one of them +# +# These times are chosen to minimize the likelyhood that another PR +# is merged at the same time. This would not be necessary if automerge +# worked but as of 30 March 2024 it does not. +# +name: renovate + +on: + push: + branches: + - 'renovate/**' # self-test updates + schedule: + - cron: '0 2,4 * * *' + +env: + RENOVATE_DRY_RUN: ${{ (github.event_name != 'schedule' && github.ref_name != github.event.repository.default_branch) && 'full' || '' }} + RENOVATE_REPOSITORIES: ${{ github.repository }} + +jobs: + renovate: + if: ${{ secrets.RENOVATE_TOKEN != '' }} + + runs-on: docker + container: + image: ghcr.io/visualon/renovate:37.278.0 + + steps: + - uses: https://code.forgejo.org/actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: | + .tmp/cache/renovate/repository + key: repo-cache-${{ github.run_id }} + restore-keys: | + repo-cache- + + - run: renovate + env: + GITHUB_COM_TOKEN: ${{ secrets.RENOVATE_GITHUB_COM_TOKEN }} + LOG_LEVEL: debug + RENOVATE_BASE_DIR: ${{ github.workspace }}/.tmp + RENOVATE_ENDPOINT: ${{ github.server_url }} + RENOVATE_PLATFORM: gitea + RENOVATE_REPOSITORY_CACHE: 'enabled' + RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }} + RENOVATE_GIT_AUTHOR: 'Renovate Bot ' + + GIT_AUTHOR_NAME: 'Renovate Bot' + GIT_AUTHOR_EMAIL: 'forgejo-renovate-action@forgejo.org' + GIT_COMMITTER_NAME: 'Renovate Bot' + GIT_COMMITTER_EMAIL: 'forgejo-renovate-action@forgejo.org' + + - name: Save renovate repo cache + if: always() && env.RENOVATE_DRY_RUN == 'true' + uses: https://code.forgejo.org/actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: | + .tmp/cache/renovate/repository + key: repo-cache-${{ github.run_id }} diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index a4b54c4da5..125cb798dc 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -14,32 +14,50 @@ jobs: container: image: 'docker.io/node:20-bookworm' steps: + - name: event info + run: | + cat <<'EOF' + ${{ toJSON(github) }} + EOF - uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" check-latest: true - run: make deps-backend deps-tools - run: make --always-make -j$(nproc) lint-backend checks-backend # ensure the "go-licenses" make target runs - env: - TAGS: bindata sqlite sqlite_unlock_notify + frontend-checks: + if: ${{ !startsWith(vars.ROLE, 'forgejo-') }} + runs-on: docker + container: + image: 'docker.io/node:20-bookworm' + steps: + - uses: https://code.forgejo.org/actions/checkout@v3 + - run: make deps-frontend + - run: make lint-frontend + - run: make checks-frontend + - run: make test-frontend + - run: make frontend test-unit: if: ${{ !startsWith(vars.ROLE, 'forgejo-') }} runs-on: docker - needs: [backend-checks] + needs: [backend-checks, frontend-checks] container: image: 'docker.io/node:20-bookworm' services: minio: - image: 'docker.io/bitnami/minio:2023.8.31' + image: bitnami/minio:2024.2.26 + options: >- + --hostname gitea.minio env: + MINIO_DOMAIN: minio MINIO_ROOT_USER: 123456 MINIO_ROOT_PASSWORD: 12345678 steps: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" - run: | git config --add safe.directory '*' adduser --quiet --comment forgejo --disabled-password forgejo @@ -67,7 +85,7 @@ jobs: test-mysql: if: ${{ !startsWith(vars.ROLE, 'forgejo-') }} runs-on: docker - needs: [backend-checks] + needs: [backend-checks, frontend-checks] container: image: 'docker.io/node:20-bookworm' services: @@ -84,7 +102,7 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" - name: install dependencies & git >= 2.42 run: | export DEBIAN_FRONTEND=noninteractive @@ -113,15 +131,15 @@ jobs: test-pgsql: if: ${{ !startsWith(vars.ROLE, 'forgejo-') }} runs-on: docker - needs: [backend-checks] + needs: [backend-checks, frontend-checks] container: image: 'docker.io/node:20-bookworm' services: minio: - image: bitnami/minio:2021.3.17 + image: bitnami/minio:2024.2.26 env: - MINIO_ACCESS_KEY: 123456 - MINIO_SECRET_KEY: 12345678 + MINIO_ROOT_USER: 123456 + MINIO_ROOT_PASSWORD: 12345678 pgsql: image: 'docker.io/postgres:15' env: @@ -131,7 +149,7 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" - name: install dependencies & git >= 2.42 run: | export DEBIAN_FRONTEND=noninteractive @@ -161,14 +179,14 @@ jobs: test-sqlite: if: ${{ !startsWith(vars.ROLE, 'forgejo-') }} runs-on: docker - needs: [backend-checks] + needs: [backend-checks, frontend-checks] container: image: 'docker.io/node:20-bookworm' steps: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" - name: install dependencies & git >= 2.42 run: | export DEBIAN_FRONTEND=noninteractive diff --git a/.gitea/issue_template/bug-report-ui.yaml b/.gitea/issue_template/bug-report-ui.yaml index 4d80198399..09513d08e7 100644 --- a/.gitea/issue_template/bug-report-ui.yaml +++ b/.gitea/issue_template/bug-report-ui.yaml @@ -1,7 +1,7 @@ name: 🦋 Bug Report (web interface / frontend) description: Something doesn't look quite as it should? Report it here! title: "[BUG] " -labels: ["bug", "forgejo/ui"] +labels: ["bug/new-report", "forgejo/ui"] body: - type: markdown attributes: diff --git a/.gitea/issue_template/bug-report.yaml b/.gitea/issue_template/bug-report.yaml index ce67378175..6edbca886f 100644 --- a/.gitea/issue_template/bug-report.yaml +++ b/.gitea/issue_template/bug-report.yaml @@ -1,7 +1,7 @@ name: 🐛 Bug Report (server / backend) description: Found something you weren't expecting? Report it here! title: "[BUG] " -labels: bug +labels: bug/new-report body: - type: markdown attributes: diff --git a/.gitea/pull_request_template.md b/.gitea/pull_request_template.md index 385300ddf8..00b874fd5b 100644 --- a/.gitea/pull_request_template.md +++ b/.gitea/pull_request_template.md @@ -1,3 +1,12 @@ +--- + +name: "Pull Request Template" +about: "Template for all Pull Requests" +labels: + +- test/needed + +--- -
+
-
+
@@ -59,7 +59,7 @@
-
+
@@ -82,7 +82,7 @@ {{ctx.Locale.Tr "admin.auths.tips"}}
-
GMail Settings:
+
{{ctx.Locale.Tr "admin.auths.tips.gmail_settings"}}

Host: smtp.gmail.com, Port: 587, Enable TLS Encryption: true

{{ctx.Locale.Tr "admin.auths.tips.oauth2.general"}}:
@@ -99,7 +99,7 @@
  • GitHub
  • {{ctx.Locale.Tr "admin.auths.tip.github"}}
  • GitLab
  • - {{ctx.Locale.Tr "admin.auths.tip.gitlab"}} + {{ctx.Locale.Tr "admin.auths.tip.gitlab_new"}}
  • Google
  • {{ctx.Locale.Tr "admin.auths.tip.google_plus"}}
  • OpenID Connect
  • diff --git a/templates/admin/auth/source/ldap.tmpl b/templates/admin/auth/source/ldap.tmpl index b945a1ab1c..680849c8ea 100644 --- a/templates/admin/auth/source/ldap.tmpl +++ b/templates/admin/auth/source/ldap.tmpl @@ -1,4 +1,4 @@ -
    +
    -
    +
    -
    +
    -
    +
    @@ -38,7 +38,7 @@
    -
    +
    @@ -115,13 +115,13 @@
    -
    +
    -
    +
    diff --git a/templates/admin/auth/source/oauth.tmpl b/templates/admin/auth/source/oauth.tmpl index da3a4f913a..0560cc8256 100644 --- a/templates/admin/auth/source/oauth.tmpl +++ b/templates/admin/auth/source/oauth.tmpl @@ -1,4 +1,4 @@ -
    +