mosenioring/.forgejo/workflows/ci.yml

130 lines
3.8 KiB
YAML
Raw Normal View History

2026-01-15 23:20:07 +01:00
name: ci
on:
push:
paths:
- "back001/**"
- "front001/**"
- ".forgejo/workflows/**"
2026-01-16 14:27:30 +01:00
- "ci/**"
2026-01-15 23:20:07 +01:00
pull_request:
jobs:
2026-01-16 15:37:53 +01:00
changes:
runs-on: docker
steps:
- uses: actions/checkout@v4
- id: filter
2026-01-16 15:40:24 +01:00
name: Detect changes
run: |
python - <<'PY'
import json
import os
import subprocess
import sys
event_path = os.environ.get("GITHUB_EVENT_PATH")
base = None
head = None
if event_path and os.path.exists(event_path):
with open(event_path, "r", encoding="utf-8") as handle:
data = json.load(handle)
if "pull_request" in data:
base = data["pull_request"]["base"]["sha"]
head = data["pull_request"]["head"]["sha"]
else:
base = data.get("before")
head = data.get("after") or data.get("checkout_sha")
if not head:
head = os.environ.get("GITHUB_SHA")
if not base or base == "0000000000000000000000000000000000000000":
try:
subprocess.check_call(
["git", "rev-parse", f"{head}^"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
base = f"{head}^"
except Exception:
base = None
if base:
diff_cmd = ["git", "diff", "--name-only", base, head]
else:
diff_cmd = ["git", "ls-files"]
files = subprocess.check_output(diff_cmd, text=True).splitlines()
backend = False
frontend = False
for path in files:
if path.startswith("back001/") or path.startswith(".forgejo/workflows/") or path.startswith("ci/"):
backend = True
if path.startswith("front001/") or path.startswith(".forgejo/workflows/") or path.startswith("ci/"):
frontend = True
out_path = os.environ.get("GITHUB_OUTPUT")
if not out_path:
print("GITHUB_OUTPUT not set", file=sys.stderr)
sys.exit(1)
with open(out_path, "a", encoding="utf-8") as handle:
handle.write(f"backend={'true' if backend else 'false'}\n")
handle.write(f"frontend={'true' if frontend else 'false'}\n")
PY
2026-01-16 15:37:53 +01:00
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
2026-01-15 23:20:07 +01:00
backend:
2026-01-16 15:37:53 +01:00
needs: changes
if: needs.changes.outputs.backend == 'true'
2026-01-15 23:20:07 +01:00
runs-on: docker
container:
2026-01-16 15:08:02 +01:00
image: forgejo.okit.pl/oskar/ci-gradle-node:8.7-jdk17
2026-01-15 23:20:07 +01:00
steps:
2026-01-16 14:27:30 +01:00
- uses: actions/checkout@v4
2026-01-16 14:27:30 +01:00
- uses: actions/cache@v4
with:
path: |
/home/gradle/.gradle/caches
/home/gradle/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('back001/**/*.gradle*', 'back001/**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
2026-01-15 23:20:07 +01:00
- name: Test + build (backend)
working-directory: back001
2026-01-15 23:23:57 +01:00
run: ./gradlew test build --no-daemon
2026-01-15 23:20:07 +01:00
flutter:
2026-01-16 15:37:53 +01:00
needs: changes
if: needs.changes.outputs.frontend == 'true'
2026-01-15 23:20:07 +01:00
runs-on: docker
container:
2026-01-16 14:32:39 +01:00
image: forgejo.okit.pl/oskar/ci-flutter-node:stable
2026-01-15 23:20:07 +01:00
steps:
2026-01-16 14:27:30 +01:00
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
/root/.pub-cache
key: pub-${{ runner.os }}-${{ hashFiles('front001/mosenioring/pubspec.lock') }}
restore-keys: |
pub-${{ runner.os }}-
- name: Pub get
2026-01-15 23:20:07 +01:00
working-directory: front001/mosenioring
run: flutter pub get
- name: Analyze (non-blocking for now)
working-directory: front001/mosenioring
run: flutter analyze || true
- name: Test
working-directory: front001/mosenioring
run: flutter test