2023-05-12 01:21:28 +00:00
|
|
|
name: db-tests
|
2023-05-04 02:04:02 +00:00
|
|
|
|
2023-05-16 02:53:18 +00:00
|
|
|
on:
|
|
|
|
pull_request:
|
2023-05-04 02:04:02 +00:00
|
|
|
|
2023-05-04 22:21:48 +00:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2023-05-04 02:04:02 +00:00
|
|
|
jobs:
|
2023-05-25 01:33:31 +00:00
|
|
|
files-changed:
|
|
|
|
uses: ./.github/workflows/files-changed.yml
|
|
|
|
|
2023-05-12 01:21:28 +00:00
|
|
|
test-pgsql:
|
2023-06-14 15:30:37 +00:00
|
|
|
if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
|
2023-05-25 01:33:31 +00:00
|
|
|
needs: files-changed
|
2023-05-04 02:04:02 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
|
|
pgsql:
|
2023-10-04 11:42:02 +00:00
|
|
|
image: postgres:12
|
2023-05-04 02:04:02 +00:00
|
|
|
env:
|
|
|
|
POSTGRES_DB: test
|
|
|
|
POSTGRES_PASSWORD: postgres
|
|
|
|
ports:
|
|
|
|
- "5432:5432"
|
|
|
|
ldap:
|
|
|
|
image: gitea/test-openldap:latest
|
|
|
|
ports:
|
|
|
|
- "389:389"
|
|
|
|
- "636:636"
|
|
|
|
minio:
|
|
|
|
# as github actions doesn't support "entrypoint", we need to use a non-official image
|
|
|
|
# that has a custom entrypoint set to "minio server /data"
|
2023-10-03 14:21:14 +00:00
|
|
|
image: bitnami/minio:2023.8.31
|
2023-05-04 02:04:02 +00:00
|
|
|
env:
|
2023-10-03 14:21:14 +00:00
|
|
|
MINIO_ROOT_USER: 123456
|
|
|
|
MINIO_ROOT_PASSWORD: 12345678
|
2023-05-04 02:04:02 +00:00
|
|
|
ports:
|
|
|
|
- "9000:9000"
|
|
|
|
steps:
|
2023-09-16 15:06:27 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-12-21 05:31:04 +00:00
|
|
|
- uses: actions/setup-go@v5
|
2023-05-04 02:04:02 +00:00
|
|
|
with:
|
2023-10-17 10:24:54 +00:00
|
|
|
go-version-file: go.mod
|
2023-06-09 07:33:48 +00:00
|
|
|
check-latest: true
|
2023-05-04 02:04:02 +00:00
|
|
|
- name: Add hosts to /etc/hosts
|
2023-05-18 19:48:47 +00:00
|
|
|
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 pgsql ldap minio" | sudo tee -a /etc/hosts'
|
2023-05-12 01:21:28 +00:00
|
|
|
- run: make deps-backend
|
|
|
|
- run: make backend
|
2023-05-04 02:04:02 +00:00
|
|
|
env:
|
|
|
|
TAGS: bindata
|
2024-03-07 16:43:32 +00:00
|
|
|
- name: run migration tests
|
|
|
|
run: make test-pgsql-migration
|
|
|
|
- name: run tests
|
|
|
|
run: make test-pgsql
|
2023-05-12 01:21:28 +00:00
|
|
|
timeout-minutes: 50
|
2023-05-04 02:04:02 +00:00
|
|
|
env:
|
|
|
|
TAGS: bindata gogit
|
|
|
|
RACE_ENABLED: true
|
|
|
|
TEST_TAGS: gogit
|
|
|
|
TEST_LDAP: 1
|
|
|
|
USE_REPO_TEST_DIR: 1
|
|
|
|
|
2023-05-12 01:21:28 +00:00
|
|
|
test-sqlite:
|
2023-06-14 15:30:37 +00:00
|
|
|
if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
|
2023-05-25 01:33:31 +00:00
|
|
|
needs: files-changed
|
2023-05-04 02:04:02 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-09-16 15:06:27 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-12-21 05:31:04 +00:00
|
|
|
- uses: actions/setup-go@v5
|
2023-05-04 02:04:02 +00:00
|
|
|
with:
|
2023-10-17 10:24:54 +00:00
|
|
|
go-version-file: go.mod
|
2023-06-09 07:33:48 +00:00
|
|
|
check-latest: true
|
2023-05-12 01:21:28 +00:00
|
|
|
- run: make deps-backend
|
|
|
|
- run: make backend
|
2023-05-04 02:04:02 +00:00
|
|
|
env:
|
|
|
|
TAGS: bindata gogit sqlite sqlite_unlock_notify
|
2024-03-07 16:43:32 +00:00
|
|
|
- name: run migration tests
|
|
|
|
run: make test-sqlite-migration
|
|
|
|
- name: run tests
|
|
|
|
run: make test-sqlite
|
2023-05-12 01:21:28 +00:00
|
|
|
timeout-minutes: 50
|
2023-05-04 02:04:02 +00:00
|
|
|
env:
|
|
|
|
TAGS: bindata gogit sqlite sqlite_unlock_notify
|
|
|
|
RACE_ENABLED: true
|
|
|
|
TEST_TAGS: gogit sqlite sqlite_unlock_notify
|
|
|
|
USE_REPO_TEST_DIR: 1
|
|
|
|
|
2023-05-12 01:21:28 +00:00
|
|
|
test-unit:
|
2023-06-14 15:30:37 +00:00
|
|
|
if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
|
2023-05-25 01:33:31 +00:00
|
|
|
needs: files-changed
|
2023-05-04 02:04:02 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
|
|
elasticsearch:
|
|
|
|
image: elasticsearch:7.5.0
|
|
|
|
env:
|
|
|
|
discovery.type: single-node
|
|
|
|
ports:
|
|
|
|
- "9200:9200"
|
Refactor and enhance issue indexer to support both searching, filtering and paging (#26012)
Fix #24662.
Replace #24822 and #25708 (although it has been merged)
## Background
In the past, Gitea supported issue searching with a keyword and
conditions in a less efficient way. It worked by searching for issues
with the keyword and obtaining limited IDs (as it is heavy to get all)
on the indexer (bleve/elasticsearch/meilisearch), and then querying with
conditions on the database to find a subset of the found IDs. This is
why the results could be incomplete.
To solve this issue, we need to store all fields that could be used as
conditions in the indexer and support both keyword and additional
conditions when searching with the indexer.
## Major changes
- Redefine `IndexerData` to include all fields that could be used as
filter conditions.
- Refactor `Search(ctx context.Context, kw string, repoIDs []int64,
limit, start int, state string)` to `Search(ctx context.Context, options
*SearchOptions)`, so it supports more conditions now.
- Change the data type stored in `issueIndexerQueue`. Use
`IndexerMetadata` instead of `IndexerData` in case the data has been
updated while it is in the queue. This also reduces the storage size of
the queue.
- Enhance searching with Bleve/Elasticsearch/Meilisearch, make them
fully support `SearchOptions`. Also, update the data versions.
- Keep most logic of database indexer, but remove
`issues.SearchIssueIDsByKeyword` in `models` to avoid confusion where is
the entry point to search issues.
- Start a Meilisearch instance to test it in unit tests.
- Add unit tests with almost full coverage to test
Bleve/Elasticsearch/Meilisearch indexer.
---------
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-07-31 06:28:53 +00:00
|
|
|
meilisearch:
|
|
|
|
image: getmeili/meilisearch:v1.2.0
|
|
|
|
env:
|
|
|
|
MEILI_ENV: development # disable auth
|
|
|
|
ports:
|
|
|
|
- "7700:7700"
|
2023-05-11 02:09:37 +00:00
|
|
|
redis:
|
|
|
|
image: redis
|
2023-05-12 01:21:28 +00:00
|
|
|
options: >- # wait until redis has started
|
2023-05-11 02:09:37 +00:00
|
|
|
--health-cmd "redis-cli ping"
|
|
|
|
--health-interval 5s
|
|
|
|
--health-timeout 3s
|
|
|
|
--health-retries 10
|
|
|
|
ports:
|
|
|
|
- 6379:6379
|
2023-05-13 22:33:25 +00:00
|
|
|
minio:
|
|
|
|
image: bitnami/minio:2021.3.17
|
|
|
|
env:
|
|
|
|
MINIO_ACCESS_KEY: 123456
|
|
|
|
MINIO_SECRET_KEY: 12345678
|
|
|
|
ports:
|
|
|
|
- "9000:9000"
|
2024-05-30 07:33:50 +00:00
|
|
|
devstoreaccount1.azurite.local: # https://github.com/Azure/Azurite/issues/1583
|
|
|
|
image: mcr.microsoft.com/azure-storage/azurite:latest
|
|
|
|
ports:
|
|
|
|
- 10000:10000
|
2023-05-04 02:04:02 +00:00
|
|
|
steps:
|
2023-09-16 15:06:27 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-12-21 05:31:04 +00:00
|
|
|
- uses: actions/setup-go@v5
|
2023-05-04 02:04:02 +00:00
|
|
|
with:
|
2023-10-17 10:24:54 +00:00
|
|
|
go-version-file: go.mod
|
2023-06-09 07:33:48 +00:00
|
|
|
check-latest: true
|
2023-05-04 02:04:02 +00:00
|
|
|
- name: Add hosts to /etc/hosts
|
2024-05-30 07:33:50 +00:00
|
|
|
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 minio devstoreaccount1.azurite.local mysql elasticsearch meilisearch smtpimap" | sudo tee -a /etc/hosts'
|
2023-05-12 01:21:28 +00:00
|
|
|
- run: make deps-backend
|
|
|
|
- run: make backend
|
2023-05-04 02:04:02 +00:00
|
|
|
env:
|
|
|
|
TAGS: bindata
|
2023-05-12 01:21:28 +00:00
|
|
|
- name: unit-tests
|
2023-05-04 02:04:02 +00:00
|
|
|
run: make unit-test-coverage test-check
|
|
|
|
env:
|
|
|
|
TAGS: bindata
|
|
|
|
RACE_ENABLED: true
|
|
|
|
GITHUB_READ_TOKEN: ${{ secrets.GITHUB_READ_TOKEN }}
|
2023-05-12 01:21:28 +00:00
|
|
|
- name: unit-tests-gogit
|
2023-05-04 02:04:02 +00:00
|
|
|
run: make unit-test-coverage test-check
|
|
|
|
env:
|
|
|
|
TAGS: bindata gogit
|
|
|
|
RACE_ENABLED: true
|
|
|
|
GITHUB_READ_TOKEN: ${{ secrets.GITHUB_READ_TOKEN }}
|
|
|
|
|
2023-10-03 17:27:57 +00:00
|
|
|
test-mysql:
|
2023-06-14 15:30:37 +00:00
|
|
|
if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
|
2023-05-25 01:33:31 +00:00
|
|
|
needs: files-changed
|
2023-05-04 02:04:02 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
|
|
mysql:
|
2024-11-15 15:45:07 +00:00
|
|
|
# the bitnami mysql image has more options than the official one, it's easier to customize
|
|
|
|
image: bitnami/mysql:8.0
|
2023-05-04 02:04:02 +00:00
|
|
|
env:
|
2024-11-15 15:45:07 +00:00
|
|
|
ALLOW_EMPTY_PASSWORD: true
|
2023-10-03 17:27:57 +00:00
|
|
|
MYSQL_DATABASE: testgitea
|
2023-05-04 02:04:02 +00:00
|
|
|
ports:
|
|
|
|
- "3306:3306"
|
2024-11-15 15:45:07 +00:00
|
|
|
options: >-
|
|
|
|
--mount type=tmpfs,destination=/bitnami/mysql/data
|
2023-05-04 02:04:02 +00:00
|
|
|
elasticsearch:
|
|
|
|
image: elasticsearch:7.5.0
|
|
|
|
env:
|
|
|
|
discovery.type: single-node
|
|
|
|
ports:
|
|
|
|
- "9200:9200"
|
|
|
|
smtpimap:
|
|
|
|
image: tabascoterrier/docker-imap-devel:latest
|
|
|
|
ports:
|
|
|
|
- "25:25"
|
|
|
|
- "143:143"
|
|
|
|
- "587:587"
|
|
|
|
- "993:993"
|
|
|
|
steps:
|
2023-09-16 15:06:27 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-12-21 05:31:04 +00:00
|
|
|
- uses: actions/setup-go@v5
|
2023-05-04 02:04:02 +00:00
|
|
|
with:
|
2023-10-17 10:24:54 +00:00
|
|
|
go-version-file: go.mod
|
2023-06-09 07:33:48 +00:00
|
|
|
check-latest: true
|
2023-05-04 02:04:02 +00:00
|
|
|
- name: Add hosts to /etc/hosts
|
2023-05-18 19:48:47 +00:00
|
|
|
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mysql elasticsearch smtpimap" | sudo tee -a /etc/hosts'
|
2023-05-12 01:21:28 +00:00
|
|
|
- run: make deps-backend
|
|
|
|
- run: make backend
|
2023-05-04 02:04:02 +00:00
|
|
|
env:
|
|
|
|
TAGS: bindata
|
2024-03-07 16:43:32 +00:00
|
|
|
- name: run migration tests
|
|
|
|
run: make test-mysql-migration
|
2023-05-04 02:04:02 +00:00
|
|
|
- name: run tests
|
2024-11-15 15:45:07 +00:00
|
|
|
# run: make integration-test-coverage (at the moment, no coverage is really handled)
|
|
|
|
run: make test-mysql
|
2023-05-04 02:04:02 +00:00
|
|
|
env:
|
|
|
|
TAGS: bindata
|
|
|
|
RACE_ENABLED: true
|
|
|
|
USE_REPO_TEST_DIR: 1
|
|
|
|
TEST_INDEXER_CODE_ES_URL: "http://elastic:changeme@elasticsearch:9200"
|
|
|
|
|
2023-05-12 01:21:28 +00:00
|
|
|
test-mssql:
|
2023-06-14 15:30:37 +00:00
|
|
|
if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
|
2023-05-25 01:33:31 +00:00
|
|
|
needs: files-changed
|
2024-09-23 20:54:20 +00:00
|
|
|
# specifying the version of ubuntu in use as mssql fails on newer kernels
|
|
|
|
# pending resolution from vendor
|
|
|
|
runs-on: ubuntu-20.04
|
2023-05-04 02:04:02 +00:00
|
|
|
services:
|
|
|
|
mssql:
|
2024-09-23 20:54:20 +00:00
|
|
|
image: mcr.microsoft.com/mssql/server:2017-latest
|
2023-05-04 02:04:02 +00:00
|
|
|
env:
|
|
|
|
ACCEPT_EULA: Y
|
|
|
|
MSSQL_PID: Standard
|
|
|
|
SA_PASSWORD: MwantsaSecurePassword1
|
|
|
|
ports:
|
|
|
|
- "1433:1433"
|
2024-05-30 07:33:50 +00:00
|
|
|
devstoreaccount1.azurite.local: # https://github.com/Azure/Azurite/issues/1583
|
|
|
|
image: mcr.microsoft.com/azure-storage/azurite:latest
|
|
|
|
ports:
|
|
|
|
- 10000:10000
|
2023-05-04 02:04:02 +00:00
|
|
|
steps:
|
2023-09-16 15:06:27 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-12-21 05:31:04 +00:00
|
|
|
- uses: actions/setup-go@v5
|
2023-05-04 02:04:02 +00:00
|
|
|
with:
|
2023-10-17 10:24:54 +00:00
|
|
|
go-version-file: go.mod
|
2023-06-09 07:33:48 +00:00
|
|
|
check-latest: true
|
2023-05-04 02:04:02 +00:00
|
|
|
- name: Add hosts to /etc/hosts
|
2024-05-30 07:33:50 +00:00
|
|
|
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mssql devstoreaccount1.azurite.local" | sudo tee -a /etc/hosts'
|
2023-05-12 01:21:28 +00:00
|
|
|
- run: make deps-backend
|
|
|
|
- run: make backend
|
2023-05-04 02:04:02 +00:00
|
|
|
env:
|
|
|
|
TAGS: bindata
|
2024-03-07 16:43:32 +00:00
|
|
|
- run: make test-mssql-migration
|
|
|
|
- name: run tests
|
|
|
|
run: make test-mssql
|
2023-05-12 01:21:28 +00:00
|
|
|
timeout-minutes: 50
|
2023-05-04 02:04:02 +00:00
|
|
|
env:
|
|
|
|
TAGS: bindata
|
|
|
|
USE_REPO_TEST_DIR: 1
|