Merge pull request '[CI] do not hardcode the Forgejo release in end-to-end testing' (#2564) from earl-warren/forgejo:wip-ci-end-to-end into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2564
This commit is contained in:
Earl Warren 2024-03-05 20:01:32 +00:00
commit d2f24a5a16
3 changed files with 75 additions and 15 deletions

View file

@ -5,17 +5,26 @@ set -ex
end_to_end=$1 end_to_end=$1
end_to_end_pr=$2 end_to_end_pr=$2
forgejo=$3 forgejo=$3
forgejo_pr=$4 forgejo_pr_or_ref=$4
cd $forgejo
full_version=$(make show-version-full)
major_version=$(make show-version-major)
cd $end_to_end
date > last-upgrade
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) head_url=$(jq --raw-output .head.repo.html_url < $forgejo_pr)
test "$head_url" != null test "$head_url" != null
branch=$(jq --raw-output .head.ref < $forgejo_pr) branch=$(jq --raw-output .head.ref < $forgejo_pr)
test "$branch" != null test "$branch" != null
cd $end_to_end echo $head_url $branch $full_version > forgejo/sources/$major_version
echo $head_url $branch 7.0.0+0-gitea-1.22.0 > forgejo/sources/1.22 else
date > last-upgrade forgejo_ref=$forgejo_pr_or_ref
echo $GITHUB_SERVER_URL/$GITHUB_REPOSITORY ${forgejo_ref#refs/heads/} $full_version > forgejo/sources/$major_version
fi
base_url=$(jq --raw-output .base.repo.html_url < $forgejo_pr)
test "$base_url" != null
test "$GITHUB_RUN_NUMBER" test "$GITHUB_RUN_NUMBER"
echo $base_url/actions/runs/$GITHUB_RUN_NUMBER/artifacts/forgejo > forgejo/binary-url echo $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_NUMBER/artifacts/forgejo > forgejo/binary-url

View file

@ -1,5 +1,23 @@
# Copyright 2024 The Forgejo Authors
# SPDX-License-Identifier: MIT # 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: on:
push:
branches:
- 'wip-ci-end-to-end'
pull_request_target: pull_request_target:
types: types:
- labeled - labeled
@ -20,9 +38,18 @@ jobs:
cat <<'EOF' cat <<'EOF'
${{ toJSON(github.event.pull_request.labels.*.name) }} ${{ toJSON(github.event.pull_request.labels.*.name) }}
EOF EOF
cat <<'EOF'
${{ toJSON(github.event) }}
EOF
build: build:
if: ${{ !startsWith(vars.ROLE, 'forgejo-') && github.event.action == 'label_updated' && contains(github.event.pull_request.labels.*.name, 'run-end-to-end-tests') }} 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 runs-on: docker
container: container:
image: 'docker.io/node:20-bookworm' image: 'docker.io/node:20-bookworm'
@ -55,19 +82,29 @@ jobs:
path: forgejo path: forgejo
cascade: cascade:
if: ${{ !startsWith(vars.ROLE, 'forgejo-') && github.event.action == 'label_updated' && contains(github.event.pull_request.labels.*.name, 'run-end-to-end-tests') }} 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')
)
)
needs: [build] needs: [build]
runs-on: docker runs-on: docker
container: container:
image: node:20-bookworm image: node:20-bookworm
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/cascading-pr@v1 with:
fetch-depth: '0'
show-progress: 'false'
- uses: actions/cascading-pr@v2
with: with:
origin-url: ${{ env.GITHUB_SERVER_URL }} origin-url: ${{ env.GITHUB_SERVER_URL }}
origin-repo: ${{ github.repository }} origin-repo: ${{ github.repository }}
origin-token: ${{ secrets.END_TO_END_CASCADING_PR_ORIGIN }} origin-token: ${{ secrets.END_TO_END_CASCADING_PR_ORIGIN }}
origin-pr: ${{ github.event.pull_request.number }} origin-pr: ${{ github.event.pull_request.number }}
origin-ref: ${{ github.event_name == 'push' && github.event.ref }}
destination-url: https://code.forgejo.org destination-url: https://code.forgejo.org
destination-fork-repo: cascading-pr/end-to-end destination-fork-repo: cascading-pr/end-to-end
destination-repo: forgejo/end-to-end destination-repo: forgejo/end-to-end

View file

@ -93,6 +93,14 @@ ifneq ($(STORED_VERSION),)
else else
FORGEJO_VERSION ?= $(shell git describe --exclude '*-test' --tags --always | sed 's/^v//')+${GITEA_COMPATIBILITY} FORGEJO_VERSION ?= $(shell git describe --exclude '*-test' --tags --always | sed 's/^v//')+${GITEA_COMPATIBILITY}
endif endif
FORGEJO_VERSION_MAJOR=$(shell echo $(FORGEJO_VERSION) | sed -e 's/\..*//')
show-version-full:
@echo ${FORGEJO_VERSION}
show-version-major:
@echo ${FORGEJO_VERSION_MAJOR}
RELEASE_VERSION ?= ${FORGEJO_VERSION} RELEASE_VERSION ?= ${FORGEJO_VERSION}
VERSION ?= ${RELEASE_VERSION} VERSION ?= ${RELEASE_VERSION}
@ -100,8 +108,10 @@ LDFLAGS := $(LDFLAGS) -X "main.ReleaseVersion=$(RELEASE_VERSION)" -X "main.MakeV
LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64 LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
ifeq ($(HAS_GO), yes)
GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/)) GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) $(shell $(GO) list code.gitea.io/gitea/models/forgejo_migrations/...) code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/)) GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) $(shell $(GO) list code.gitea.io/gitea/models/forgejo_migrations/...) code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
endif
FOMANTIC_WORK_DIR := web_src/fomantic FOMANTIC_WORK_DIR := web_src/fomantic
@ -140,7 +150,9 @@ GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" ! -path modules/optio
GO_SOURCES += $(GENERATED_GO_DEST) GO_SOURCES += $(GENERATED_GO_DEST)
GO_SOURCES_NO_BINDATA := $(GO_SOURCES) GO_SOURCES_NO_BINDATA := $(GO_SOURCES)
ifeq ($(HAS_GO), yes)
MIGRATION_PACKAGES := $(shell $(GO) list code.gitea.io/gitea/models/migrations/... code.gitea.io/gitea/models/forgejo_migrations/...) MIGRATION_PACKAGES := $(shell $(GO) list code.gitea.io/gitea/models/migrations/... code.gitea.io/gitea/models/forgejo_migrations/...)
endif
ifeq ($(filter $(TAGS_SPLIT),bindata),bindata) ifeq ($(filter $(TAGS_SPLIT),bindata),bindata)
GO_SOURCES += $(BINDATA_DEST) GO_SOURCES += $(BINDATA_DEST)
@ -219,6 +231,8 @@ help:
@echo " - checks-frontend check frontend files" @echo " - checks-frontend check frontend files"
@echo " - checks-backend check backend files" @echo " - checks-backend check backend files"
@echo " - test test everything" @echo " - test test everything"
@echo " - show-version-full show the same version as the API endpoint"
@echo " - show-version-major show major release number only"
@echo " - test-frontend test frontend files" @echo " - test-frontend test frontend files"
@echo " - test-backend test backend files" @echo " - test-backend test backend files"
@echo " - test-e2e[\#TestSpecificName] test end to end using playwright" @echo " - test-e2e[\#TestSpecificName] test end to end using playwright"