Skip to content

Commit

Permalink
Refine coverage checking (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavetok authored Sep 11, 2023
1 parent 4e3b553 commit fc2fd3b
Show file tree
Hide file tree
Showing 114 changed files with 406 additions and 470 deletions.
34 changes: 17 additions & 17 deletions .dx/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@
ansible.builtin.debug:
msg: "{{ binary_status.cmd|join(' ') }}"
when: binary_status is changed
- name: Test and create binaries
- name: Create binaries
ansible.builtin.command:
cmd: >
mvn
--no-snapshot-updates
--fail-fast
--batch-mode
--threads 2C
--define revision={{ lib_version }}
--threads 1C
clean
{% if focus == 'solution' %}
deploy
{% else %}
install
{% endif %}
--define revision={{ lib_version }}
chdir: "{{ playbook_dir }}/../libs"
changed_when: true
when: binary_status is changed
Expand Down Expand Up @@ -72,43 +72,43 @@
msg: "{{ image_status.results|map(attribute='cmd')|map('join', ' ') }}"
when: image_status is changed
tags: [always]
- name: Test units and create binaries
- name: Create binaries
ansible.builtin.command:
cmd: >
mvn
--no-snapshot-updates
--fail-fast
--batch-mode
--threads 2C
--threads 1C
{% if not hostvars.lib.binary_status|default({}) is changed %}
--projects {{ image_status.results|select('changed')|map(attribute='item.key')|join(',') }}
{% endif %}
--define revision={{ app_version }}
--define lib.version={{ lib_version }}
clean
{% if up_to_images|default(false) %}
verify
{% else %}
package
{% endif %}
--define revision={{ app_version }}
--define lib.version={{ lib_version }}
chdir: "{{ playbook_dir }}/../apps"
strip_empty_ends: false
changed_when: true
when: image_status is changed

- name: Coverage
hosts: tool
- name: Binaries
hosts: test
run_once: true
tasks:
- name: Generate reports
- name: Create binaries
ansible.builtin.command:
cmd: >
mvn
--no-snapshot-updates
--batch-mode
clean
antrun:run@units
antrun:run@integrations
antrun:run@overall
chdir: "{{ playbook_dir }}/../.tools"
test-compile
chdir: "{{ playbook_dir }}/../tests"
strip_empty_ends: false
changed_when: true
when: >
hostvars.lib.binary_status|default({}) is changed or
hostvars.app.image_status|default({}) is changed
when: hostvars.lib.binary_status|default({}) is changed
16 changes: 6 additions & 10 deletions .dx/images.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
- import_playbook: binaries.yml # noqa: name[play]
vars:
up_to_images: true
tags: [binaries, deps]

- name: Images
Expand Down Expand Up @@ -33,21 +35,15 @@
hosts: app
run_once: true
tasks:
- name: Test integrations
- name: Analyze coverage
ansible.builtin.command:
cmd: >
mvn
--no-snapshot-updates
--fail-fast
--batch-mode
--threads 2C
{% if not hostvars.lib.binary_status|default({}) is changed %}
--projects {{ image_status.results|select('changed')|map(attribute='item.key')|join(',') }}
{% endif %}
--define lib.version={{ lib_version }}
failsafe:integration-test
failsafe:verify
chdir: "{{ playbook_dir }}/../apps"
clean
antrun:run@coverage
chdir: "{{ playbook_dir }}/../.tools"
strip_empty_ends: false
changed_when: true
when: image_status is changed
Expand Down
1 change: 0 additions & 1 deletion .dx/inventory/aliases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ all:
schema:
test:
dx:
tool:
vars:
ansible_connection: local
stack:
Expand Down
40 changes: 6 additions & 34 deletions .github/workflows/solution-convincing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
permissions:
checks: write
packages: write
pull-requests: write
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/prepare
Expand All @@ -41,7 +40,6 @@ jobs:
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# units reporting
- uses: EnricoMi/[email protected]
if: ${{ !cancelled() }}
with:
Expand All @@ -55,22 +53,6 @@ jobs:
files: |
libs/*/target/surefire-reports/TEST-*.xml
apps/*/target/surefire-reports/TEST-*.xml
- uses: madrapps/[email protected]
if: ${{ github.event_name == 'pull_request' && hashFiles(env.JACOCO_UNITS) != '' }}
with:
title: Unit Coverage Report
paths: ${{ env.JACOCO_UNITS }}
token: ${{ secrets.GITHUB_TOKEN }}
update-comment: true
env:
JACOCO_UNITS: .tools/target/coverage/units/jacoco.xml
- uses: actions/[email protected]
if: ${{ !cancelled() }}
with:
name: units-coverage-report
path: .tools/target/coverage/units
if-no-files-found: ignore
# integrations reporting
- uses: EnricoMi/[email protected]
if: ${{ !cancelled() }}
with:
Expand All @@ -84,22 +66,6 @@ jobs:
files: |
libs/*/target/failsafe-reports/TEST-*.xml
apps/*/target/failsafe-reports/TEST-*.xml
- uses: madrapps/[email protected]
if: ${{ github.event_name == 'pull_request' && hashFiles(env.JACOCO_INTEGRATIONS) != '' }}
with:
title: Integration Coverage Report
paths: ${{ env.JACOCO_INTEGRATIONS }}
token: ${{ secrets.GITHUB_TOKEN }}
update-comment: true
env:
JACOCO_INTEGRATIONS: .tools/target/coverage/integrations/jacoco.xml
- uses: actions/[email protected]
if: ${{ !cancelled() }}
with:
name: integrations-coverage-report
path: .tools/target/coverage/integrations
if-no-files-found: ignore
# fake e2e reporting
- name: Always empty E2E test report. See https://github.com/orgs/community/discussions/13690
uses: EnricoMi/[email protected]
if: ${{ !cancelled() }}
Expand All @@ -112,3 +78,9 @@ jobs:
job_summary: false
comment_mode: off
files: tests/*/target/surefire-reports/TEST-*.xml
- uses: actions/[email protected]
if: ${{ !cancelled() }}
with:
name: test-coverage-report
path: .tools/target/coverage
if-no-files-found: ignore
9 changes: 0 additions & 9 deletions .github/workflows/solution-sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,3 @@ jobs:
files: |
libs/*/target/surefire-reports/TEST-*.xml
apps/*/target/surefire-reports/TEST-*.xml
- uses: madrapps/[email protected]
if: ${{ github.event_name == 'pull_request' && hashFiles(env.JACOCO_UNITS) != '' }}
with:
title: Unit Coverage Report
paths: ${{ env.JACOCO_UNITS }}
token: ${{ secrets.GITHUB_TOKEN }}
update-comment: true
env:
JACOCO_UNITS: .tools/target/coverage/units/jacoco.xml
118 changes: 32 additions & 86 deletions .tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,105 +30,51 @@
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>units</id>
<id>coverage</id>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<taskdef resource="org/jacoco/ant/antlib.xml" classpathref="maven.plugin.classpath"/>
<report>
<html destdir="${project.build.directory}/coverage/units"/>
<xml destfile="${project.build.directory}/coverage/units/jacoco.xml"/>
<executiondata>
<fileset dir="${project.basedir}/..">
<include name="libs/*/target/jacoco.exec"/>
<include name="apps/*/target/jacoco.exec"/>
</fileset>
</executiondata>
<structure name="Units Coverage">
<classfiles>
<fileset dir="${project.basedir}/..">
<include name="libs/*/target/classes/**/*.class"/>
<include name="apps/*/target/classes/**/*.class"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<dirset dir="${project.basedir}/..">
<include name="libs/*/src/main/java"/>
<include name="apps/*/src/main/java"/>
</dirset>
</sourcefiles>
</structure>
</report>
</target>
</configuration>
</execution>
<execution>
<id>integrations</id>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<taskdef resource="org/jacoco/ant/antlib.xml" classpathref="maven.plugin.classpath"/>
<report>
<html destdir="${project.build.directory}/coverage/integrations"/>
<xml destfile="${project.build.directory}/coverage/integrations/jacoco.xml"/>
<executiondata>
<fileset dir="${project.basedir}/..">
<include name="libs/*/target/jacoco-it.exec"/>
<include name="apps/*/target/jacoco-it.exec"/>
</fileset>
</executiondata>
<structure name="Integrations Coverage">
<classfiles>
<fileset dir="${project.basedir}/..">
<include name="libs/*/target/classes/**/*.class"/>
<include name="apps/*/target/classes/**/*.class"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<dirset dir="${project.basedir}/..">
<include name="libs/*/src/main/java"/>
<include name="apps/*/src/main/java"/>
</dirset>
</sourcefiles>
</structure>
</report>
</target>
</configuration>
</execution>
<execution>
<id>overall</id>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<taskdef resource="org/jacoco/ant/antlib.xml" classpathref="maven.plugin.classpath"/>
<report>
<html destdir="${project.build.directory}/coverage/overall"/>
<xml destfile="${project.build.directory}/coverage/overall/jacoco.xml"/>
<html destdir="${project.build.directory}/coverage"/>
<check>
<rule element="CLASS">
<limit counter="METHOD" value="MISSEDCOUNT" maximum="3"/>
</rule>
</check>
<executiondata>
<fileset dir="${project.basedir}/..">
<include name="libs/*/target/*.exec"/>
<include name="apps/*/target/*.exec"/>
</fileset>
</executiondata>
<structure name="Overall Coverage">
<classfiles>
<fileset dir="${project.basedir}/..">
<include name="libs/*/target/classes/**/*.class"/>
<include name="apps/*/target/classes/**/*.class"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<dirset dir="${project.basedir}/..">
<include name="libs/*/src/main/java"/>
<include name="apps/*/src/main/java"/>
</dirset>
</sourcefiles>
<structure name="Test coverage">
<group name="libs">
<classfiles>
<fileset dir="${project.basedir}/../libs">
<include name="*/target/classes/**/impl/**/*.class"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<dirset dir="${project.basedir}/../libs">
<include name="*/src/main/java"/>
</dirset>
</sourcefiles>
</group>
<group name="apps">
<classfiles>
<fileset dir="${project.basedir}/../apps">
<include name="*/target/classes/**/impl/**/*.class"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<dirset dir="${project.basedir}/../apps">
<include name="*/src/main/java"/>
</dirset>
</sourcefiles>
</group>
</structure>
</report>
</target>
Expand Down
6 changes: 3 additions & 3 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@

==== В пределах разумного (sanity)

Запускаем анализ зависимостей, линтинг, статический анализ, компиляцию, модульные тесты, анализируем покрытие и собираем бинарники решения.
Запускаем анализ зависимостей, линтинг, статический анализ, компиляцию, модульные тесты и собираем/публикуем бинарники.

==== Убедительная (convincing)

Все перечисленное ранее. Плюс запускаем интеграционные тесты, собираем и публикуем образы.
Все перечисленное ранее. Плюс запускаем интеграционные тесты, анализируем покрытие и собираем/публикуем образы.

==== За пределами сомнений (beyond doubt)

Все перечисленное ранее. Плюс запускаем сквозные тесты, собираем и публикуем решения.
Все перечисленное ранее. Плюс запускаем сквозные тесты, собираем/публикуем решения.

=== Проверка конвейера

Expand Down
2 changes: 1 addition & 1 deletion apps/foo/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ COPY app-foo*.jar foo/app.jar
ENTRYPOINT [ \
"java", "-cp", "foo/app.jar:foo/libs/*", \
"-Dconfig.file=foo/application.conf", \
"org.smecalculus.bezmen.construction.App" \
"org.smecalculus.bezmen.construction.spec.App" \
]
Loading

0 comments on commit fc2fd3b

Please sign in to comment.