-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add code validation and unit test workflows for PRs
- Loading branch information
1 parent
e296b1b
commit 526e17d
Showing
3 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: "Generates assets" | ||
description: "Runs the flutter build command to transform and generate assets for the deployment build" | ||
|
||
inputs: | ||
GITHUB_TOKEN: | ||
description: "The GitHub API public readonly token" | ||
required: false | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Fetch packages and generate assets | ||
shell: bash | ||
env: | ||
GITHUB_API_PUBLIC_READONLY_TOKEN: ${{ inputs.GITHUB_TOKEN }} | ||
run: | | ||
echo "Running \`flutter build\` to generate assets for the deployment build" | ||
if [ -n "$GITHUB_API_PUBLIC_READONLY_TOKEN" ]; then | ||
echo "GITHUB_TOKEN provided, running flutter build with token" | ||
else | ||
echo "GITHUB_TOKEN not provided or empty, running flutter build without token" | ||
unset GITHUB_API_PUBLIC_READONLY_TOKEN | ||
fi | ||
flutter pub get > /dev/null 2>&1 | ||
flutter build web --release > /dev/null 2>&1 || true | ||
rm -rf build/* | ||
# Run flutter build and capture its output and exit status | ||
flutter pub get > /dev/null 2>&1 | ||
output=$(flutter build web --release) | ||
exit_status=$? | ||
# Check if the exit status is non-zero (indicating an error) | ||
if [ $exit_status -ne 0 ]; then | ||
echo "Flutter build exited with status $exit_status. Output:" | ||
echo "$output" | ||
exit $exit_status | ||
fi | ||
echo "Done fetching packages and generating assets" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Runs unit tests on PRs to ensure the app is working as expected | ||
name: Run unit tests for packages on PR | ||
run-name: ${{ github.actor }} is running unit tests on PR 🚀 | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
paths: | ||
- "packages/**" | ||
|
||
jobs: | ||
unit_tests_: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
|
||
steps: | ||
- name: Setup GH Actions | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get stable flutter | ||
uses: subosito/flutter-action@v2 | ||
with: | ||
channel: "stable" | ||
|
||
- name: Fetch packages and generate assets | ||
uses: ./.github/actions/generate-assets | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Test unit_test (unix) | ||
id: unit_tests | ||
continue-on-error: false | ||
timeout-minutes: 15 | ||
run: | | ||
cd packages | ||
for package in */; do | ||
echo "Running tests for $package" | ||
cd "$package" | ||
if [ -d "test" ]; then | ||
flutter clean | ||
rm -rf build/* | ||
rm -rf web/src/mm2/* | ||
rm -rf web/src/kdfi/* | ||
rm -rf web/dist/* | ||
flutter test | ||
else | ||
echo "No test directory found in $package" | ||
fi | ||
cd .. | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Rule for running static analysis and code formatting checks on all PRs | ||
# Runs static analysis and code formatting checks on all PRs to ensure the codebase is clean and consistent | ||
name: Validate Packages Code Guidelines | ||
run-name: ${{ github.actor }} is validating code guidelines 🚀 | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- "*" | ||
paths: | ||
- "packages/**" | ||
|
||
jobs: | ||
validate_packages_code_guidelines: | ||
runs-on: macos-latest | ||
|
||
steps: | ||
- name: Setup GH Actions | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get stable flutter | ||
uses: subosito/flutter-action@v2 | ||
with: | ||
channel: "stable" | ||
|
||
- name: Fetch packages and generate assets | ||
uses: ./.github/actions/generate-assets | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Validate dart code | ||
run: | | ||
cd packages | ||
for package in */; do | ||
echo "Analyzing package: $package" | ||
cd "$package" | ||
flutter analyze | ||
cd .. | ||
done |