fix(ci): enforce automation checks
This commit is contained in:
@@ -470,7 +470,7 @@ jobs:
|
|||||||
key: ${{ runner.os }}-${{ runner.arch }}-pub-v2-${{ hashFiles('pubspec.yaml', 'pubspec.lock') }}
|
key: ${{ runner.os }}-${{ runner.arch }}-pub-v2-${{ hashFiles('pubspec.yaml', 'pubspec.lock') }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: flutter pub get --no-example
|
run: flutter pub get --enforce-lockfile --no-example
|
||||||
|
|
||||||
- name: Install patched Flutter engine (DComp)
|
- name: Install patched Flutter engine (DComp)
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
@@ -768,7 +768,7 @@ jobs:
|
|||||||
run: sudo gem install fpm
|
run: sudo gem install fpm
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: flutter pub get --no-example
|
run: flutter pub get --enforce-lockfile --no-example
|
||||||
|
|
||||||
- name: Build Linux arm64
|
- 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
|
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
|
||||||
|
|||||||
@@ -40,26 +40,14 @@ jobs:
|
|||||||
flutter pub get
|
flutter pub get
|
||||||
|
|
||||||
- name: Verify generated files committed
|
- name: Verify generated files committed
|
||||||
run: |
|
run: scripts/codegen.sh --check
|
||||||
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
|
|
||||||
|
|
||||||
- name: Verify formatting
|
- name: Verify formatting
|
||||||
run: |
|
run: |
|
||||||
# Find all Dart files excluding generated files
|
paths=(lib)
|
||||||
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
|
[ ! -d test ] || paths+=(test)
|
||||||
files_found=true
|
find "${paths[@]}" -name "*.dart" ! -name "*.g.dart" ! -name "*.freezed.dart" -type f -print0 |
|
||||||
break
|
xargs -0 -r dart format --output=none --set-exit-if-changed
|
||||||
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
|
|
||||||
- name: Analyze code
|
- name: Analyze code
|
||||||
run: |
|
run: |
|
||||||
# Run flutter analyze
|
# Run flutter analyze
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Trigger build workflow
|
- name: Trigger build workflow
|
||||||
run: |
|
run: |
|
||||||
curl -L \
|
curl --fail-with-body -L \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Accept: application/vnd.github+json" \
|
-H "Accept: application/vnd.github+json" \
|
||||||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
|
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
id: release
|
id: release
|
||||||
run: |
|
run: |
|
||||||
VERSION="${{ github.event.release.tag_name || github.ref_name }}"
|
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"
|
"https://github.com/edde746/plezy/releases/download/$VERSION/plezy-macos.dmg"
|
||||||
SHA256=$(shasum -a 256 plezy-macos.dmg | cut -d' ' -f1)
|
SHA256=$(shasum -a 256 plezy-macos.dmg | cut -d' ' -f1)
|
||||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|||||||
+5
-2
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
1. Fork and clone the repository
|
1. Fork and clone the repository
|
||||||
2. Run `flutter pub get` to install dependencies
|
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!
|
4. Start developing!
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
@@ -30,7 +30,10 @@ The project includes automated CI checks that run on all pull requests:
|
|||||||
- Run locally: `flutter analyze`
|
- Run locally: `flutter analyze`
|
||||||
- Note: CI excludes generated files from analysis (configured in `analysis_options.yaml`)
|
- 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`
|
- Run locally: `flutter test`
|
||||||
|
|
||||||
All these checks must pass before your changes can be merged.
|
All these checks must pass before your changes can be merged.
|
||||||
|
|||||||
+7
-15
@@ -59,25 +59,17 @@ else
|
|||||||
rm -f "$out"
|
rm -f "$out"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 2. Codegen freshness (build_runner outputs newer than their sources)
|
# 2. Codegen freshness
|
||||||
section "codegen freshness"
|
section "codegen freshness"
|
||||||
stale=()
|
out="$(mktemp)"
|
||||||
while IFS= read -r -d '' src; do
|
if scripts/codegen.sh --check >"$out" 2>&1; then
|
||||||
for gen in "${src%.dart}.g.dart" "${src%.dart}.freezed.dart"; do
|
ok "generated files are current"
|
||||||
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"
|
|
||||||
else
|
else
|
||||||
fail "${#stale[@]} dart source(s) newer than their generated .g/.freezed:"
|
fail "generated files are stale"
|
||||||
printf ' %s\n' "${stale[@]}"
|
sed 's/^/ /' "$out"
|
||||||
echo " Run: scripts/codegen.sh"
|
|
||||||
FAILED=1
|
FAILED=1
|
||||||
fi
|
fi
|
||||||
|
rm -f "$out"
|
||||||
|
|
||||||
# 3. Native formatting
|
# 3. Native formatting
|
||||||
section "native format"
|
section "native format"
|
||||||
|
|||||||
+24
-1
@@ -1,5 +1,28 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||||
|
|
||||||
|
check=false
|
||||||
|
if [[ "${1:-}" == "--check" ]]; then
|
||||||
|
check=true
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
dart run slang
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user