jojo/.forgejo/workflows/coverage.yml

90 lines
3.2 KiB
YAML
Raw Normal View History

chore: collect coverage using GOCOVERDIR (#9004) - run all unit tests and integration tests in sequence in the same job - upload the coverage data as an artifact to the run - only run via dispatch because it is very long - arguments are used to select which unit or integration tests to focus on Refs https://go.dev/blog/integration-test-coverage ### Testing - Run this workflow via workflow_dispatch (see https://codeberg.org/forgejo-integration/forgejo/actions/runs/11889) - Download the coverage information (see https://codeberg.org/forgejo-integration/forgejo/actions/runs/11889/artifacts/coverage) - Download the coverage information from an end-to-end cascade test (see https://code.forgejo.org/forgejo/end-to-end/actions/runs/3961) - Unzip them in a the `coverage/data` sub-directory at the root of the Forgejo source tree ```sh $ ls coverage/data actions coverage-actions.zip coverage-federation.zip coverage-tests.zip coverage-upgrade.zip federation tests upgrade ``` - Display the coverage percentage ``` $ make coverage-show-percentage ... forgejo.org/services/wiki/wiki_path.go:96: WebPathToGitPath 81.8% forgejo.org/services/wiki/wiki_path.go:113: GitPathToWebPath 90.0% forgejo.org/services/wiki/wiki_path.go:129: WebPathToUserTitle 71.4% forgejo.org/services/wiki/wiki_path.go:140: WebPathToURLPath 100.0% forgejo.org/services/wiki/wiki_path.go:144: WebPathFromRequest 100.0% forgejo.org/services/wiki/wiki_path.go:151: UserTitleToWebPath 80.0% forgejo.org/services/wiki/wiki_path.go:163: ToWikiPageMetaData 100.0% forgejo.org/tests/integration/api_repo_file_helpers.go:18: createFileInBranch 100.0% ... total: (statements) 63.9% ``` Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9004 Reviewed-by: jerger <jerger@noreply.codeberg.org> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-08-26 10:10:46 +02:00
name: coverage
on:
workflow_dispatch:
inputs:
repository:
description: 'repository'
type: string
ref:
description: 'ref'
type: string
unit-tests-env:
description: 'COVERAGE_TEST_PACKAGES=forgejo.org/modules/actions'
type: string
integration-tests-env:
description: 'COVERAGE_TEST_ARGS=-run=TestAPIListRepoComments'
type: string
jobs:
all:
runs-on: docker
container:
image: 'data.forgejo.org/oci/ci:1'
options: --tmpfs /tmp:exec,noatime
services:
elasticsearch:
image: data.forgejo.org/oci/bitnami/elasticsearch:7
options: --tmpfs /bitnami/elasticsearch/data
env:
discovery.type: single-node
ES_JAVA_OPTS: "-Xms512m -Xmx512m"
minio:
image: data.forgejo.org/oci/bitnami/minio:2024.8.17
options: >-
--hostname gitea.minio --tmpfs /bitnami/minio/data:noatime
env:
MINIO_DOMAIN: minio
MINIO_ROOT_USER: 123456
MINIO_ROOT_PASSWORD: 12345678
mysql:
image: 'data.forgejo.org/oci/bitnami/mysql:8.4'
env:
ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: testgitea
#
# See also https://codeberg.org/forgejo/forgejo/issues/976
#
MYSQL_EXTRA_FLAGS: --innodb-adaptive-flushing=OFF --innodb-buffer-pool-size=4G --innodb-log-buffer-size=128M --innodb-flush-log-at-trx-commit=0 --innodb-flush-log-at-timeout=30 --innodb-flush-method=nosync --innodb-fsync-threshold=1000000000 --disable-log-bin
options: --tmpfs /bitnami/mysql/data:noatime
ldap:
image: data.forgejo.org/oci/forgejo-test-openldap:latest
chore: collect coverage using GOCOVERDIR (#9004) - run all unit tests and integration tests in sequence in the same job - upload the coverage data as an artifact to the run - only run via dispatch because it is very long - arguments are used to select which unit or integration tests to focus on Refs https://go.dev/blog/integration-test-coverage ### Testing - Run this workflow via workflow_dispatch (see https://codeberg.org/forgejo-integration/forgejo/actions/runs/11889) - Download the coverage information (see https://codeberg.org/forgejo-integration/forgejo/actions/runs/11889/artifacts/coverage) - Download the coverage information from an end-to-end cascade test (see https://code.forgejo.org/forgejo/end-to-end/actions/runs/3961) - Unzip them in a the `coverage/data` sub-directory at the root of the Forgejo source tree ```sh $ ls coverage/data actions coverage-actions.zip coverage-federation.zip coverage-tests.zip coverage-upgrade.zip federation tests upgrade ``` - Display the coverage percentage ``` $ make coverage-show-percentage ... forgejo.org/services/wiki/wiki_path.go:96: WebPathToGitPath 81.8% forgejo.org/services/wiki/wiki_path.go:113: GitPathToWebPath 90.0% forgejo.org/services/wiki/wiki_path.go:129: WebPathToUserTitle 71.4% forgejo.org/services/wiki/wiki_path.go:140: WebPathToURLPath 100.0% forgejo.org/services/wiki/wiki_path.go:144: WebPathFromRequest 100.0% forgejo.org/services/wiki/wiki_path.go:151: UserTitleToWebPath 80.0% forgejo.org/services/wiki/wiki_path.go:163: ToWikiPageMetaData 100.0% forgejo.org/tests/integration/api_repo_file_helpers.go:18: createFileInBranch 100.0% ... total: (statements) 63.9% ``` Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9004 Reviewed-by: jerger <jerger@noreply.codeberg.org> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-08-26 10:10:46 +02:00
pgsql:
image: data.forgejo.org/oci/bitnami/postgresql:16
env:
POSTGRESQL_DATABASE: test
POSTGRESQL_PASSWORD: postgres
POSTGRESQL_FSYNC: off
POSTGRESQL_EXTRA_FLAGS: -c full_page_writes=off
options: --tmpfs /bitnami/postgresql
cacher:
image: registry.redict.io/redict:7.3.6-scratch
chore: collect coverage using GOCOVERDIR (#9004) - run all unit tests and integration tests in sequence in the same job - upload the coverage data as an artifact to the run - only run via dispatch because it is very long - arguments are used to select which unit or integration tests to focus on Refs https://go.dev/blog/integration-test-coverage ### Testing - Run this workflow via workflow_dispatch (see https://codeberg.org/forgejo-integration/forgejo/actions/runs/11889) - Download the coverage information (see https://codeberg.org/forgejo-integration/forgejo/actions/runs/11889/artifacts/coverage) - Download the coverage information from an end-to-end cascade test (see https://code.forgejo.org/forgejo/end-to-end/actions/runs/3961) - Unzip them in a the `coverage/data` sub-directory at the root of the Forgejo source tree ```sh $ ls coverage/data actions coverage-actions.zip coverage-federation.zip coverage-tests.zip coverage-upgrade.zip federation tests upgrade ``` - Display the coverage percentage ``` $ make coverage-show-percentage ... forgejo.org/services/wiki/wiki_path.go:96: WebPathToGitPath 81.8% forgejo.org/services/wiki/wiki_path.go:113: GitPathToWebPath 90.0% forgejo.org/services/wiki/wiki_path.go:129: WebPathToUserTitle 71.4% forgejo.org/services/wiki/wiki_path.go:140: WebPathToURLPath 100.0% forgejo.org/services/wiki/wiki_path.go:144: WebPathFromRequest 100.0% forgejo.org/services/wiki/wiki_path.go:151: UserTitleToWebPath 80.0% forgejo.org/services/wiki/wiki_path.go:163: ToWikiPageMetaData 100.0% forgejo.org/tests/integration/api_repo_file_helpers.go:18: createFileInBranch 100.0% ... total: (statements) 63.9% ``` Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9004 Reviewed-by: jerger <jerger@noreply.codeberg.org> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-08-26 10:10:46 +02:00
options: --tmpfs /data:noatime
steps:
- uses: https://data.forgejo.org/actions/checkout@v6
chore: collect coverage using GOCOVERDIR (#9004) - run all unit tests and integration tests in sequence in the same job - upload the coverage data as an artifact to the run - only run via dispatch because it is very long - arguments are used to select which unit or integration tests to focus on Refs https://go.dev/blog/integration-test-coverage ### Testing - Run this workflow via workflow_dispatch (see https://codeberg.org/forgejo-integration/forgejo/actions/runs/11889) - Download the coverage information (see https://codeberg.org/forgejo-integration/forgejo/actions/runs/11889/artifacts/coverage) - Download the coverage information from an end-to-end cascade test (see https://code.forgejo.org/forgejo/end-to-end/actions/runs/3961) - Unzip them in a the `coverage/data` sub-directory at the root of the Forgejo source tree ```sh $ ls coverage/data actions coverage-actions.zip coverage-federation.zip coverage-tests.zip coverage-upgrade.zip federation tests upgrade ``` - Display the coverage percentage ``` $ make coverage-show-percentage ... forgejo.org/services/wiki/wiki_path.go:96: WebPathToGitPath 81.8% forgejo.org/services/wiki/wiki_path.go:113: GitPathToWebPath 90.0% forgejo.org/services/wiki/wiki_path.go:129: WebPathToUserTitle 71.4% forgejo.org/services/wiki/wiki_path.go:140: WebPathToURLPath 100.0% forgejo.org/services/wiki/wiki_path.go:144: WebPathFromRequest 100.0% forgejo.org/services/wiki/wiki_path.go:151: UserTitleToWebPath 80.0% forgejo.org/services/wiki/wiki_path.go:163: ToWikiPageMetaData 100.0% forgejo.org/tests/integration/api_repo_file_helpers.go:18: createFileInBranch 100.0% ... total: (statements) 63.9% ``` Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9004 Reviewed-by: jerger <jerger@noreply.codeberg.org> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-08-26 10:10:46 +02:00
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
- uses: ./.forgejo/workflows-composite/setup-env
- name: install git >= 2.42
uses: ./.forgejo/workflows-composite/apt-install-from
with:
packages: git
- uses: ./.forgejo/workflows-composite/build-backend
- run: |
su forgejo -c '${{ inputs.unit-tests-env }} make coverage-run'
su forgejo -c '${{ inputs.integration-tests-env }} make coverage-run-pgsql'
su forgejo -c '${{ inputs.integration-tests-env }} make coverage-run-mysql'
su forgejo -c '${{ inputs.integration-tests-env }} make coverage-run-sqlite'
su forgejo -c 'make coverage-merge'
timeout-minutes: 180
env:
TEST_ELASTICSEARCH_URL: http://elasticsearch:9200
TEST_MINIO_ENDPOINT: minio:9000
TEST_LDAP: 1
TEST_REDIS_SERVER: cacher:6379
- uses: https://data.forgejo.org/forgejo/upload-artifact@v5
chore: collect coverage using GOCOVERDIR (#9004) - run all unit tests and integration tests in sequence in the same job - upload the coverage data as an artifact to the run - only run via dispatch because it is very long - arguments are used to select which unit or integration tests to focus on Refs https://go.dev/blog/integration-test-coverage ### Testing - Run this workflow via workflow_dispatch (see https://codeberg.org/forgejo-integration/forgejo/actions/runs/11889) - Download the coverage information (see https://codeberg.org/forgejo-integration/forgejo/actions/runs/11889/artifacts/coverage) - Download the coverage information from an end-to-end cascade test (see https://code.forgejo.org/forgejo/end-to-end/actions/runs/3961) - Unzip them in a the `coverage/data` sub-directory at the root of the Forgejo source tree ```sh $ ls coverage/data actions coverage-actions.zip coverage-federation.zip coverage-tests.zip coverage-upgrade.zip federation tests upgrade ``` - Display the coverage percentage ``` $ make coverage-show-percentage ... forgejo.org/services/wiki/wiki_path.go:96: WebPathToGitPath 81.8% forgejo.org/services/wiki/wiki_path.go:113: GitPathToWebPath 90.0% forgejo.org/services/wiki/wiki_path.go:129: WebPathToUserTitle 71.4% forgejo.org/services/wiki/wiki_path.go:140: WebPathToURLPath 100.0% forgejo.org/services/wiki/wiki_path.go:144: WebPathFromRequest 100.0% forgejo.org/services/wiki/wiki_path.go:151: UserTitleToWebPath 80.0% forgejo.org/services/wiki/wiki_path.go:163: ToWikiPageMetaData 100.0% forgejo.org/tests/integration/api_repo_file_helpers.go:18: createFileInBranch 100.0% ... total: (statements) 63.9% ``` Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9004 Reviewed-by: jerger <jerger@noreply.codeberg.org> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-08-26 10:10:46 +02:00
with:
name: coverage
path: ${{ forge.workspace }}/coverage/merged