-
Notifications
You must be signed in to change notification settings - Fork 22
100 lines (88 loc) · 2.54 KB
/
code_check.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Code Check
on:
push:
branches: main
pull_request:
env:
FLUTTER_TEST_REPORT: ${{github.workspace}}/flutter-test-report.json
PATTERN_CHECKER: ${{github.workspace}}/scripts/pattern_checker.sh
jobs:
# Change detection
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
dart-files: ${{ steps.filter.outputs.dart-files }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
dart-files:
- '**.dart'
# Static code analysis
analysis:
needs: changes
if: ${{ needs.changes.outputs.dart-files == 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
target: [package, cookbook]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Flutter
uses: ./.github/actions/setup_flutter
with:
target: ${{ matrix.target }}
- name: Format
run: dart format . -o none --set-exit-if-changed
working-directory: ${{ matrix.target }}
- name: Analyze
run: dart analyze
working-directory: ${{ matrix.target }}
- name: Disallowed patterns check
run: bash ${{ env.PATTERN_CHECKER }} "*.dart" "--" "debugPrint"
working-directory: ${{ matrix.target }}
# Unit testing
testing:
needs: changes
if: ${{ needs.changes.outputs.dart-files == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
checks: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Flutter
uses: ./.github/actions/setup_flutter
with:
target: package
- name: Run unit tests
run: flutter test --file-reporter="json:${{ env.FLUTTER_TEST_REPORT }}"
working-directory: package
- name: Write test report
uses: dorny/test-reporter@v1
# PRs from forks have no write permissions.
if: github.event.pull_request.head.repo.fork == false && (success() || failure())
with:
name: Test Report
path: ${{ env.FLUTTER_TEST_REPORT }}
reporter: flutter-json
# Final results (Used for status checks)
code-check:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [analysis, testing]
steps:
# Fails if any of the previous jobs failed.
- run: exit 1
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
}}