feat(actions): improve support for reusable workflows #43944
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: db-tests | |
| on: | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| files-changed: | |
| uses: ./.github/workflows/files-changed.yml | |
| test-pgsql-shard-1: | |
| if: needs.files-changed.outputs.backend == 'true' | |
| needs: files-changed | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 50 | |
| services: | |
| pgsql: | |
| image: postgres:14 | |
| env: | |
| POSTGRES_DB: test | |
| POSTGRES_PASSWORD: postgres | |
| ports: | |
| - "5432:5432" | |
| ldap: | |
| image: gitea/test-openldap:latest@sha256:4ac633b01d684e6b2a458cc0c8530c92f9b3702f6e040ce5f365607df34fbda0 | |
| 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" | |
| image: bitnamilegacy/minio:2025.7.23 | |
| env: | |
| MINIO_ROOT_USER: 123456 | |
| MINIO_ROOT_PASSWORD: 12345678 | |
| ports: | |
| - "9000:9000" | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: ./.github/actions/go-setup | |
| - uses: ./.github/actions/pgsql-shard | |
| with: | |
| shard: 1 | |
| total-shards: 2 | |
| run-migration: "true" | |
| test-pgsql-shard-2: | |
| if: needs.files-changed.outputs.backend == 'true' | |
| needs: files-changed | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 50 | |
| services: | |
| pgsql: | |
| image: postgres:14 | |
| env: | |
| POSTGRES_DB: test | |
| POSTGRES_PASSWORD: postgres | |
| ports: | |
| - "5432:5432" | |
| ldap: | |
| image: gitea/test-openldap:latest@sha256:4ac633b01d684e6b2a458cc0c8530c92f9b3702f6e040ce5f365607df34fbda0 | |
| 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" | |
| image: bitnamilegacy/minio:2025.7.23 | |
| env: | |
| MINIO_ROOT_USER: 123456 | |
| MINIO_ROOT_PASSWORD: 12345678 | |
| ports: | |
| - "9000:9000" | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: ./.github/actions/go-setup | |
| - uses: ./.github/actions/pgsql-shard | |
| with: | |
| shard: 2 | |
| total-shards: 2 | |
| test-sqlite: | |
| if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true' | |
| needs: files-changed | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: ./.github/actions/go-setup | |
| - run: make deps-backend | |
| - run: make backend | |
| env: | |
| TAGS: bindata gogit | |
| GOEXPERIMENT: | |
| - run: GITEA_TEST_DATABASE=sqlite make test-migration | |
| env: | |
| TAGS: bindata gogit | |
| - name: run tests | |
| run: GITEA_TEST_DATABASE=sqlite make test-integration | |
| timeout-minutes: 50 | |
| env: | |
| # sqlite driver can contain large amount of Golang code, so don't use race detector for it, otherwise, extremely slow | |
| GOTEST_FLAGS: -timeout=40m | |
| TAGS: bindata gogit | |
| GOEXPERIMENT: | |
| test-unit: | |
| if: needs.files-changed.outputs.backend == 'true' | |
| needs: files-changed | |
| runs-on: ubuntu-latest | |
| services: | |
| elasticsearch: | |
| image: docker.elastic.co/elasticsearch/elasticsearch:8.19.15 | |
| env: | |
| discovery.type: single-node | |
| xpack.security.enabled: false | |
| ES_JAVA_OPTS: "-Xms512m -Xmx512m" # reduce from ES default of 50% | |
| ports: | |
| - "9200:9200" | |
| meilisearch: | |
| image: getmeili/meilisearch:v1 | |
| env: | |
| MEILI_ENV: development # disable auth | |
| ports: | |
| - "7700:7700" | |
| redis: | |
| image: redis:latest@sha256:48e78eb9d1e1adcfb10184b2cc3c7fc5ed21e5a3be08875f239257d194bab8c9 | |
| options: >- # wait until redis has started | |
| --health-cmd "redis-cli ping" | |
| --health-interval 5s | |
| --health-timeout 3s | |
| --health-retries 10 | |
| ports: | |
| - 6379:6379 | |
| minio: | |
| image: bitnamilegacy/minio:2025.7.23 | |
| env: | |
| MINIO_ROOT_USER: 123456 | |
| MINIO_ROOT_PASSWORD: 12345678 | |
| ports: | |
| - "9000:9000" | |
| devstoreaccount1.azurite.local: # https://github.com/Azure/Azurite/issues/1583 | |
| image: mcr.microsoft.com/azure-storage/azurite:latest@sha256:dae2a5f96553962901304b94e72ef87e299d0825e4b679673bcc527a25076fe4 | |
| ports: | |
| - 10000:10000 | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: ./.github/actions/go-setup | |
| - name: Add hosts to /etc/hosts | |
| run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 minio devstoreaccount1.azurite.local mysql elasticsearch meilisearch smtpimap" | sudo tee -a /etc/hosts' | |
| - run: make deps-backend | |
| - run: make generate-go | |
| env: | |
| TAGS: bindata | |
| - name: unit-tests | |
| run: make test-backend | |
| env: | |
| GOTEST_FLAGS: -race -timeout=20m | |
| TAGS: bindata | |
| GITHUB_READ_TOKEN: ${{ secrets.GITHUB_READ_TOKEN }} | |
| - name: unit-tests-gogit | |
| run: make test-backend | |
| env: | |
| GOTEST_FLAGS: -race -timeout=20m | |
| TAGS: bindata gogit | |
| GOEXPERIMENT: | |
| GITHUB_READ_TOKEN: ${{ secrets.GITHUB_READ_TOKEN }} | |
| GITEA_TEST_CI_SKIP_EXTERNAL: true | |
| - run: make test-check | |
| test-mysql: | |
| if: needs.files-changed.outputs.backend == 'true' | |
| needs: files-changed | |
| runs-on: ubuntu-latest | |
| services: | |
| mysql: | |
| # the bitnami mysql image has more options than the official one, it's easier to customize | |
| image: bitnamilegacy/mysql:8.4 | |
| env: | |
| ALLOW_EMPTY_PASSWORD: true | |
| MYSQL_DATABASE: testgitea | |
| ports: | |
| - "3306:3306" | |
| options: >- | |
| --mount type=tmpfs,destination=/bitnami/mysql/data | |
| elasticsearch: | |
| image: docker.elastic.co/elasticsearch/elasticsearch:8.19.15 | |
| env: | |
| discovery.type: single-node | |
| xpack.security.enabled: false | |
| ES_JAVA_OPTS: "-Xms512m -Xmx512m" # reduce from ES default of 50% | |
| ports: | |
| - "9200:9200" | |
| smtpimap: | |
| image: tabascoterrier/docker-imap-devel:latest@sha256:3fb7cf50b47693e7b80f6f74abea2def4d7386016931d61359864de8a0aba551 | |
| ports: | |
| - "25:25" | |
| - "143:143" | |
| - "587:587" | |
| - "993:993" | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: ./.github/actions/go-setup | |
| - name: Add hosts to /etc/hosts | |
| run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mysql elasticsearch smtpimap" | sudo tee -a /etc/hosts' | |
| - run: make deps-backend | |
| - run: make backend | |
| env: | |
| TAGS: bindata | |
| - run: GITEA_TEST_DATABASE=mysql make test-migration | |
| - name: run tests | |
| run: GITEA_TEST_DATABASE=mysql make test-integration | |
| env: | |
| TAGS: bindata | |
| TEST_INDEXER_CODE_ES_URL: "http://elastic:changeme@elasticsearch:9200" | |
| test-mssql: | |
| if: needs.files-changed.outputs.backend == 'true' | |
| needs: files-changed | |
| runs-on: ubuntu-latest | |
| services: | |
| mssql: | |
| image: mcr.microsoft.com/mssql/server:2019-latest | |
| env: | |
| ACCEPT_EULA: Y | |
| MSSQL_PID: Standard | |
| SA_PASSWORD: MwantsaSecurePassword1 | |
| ports: | |
| - "1433:1433" | |
| devstoreaccount1.azurite.local: # https://github.com/Azure/Azurite/issues/1583 | |
| image: mcr.microsoft.com/azure-storage/azurite:latest@sha256:dae2a5f96553962901304b94e72ef87e299d0825e4b679673bcc527a25076fe4 | |
| ports: | |
| - 10000:10000 | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: ./.github/actions/go-setup | |
| - name: Add hosts to /etc/hosts | |
| run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mssql devstoreaccount1.azurite.local" | sudo tee -a /etc/hosts' | |
| - run: make deps-backend | |
| - run: make backend | |
| env: | |
| TAGS: bindata | |
| - run: GITEA_TEST_DATABASE=mssql make test-migration | |
| - name: run tests | |
| run: GITEA_TEST_DATABASE=mssql make test-integration | |
| timeout-minutes: 50 | |
| env: | |
| TAGS: bindata |