Skip to content

Development

Development #10

Workflow file for this run

name: "Checks"
on:
pull_request:
branches: [ main, next, development ]
types: [ opened, synchronize, reopened ]
jobs:
lint-dart:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Flutter
uses: flutter-actions/setup-flutter@v4
with:
channel: stable
version: 3.38.8
cache: true
cache-sdk: true
cache-key: ${{ runner.os }}-flutter-${{ hashFiles('pubspec.yaml') }}
- name: Install dependencies
run: flutter pub get
- name: Run analyze
run: flutter analyze
- name: Run tests
run: flutter test --machine > test-results.json
- name: Publish test results
uses: dorny/test-reporter@v1
if: always()
with:
name: Unit Tests
path: test-results.json
reporter: flutter-json
- name: Parse test results
if: always()
id: test_summary
run: |
if [ -f test-results.json ]; then
# Count total tests and failures from the JSON output
TOTAL=$(grep -c '"type":"testStart"' test-results.json || echo "0")
FAILED=$(grep -c '"result":"error"' test-results.json || echo "0")
PASSED=$((TOTAL - FAILED))
# Calculate percentage
if [ $TOTAL -gt 0 ]; then
PASS_RATE=$(awk "BEGIN {printf \"%.1f\", ($PASSED/$TOTAL)*100}")
else
PASS_RATE="0.0"
fi
echo "total=$TOTAL" >> $GITHUB_OUTPUT
echo "passed=$PASSED" >> $GITHUB_OUTPUT
echo "failed=$FAILED" >> $GITHUB_OUTPUT
echo "pass_rate=$PASS_RATE" >> $GITHUB_OUTPUT
else
echo "total=0" >> $GITHUB_OUTPUT
echo "passed=0" >> $GITHUB_OUTPUT
echo "failed=0" >> $GITHUB_OUTPUT
echo "pass_rate=0.0" >> $GITHUB_OUTPUT
fi
- name: Comment test results
if: always()
uses: actions/github-script@v7
with:
script: |
const total = '${{ steps.test_summary.outputs.total }}';
const passed = '${{ steps.test_summary.outputs.passed }}';
const failed = '${{ steps.test_summary.outputs.failed }}';
const passRate = '${{ steps.test_summary.outputs.pass_rate }}';
const emoji = failed === '0' ? '✅' : '❌';
const status = failed === '0' ? 'All tests passed!' : `${failed} test(s) failed`;
const body = `## ${emoji} Test Results
**Status:** ${status}
| Metric | Value |
|--------|-------|
| Total Tests | ${total} |
| Passed | ✅ ${passed} |
| Failed | ❌ ${failed} |
| Pass Rate | ${passRate}% |
${failed !== '0' ? '⚠️ Please check the **Unit Tests** check run for detailed failure information.' : ''}
<sub>🤖 Automated test results from [checks workflow](${context.payload.repository.html_url}/actions/runs/${context.runId})</sub>`;
// Find existing comment
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('## ✅ Test Results') || comment.body.includes('## ❌ Test Results')
);
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}