Skip to content

develop

develop #48

Workflow file for this run

name: Release Checks
on:
pull_request:
branches:
- release
jobs:
check-dart-lines:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.6'
- name: Count Dart lines in PR
id: count_lines
run: |
# Fetching the changes from the base branch to compare the PR changes
git fetch origin ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
# Get the list of added or modified Dart files in the PR
dart_files=$(git diff --name-only --diff-filter=AMR origin/${{ github.base_ref }}...${{ github.head_ref }} | grep '\.dart$')
# Initialize line count
line_count=0
# Loop through each Dart file and count lines
for file in $dart_files; do
if [ -f "$file" ]; then
file_lines=$(wc -l < "$file")
line_count=$((line_count + file_lines))
fi
done
echo "Total Dart lines of code: $line_count"
echo "line_count=$line_count" >> $GITHUB_ENV
- name: Fail if Dart lines exceed limit
if: env.line_count > 20
run: |
echo "The number of Dart lines in the PR exceeds the limit of 20 lines."
exit 1
check-asset-size:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.6'
- name: Check asset sizes in PR
run: |
# Fetching the changes from the base branch to compare the PR changes
git fetch origin ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
# Set asset size limit in bytes (e.g., 5 MB = 5 * 1024 * 1024 bytes)
ASSET_SIZE_LIMIT=$((5 * 1024 * 1024))
# Get the list of added or modified asset files in PR (common Flutter asset directories)
asset_files=$(git diff --name-only --diff-filter=AMR origin/${{ github.base_ref }}...${{ github.head_ref }} | grep -E '^assets/|^images/|^res/|^icons/' | grep -E '\.(png|jpg|jpeg|gif|svg|webp|mp4|mp3|json|xml)$')
# Initialize total asset size
total_asset_size=0
# Calculate the size of each asset file
for file in $asset_files; do
if [ -f "$file" ]; then
file_size=$(stat -c%s "$file")
total_asset_size=$((total_asset_size + file_size))
fi
done
echo "Total asset size: $total_asset_size bytes"
# Check if the total asset size exceeds the limit
if [ "$total_asset_size" -gt "$ASSET_SIZE_LIMIT" ]; then
echo "The total asset size exceeds the limit of $ASSET_SIZE_LIMIT bytes."
exit 1
else
echo "Asset size is within the limit."
fi