Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial playwright config #18442

Closed
wants to merge 16 commits into from
Closed
71 changes: 71 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,77 @@ steps:
- name: deps
path: /go

---
kind: pipeline
type: docker
name: testing-e2e

platform:
os: linux
arch: amd64

#depends_on:
# - testing-amd64
# - testing-arm64

trigger:
event:
- pull_request

volumes:
- name: deps
temp: {}

services:
- name: pgsql
pull: default
image: postgres:10
environment:
POSTGRES_DB: testgitea-e2e
POSTGRES_PASSWORD: postgres
POSTGRES_INITDB_ARGS: --encoding=UTF8 --lc-collate='en_US.UTF-8' --lc-ctype='en_US.UTF-8'

steps:
- name: deps-frontend
image: node:16
pull: always
commands:
- make deps-frontend

- name: deps-backend
image: golang:1.18
pull: always
commands:
- make deps-backend
volumes:
- name: deps
path: /go

# TODO: We should probably build all dependencies into a test image
- name: test-e2e
image: mcr.microsoft.com/playwright:v1.22.2-focal
commands:
- curl -sL https://go.dev/dl/go1.18.3.linux-amd64.tar.gz -o go1.18.3.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.18.3.linux-amd64.tar.gz
- groupadd --gid 1001 gitea && useradd -m --gid 1001 --uid 1001 gitea
- apt-get update
- apt-get install build-essential --yes
- export TEST_PGSQL_SCHEMA=''
- ./build/test-env-prepare.sh
- su gitea bash -c "export PATH=$PATH:/usr/local/go/bin && timeout -s ABRT 40m make test-e2e-pgsql"
environment:
GOPROXY: https://goproxy.io
GOSUMDB: sum.golang.org
TAGS: bindata
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this tag is for go build only in my mind.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just updated the summary. I'm actually building the binary before running e2e tests. Alternatively, I could throw an error "Build gitea before running e2e tests", but I like this better right now.

USE_REPO_TEST_DIR: 1
NO_DEPS_PLAYWRIGHT: 1
TEST_LOGGER: console,file # Debug
TEST_PGSQL_DBNAME: 'testgitea-e2e'
NPX_FLAGS: '--yes'
depends_on: [deps-backend, deps-frontend]
volumes:
- name: deps
path: /go

---
kind: pipeline
name: update_translations
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,7 @@ prime/

# Manpage
/man
test-results/

# E2E
tools/e2e/reports/
64 changes: 64 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ ifeq ($(filter $(TAGS_SPLIT),bindata),bindata)
GO_SOURCES += $(BINDATA_DEST)
endif

ifneq ($(NO_DEPS_PLAYWRIGHT),1)
PLAYWRIGHT_FLAGS += --with-deps
endif

SWAGGER_SPEC := templates/swagger/v1_json.tmpl
SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl \| JSEscape \| Safe}}/api/v1"|g
SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl \| JSEscape \| Safe}}/api/v1"|"basePath": "/api/v1"|g
Expand Down Expand Up @@ -183,6 +187,7 @@ help:
@echo " - test test everything"
@echo " - test-frontend test frontend files"
@echo " - test-backend test backend files"
@echo " - test-e2e[\#TestSpecificName] test end to end using playwright"
@echo " - webpack build webpack files"
@echo " - svg build svg files"
@echo " - fomantic build fomantic files"
Expand Down Expand Up @@ -390,6 +395,7 @@ gomod-check: tidy

generate-ini-sqlite:
sed -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
-e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
integrations/sqlite.ini.tmpl > integrations/sqlite.ini

.PHONY: test-sqlite
Expand All @@ -416,6 +422,7 @@ generate-ini-mysql:
-e 's|{{TEST_MYSQL_USERNAME}}|${TEST_MYSQL_USERNAME}|g' \
-e 's|{{TEST_MYSQL_PASSWORD}}|${TEST_MYSQL_PASSWORD}|g' \
-e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
-e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
integrations/mysql.ini.tmpl > integrations/mysql.ini

.PHONY: test-mysql
Expand All @@ -437,6 +444,7 @@ generate-ini-mysql8:
-e 's|{{TEST_MYSQL8_USERNAME}}|${TEST_MYSQL8_USERNAME}|g' \
-e 's|{{TEST_MYSQL8_PASSWORD}}|${TEST_MYSQL8_PASSWORD}|g' \
-e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
-e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
integrations/mysql8.ini.tmpl > integrations/mysql8.ini

.PHONY: test-mysql8
Expand All @@ -459,6 +467,7 @@ generate-ini-pgsql:
-e 's|{{TEST_PGSQL_PASSWORD}}|${TEST_PGSQL_PASSWORD}|g' \
-e 's|{{TEST_PGSQL_SCHEMA}}|${TEST_PGSQL_SCHEMA}|g' \
-e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
-e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
integrations/pgsql.ini.tmpl > integrations/pgsql.ini

.PHONY: test-pgsql
Expand All @@ -480,6 +489,7 @@ generate-ini-mssql:
-e 's|{{TEST_MSSQL_USERNAME}}|${TEST_MSSQL_USERNAME}|g' \
-e 's|{{TEST_MSSQL_PASSWORD}}|${TEST_MSSQL_PASSWORD}|g' \
-e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
-e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
integrations/mssql.ini.tmpl > integrations/mssql.ini

.PHONY: test-mssql
Expand All @@ -495,6 +505,60 @@ test-mssql-migration: migrations.mssql.test migrations.individual.mssql.test gen
GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/mssql.ini ./migrations.mssql.test -test.failfast
GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/mssql.ini ./migrations.individual.mssql.test -test.failfast

