130 lines
3.8 KiB
YAML
130 lines
3.8 KiB
YAML
name: ci
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- "back001/**"
|
|
- "front001/**"
|
|
- ".forgejo/workflows/**"
|
|
- "ci/**"
|
|
pull_request:
|
|
|
|
jobs:
|
|
changes:
|
|
runs-on: docker
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- id: filter
|
|
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
|
|
outputs:
|
|
backend: ${{ steps.filter.outputs.backend }}
|
|
frontend: ${{ steps.filter.outputs.frontend }}
|
|
|
|
backend:
|
|
needs: changes
|
|
if: needs.changes.outputs.backend == 'true'
|
|
runs-on: docker
|
|
container:
|
|
image: forgejo.okit.pl/oskar/ci-gradle-node:8.7-jdk17
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- 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 }}-
|
|
|
|
- name: Test + build (backend)
|
|
working-directory: back001
|
|
run: ./gradlew test build --no-daemon
|
|
|
|
flutter:
|
|
needs: changes
|
|
if: needs.changes.outputs.frontend == 'true'
|
|
runs-on: docker
|
|
container:
|
|
image: forgejo.okit.pl/oskar/ci-flutter-node:stable
|
|
steps:
|
|
- 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
|
|
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
|