fix(ci): enforce automation checks

This commit is contained in:
edde746
2026-07-12 08:42:18 +02:00
parent 64db84c3e2
commit e4b0680158
7 changed files with 45 additions and 39 deletions
+2 -2
View File
@@ -470,7 +470,7 @@ jobs:
key: ${{ runner.os }}-${{ runner.arch }}-pub-v2-${{ hashFiles('pubspec.yaml', 'pubspec.lock') }}
- name: Install dependencies
run: flutter pub get --no-example
run: flutter pub get --enforce-lockfile --no-example
- name: Install patched Flutter engine (DComp)
shell: pwsh
@@ -768,7 +768,7 @@ jobs:
run: sudo gem install fpm
- name: Install dependencies
run: flutter pub get --no-example
run: flutter pub get --enforce-lockfile --no-example
- name: Build Linux arm64
run: flutter build linux --release --dart-define=ENABLE_UPDATE_CHECK=true ${{ env.SENTRY_DART_DEFINE }} ${{ env.GIT_COMMIT_DART_DEFINE }} ${{ env.SENTRY_ENV_DART_DEFINE }} --dart-define=SENTRY_DIST=github-linux-arm64 ${{ env.DONATIONS_DART_DEFINE }} --split-debug-info=debug-info/linux-arm64
+5 -17
View File
@@ -40,26 +40,14 @@ jobs:
flutter pub get
- name: Verify generated files committed
run: |
scripts/codegen.sh
if ! git diff --exit-code lib/; then
echo "::error::Generated files (.g.dart / .freezed.dart) are out of date."
echo "Run 'scripts/codegen.sh' and commit the result."
exit 1
fi
run: scripts/codegen.sh --check
- name: Verify formatting
run: |
# Find all Dart files excluding generated files
find lib $([ -d test ] && echo test) -name "*.dart" ! -name "*.g.dart" ! -name "*.freezed.dart" -type f 2>/dev/null | while IFS= read -r file; do
files_found=true
break
done
if [ "$files_found" != "true" ]; then
echo "No Dart files found to format"
exit 0
fi
find lib $([ -d test ] && echo test) -name "*.dart" ! -name "*.g.dart" ! -name "*.freezed.dart" -type f 2>/dev/null -print0 | xargs -0 dart format --output=none --set-exit-if-changed
paths=(lib)
[ ! -d test ] || paths+=(test)
find "${paths[@]}" -name "*.dart" ! -name "*.g.dart" ! -name "*.freezed.dart" -type f -print0 |
xargs -0 -r dart format --output=none --set-exit-if-changed
- name: Analyze code
run: |
# Run flutter analyze
+1 -1
View File
@@ -71,7 +71,7 @@ jobs:
- name: Trigger build workflow
run: |
curl -L \
curl --fail-with-body -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
+1 -1
View File
@@ -20,7 +20,7 @@ jobs:
id: release
run: |
VERSION="${{ github.event.release.tag_name || github.ref_name }}"
curl -L -o plezy-macos.dmg \
curl --fail-with-body -L -o plezy-macos.dmg \
"https://github.com/edde746/plezy/releases/download/$VERSION/plezy-macos.dmg"
SHA256=$(shasum -a 256 plezy-macos.dmg | cut -d' ' -f1)
echo "version=$VERSION" >> $GITHUB_OUTPUT
+5 -2
View File
@@ -4,7 +4,7 @@
1. Fork and clone the repository
2. Run `flutter pub get` to install dependencies
3. Run `dart run build_runner build` to generate code
3. Run `scripts/codegen.sh` to generate translations and Dart model code
4. Start developing!
## Development
@@ -30,7 +30,10 @@ The project includes automated CI checks that run on all pull requests:
- Run locally: `flutter analyze`
- Note: CI excludes generated files from analysis (configured in `analysis_options.yaml`)
3. **Tests**: Runs unit and widget tests (when available)
3. **Generated Code**: Ensures generated translations and model files are current
- Run locally: `scripts/codegen.sh --check`
4. **Tests**: Runs unit and widget tests (when available)
- Run locally: `flutter test`
All these checks must pass before your changes can be merged.
+7 -15
View File
@@ -59,25 +59,17 @@ else
rm -f "$out"
fi
# 2. Codegen freshness (build_runner outputs newer than their sources)
# 2. Codegen freshness
section "codegen freshness"
stale=()
while IFS= read -r -d '' src; do
for gen in "${src%.dart}.g.dart" "${src%.dart}.freezed.dart"; do
if [ -f "$gen" ] && [ "$src" -nt "$gen" ]; then
stale+=("${src#./}")
break
fi
done
done < <(find lib -name "*.dart" ! -name "*.g.dart" ! -name "*.freezed.dart" -type f -print0 2>/dev/null)
if [ ${#stale[@]} -eq 0 ]; then
ok "no stale generated files"
out="$(mktemp)"
if scripts/codegen.sh --check >"$out" 2>&1; then
ok "generated files are current"
else
fail "${#stale[@]} dart source(s) newer than their generated .g/.freezed:"
printf ' %s\n' "${stale[@]}"
echo " Run: scripts/codegen.sh"
fail "generated files are stale"
sed 's/^/ /' "$out"
FAILED=1
fi
rm -f "$out"
# 3. Native formatting
section "native format"
+24 -1
View File
@@ -1,5 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
check=false
if [[ "${1:-}" == "--check" ]]; then
check=true
shift
fi
dart run slang
exec dart run build_runner build --delete-conflicting-outputs "$@"
dart run build_runner build --delete-conflicting-outputs "$@"
if $check; then
generated_changes="$({
git diff --name-only -- lib
git ls-files --others --exclude-standard -- \
':(glob)lib/**/*.g.dart' \
':(glob)lib/**/*.freezed.dart'
} | grep -E '\.(g|freezed)\.dart$' || true)"
if [[ -n "$generated_changes" ]]; then
echo "Generated files are out of date:" >&2
printf ' %s\n' "$generated_changes" >&2
echo "Run 'scripts/codegen.sh' and commit the result." >&2
exit 1
fi
fi