.PHONY: test-e2e%
# Use only file logging for end-to-end tests
test-e2e%: TEST_LOGGER ?= file

.PHONY: test-e2e
test-e2e: test-e2e-sqlite

.PHONY: test-e2e\#%
test-e2e\#%: test-e2e-sqlite\#%
# Kind of a hack to get makefile to accept passing arguement
true

.PHONY: test-e2e-sqlite
test-e2e-sqlite: TAGS+=sqlite sqlite_unlock_notify
test-e2e-sqlite: build generate-ini-sqlite
npx playwright install $(PLAYWRIGHT_FLAGS)
GITEA_ROOT=$(CURDIR) GITEA_URL="http://localhost:3003" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=integrations/sqlite.ini ./tools/e2e/run_e2e.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to override the GITEA_URL? This port is wrong when I run the make task.


.PHONY: test-e2e-sqlite\#%
test-e2e-sqlite\#%: TAGS+=sqlite sqlite_unlock_notify
test-e2e-sqlite\#%: build generate-ini-sqlite
npx playwright install $(PLAYWRIGHT_FLAGS)
GITEA_URL="http://localhost:3003" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=$(CURDIR)/integrations/sqlite.ini E2E_TESTS=$* ./tools/e2e/run_e2e.sh

.PHONY: test-e2e-mysql8
test-e2e-mysql8: build generate-ini-mysql8
npx playwright install $(PLAYWRIGHT_FLAGS)
GITEA_URL="http://localhost:3004" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=$(CURDIR)/integrations/mysql8.ini ./tools/e2e/run_e2e.sh

.PHONY: test-e2e-mysql8\#%
test-e2e-mysql8\#%: build generate-ini-mysql8
npx playwright install $(PLAYWRIGHT_FLAGS)
GITEA_URL="http://localhost:3004" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=$(CURDIR)/integrations/mysql8.ini E2E_TESTS=$* ./tools/e2e/run_e2e.sh

.PHONY: test-e2e-pgsql
test-e2e-pgsql: build generate-ini-pgsql
npx playwright install $(PLAYWRIGHT_FLAGS)
GITEA_URL="http://localhost:3002" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=$(CURDIR)/integrations/pgsql.ini ./tools/e2e/run_e2e.sh

.PHONY: test-e2e-pgsql\#%
test-e2e-pgsql\#%: build generate-ini-pgsql
npx playwright install $(PLAYWRIGHT_FLAGS)
GITEA_URL="http://localhost:3002" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=$(CURDIR)/integrations/pgsql.ini E2E_TESTS=$* ./tools/e2e/run_e2e.sh

.PHONY: test-e2e-mssql
test-e2e-mssql: build generate-ini-mssql
npx playwright install $(PLAYWRIGHT_FLAGS)
GITEA_ROOT=$(CURDIR) GITEA_URL="http://localhost:3003" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=$(CURDIR)/integrations/mssql.ini ./tools/e2e/run_e2e.sh

.PHONY: test-e2e-mssql\#%
test-e2e-mssql\#%: build generate-ini-mssql
npx playwright install $(PLAYWRIGHT_FLAGS)
GITEA_ROOT=$(CURDIR) GITEA_URL="http://localhost:3003" GITEA_EXECUTABLE=$(EXECUTABLE) GITEA_CONF=$(CURDIR)/integrations/mssql.ini E2E_TESTS=$* ./tools/e2e/run_e2e.sh

.PHONY: bench-sqlite
bench-sqlite: integrations.sqlite.test generate-ini-sqlite
GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
Expand Down
2 changes: 1 addition & 1 deletion integrations/mssql.ini.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ PROVIDER = file
PROVIDER_CONFIG = integrations/gitea-integration-mssql/data/sessions

[log]
MODE = test,file
MODE = {{TEST_LOGGER}}
ROOT_PATH = {{REPO_TEST_DIR}}mssql-log
ROUTER = ,
XORM = file
Expand Down
2 changes: 1 addition & 1 deletion integrations/mysql.ini.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ PROVIDER = file
PROVIDER_CONFIG = integrations/gitea-integration-mysql/data/sessions

[log]
MODE = test,file
MODE = {{TEST_LOGGER}}
ROOT_PATH = {{REPO_TEST_DIR}}mysql-log
ROUTER = ,
XORM = file
Expand Down
2 changes: 1 addition & 1 deletion integrations/mysql8.ini.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ PROVIDER = file
PROVIDER_CONFIG = integrations/gitea-integration-mysql8/data/sessions

[log]
MODE = test,file
MODE = {{TEST_LOGGER}}
ROOT_PATH = {{REPO_TEST_DIR}}mysql8-log
ROUTER = ,
XORM = file
Expand Down
2 changes: 1 addition & 1 deletion integrations/pgsql.ini.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ PROVIDER = file
PROVIDER_CONFIG = integrations/gitea-integration-pgsql/data/sessions

[log]
MODE = test,file
MODE = {{TEST_LOGGER}}
ROOT_PATH = {{REPO_TEST_DIR}}pgsql-log
ROUTER = ,
XORM = file
Expand Down
2 changes: 1 addition & 1 deletion integrations/sqlite.ini.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ PROVIDER = file
PROVIDER_CONFIG = integrations/gitea-integration-sqlite/data/sessions

[log]
MODE = test,file
MODE = {{TEST_LOGGER}}
ROOT_PATH = {{REPO_TEST_DIR}}sqlite-log
ROUTER = ,
XORM = file
Expand Down
Loading