105 lines
3.5 KiB
YAML
105 lines
3.5 KiB
YAML
name: PR checks
|
|
|
|
on:
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
java:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: Setup JDK 21
|
|
uses: actions/setup-java@v5
|
|
with:
|
|
java-version: '21'
|
|
distribution: 'temurin'
|
|
|
|
- name: Cache Maven repository
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.m2/repository
|
|
key: maven-${{ hashFiles('pom.xml', 'wordpdf-core/pom.xml', 'wordpdf-app/pom.xml') }}
|
|
restore-keys: maven-
|
|
|
|
- name: Setup Maven 3.9.16
|
|
run: |
|
|
curl -fsSL https://dlcdn.apache.org/maven/maven-3/3.9.16/binaries/apache-maven-3.9.16-bin.tar.gz | tar xz -C /opt
|
|
echo "/opt/apache-maven-3.9.16/bin" >> "$GITHUB_PATH"
|
|
|
|
- name: Build and test (PMD gate included)
|
|
run: mvn -B clean verify
|
|
|
|
- name: Coverage summary
|
|
if: always()
|
|
run: |
|
|
python3 - <<'PY' >> "$GITHUB_STEP_SUMMARY"
|
|
import os
|
|
import xml.etree.ElementTree as ET
|
|
def pct(root, kind):
|
|
for c in root.findall("counter"):
|
|
if c.get("type") == kind:
|
|
missed, covered = int(c.get("missed")), int(c.get("covered"))
|
|
return f"{100.0 * covered / (missed + covered):.1f}%"
|
|
return "—"
|
|
print("## Покрытие (JaCoCo)\n")
|
|
print("| Модуль | Строки | Ветви | Порог строк |")
|
|
print("|---|---|---|---|")
|
|
for m in ("wordpdf-core", "wordpdf-app"):
|
|
p = f"{m}/target/site/jacoco/jacoco.xml"
|
|
if not os.path.exists(p):
|
|
print(f"| {m} | нет данных | — | 90% |")
|
|
continue
|
|
r = ET.parse(p).getroot()
|
|
print(f"| {m} | {pct(r, 'LINE')} | {pct(r, 'BRANCH')} | 90% |")
|
|
PY
|
|
|
|
# v3, не v4: артефакт-сервер Gitea говорит по протоколу actions/artifact v1,
|
|
# v4+ падает «not currently supported on GHES». Один zip вместо ~150 файлов:
|
|
# v1 грузит каждый файл отдельным запросом — поштучно это минуты;
|
|
# python3 (не zip) — гарантирован на раннере, см. шаг Coverage summary
|
|
- name: Pack coverage reports
|
|
if: always()
|
|
run: |
|
|
python3 - <<'PY'
|
|
import os, zipfile
|
|
with zipfile.ZipFile("jacoco-html.zip", "w", zipfile.ZIP_DEFLATED) as z:
|
|
for m in ("wordpdf-core", "wordpdf-app"):
|
|
d = f"{m}/target/site/jacoco"
|
|
for root, _, files in os.walk(d):
|
|
for f in files:
|
|
p = os.path.join(root, f)
|
|
z.write(p, p)
|
|
PY
|
|
- name: Upload coverage reports
|
|
if: always()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: jacoco-html
|
|
path: jacoco-html.zip
|
|
|
|
web:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: Cache npm
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.npm
|
|
key: npm-${{ hashFiles('wordpdf-web/package-lock.json') }}
|
|
restore-keys: npm-
|
|
|
|
- name: Install dependencies
|
|
working-directory: wordpdf-web
|
|
run: npm ci
|
|
|
|
- name: Build SPA
|
|
working-directory: wordpdf-web
|
|
run: npm run build
|
|
|
|
- name: Lint SPA
|
|
working-directory: wordpdf-web
|
|
run: npm run lint
|