11name : CI
22on :
3- # Trigger the workflow on push or pull request,
4- # but push action is only for the feature branch
53 pull_request :
64 types : [ opened, synchronize, reopened ]
75
86jobs :
9- test :
10- name : Template initializing scripts test
7+ validate_sample :
8+ name : Validate sample project
119 runs-on : ubuntu-latest
1210 timeout-minutes : 30
1311 steps :
@@ -18,118 +16,36 @@ jobs:
1816 uses : subosito/flutter-action@v2
1917 with :
2018 channel : ' stable'
21- flutter-version : ' 3.10.5 '
19+ flutter-version : ' 3.24.3 '
2220
23- - name : Generate new project
21+ - name : Check for spec drift
2422 run : |
25- dart pub global activate mason_cli
26- mason get
27- mason make template -c mason-config.json
23+ SAMPLE_CHANGED=$(git diff --name-only origin/develop...HEAD -- sample/ | wc -l)
24+ SPECS_CHANGED=$(git diff --name-only origin/develop...HEAD -- specs/ | wc -l)
25+ if [ "$SAMPLE_CHANGED" -gt 0 ] && [ "$SPECS_CHANGED" -eq 0 ]; then
26+ echo "::warning::sample/ changed but specs/ was not updated. Please review if specs need updating."
27+ fi
2828
29- - name : Get Flutter dependencies
30- run : flutter pub get
29+ - name : Layer 1 — Structural validation
30+ run : bash specs/validation/validate_structure.sh sample
3131
32- - name : Run code generator
33- run : flutter packages pub run build_runner build --delete-conflicting-outputs
32+ - name : Layer 2a — Get Flutter dependencies
33+ run : cd sample && flutter pub get
3434
35- - name : Check for any formatting issues in the code
36- run : dart format --set-exit-if-changed .
35+ - name : Layer 2b — Run code generator
36+ run : cd sample && flutter packages pub run build_runner build --delete-conflicting-outputs
3737
38- - name : Statically analyze the Dart code for any errors
39- run : flutter analyze .
38+ - name : Layer 2c — Check formatting
39+ run : cd sample && dart format --set-exit-if-changed .
4040
41- - name : Run widget tests, unit tests
42- run : flutter test --machine --coverage
41+ - name : Layer 2d — Static analysis
42+ run : cd sample && flutter analyze .
4343
44- generate_mason_bundle :
45- # The job generate_mason_bundle identify that the job test must complete successfully
46- # before this generate_mason_bundle job will run
47- needs : test
48- name : Generate Mason bundle
49- runs-on : ubuntu-latest
50- steps :
51- - name : Check out
52- uses : actions/checkout@v3
53- with :
54- ref : ${{ github.head_ref }}
55-
56- - name : Set up Flutter environment
57- uses : subosito/flutter-action@v2
58- with :
59- channel : ' stable'
60- flutter-version : ' 3.10.5'
61-
62- - name : Install Mason CLI
63- run : |
64- dart pub global activate mason_cli
65- mason get
66-
67- - name : Generate Mason bundle
68- run : |
69- mason bundle bricks/permission_handler -t dart -o bricks/template/hooks/bundles
70-
71- - id : changes
72- name : Check for changes in the Mason bricks
73- run : |
74- count=$(git status bricks --porcelain | wc -l)
75- echo "count=$count" >> $GITHUB_OUTPUT
76-
77- - name : Commit & push the Mason bundle changes
78- if : steps.changes.outputs.count > 0
79- run : |
80- git config user.name team-nimblehq
81- git config user.email bot@nimblehq.co
82- git add bricks
83- git commit -m "[Chore] Generate Mason bundle"
84- git push
85-
86- generate_sample_project :
87- # The job generate_sample_project identify that the job generate_mason_bundle must complete successfully
88- # before this generate_sample_project job will run
89- needs : generate_mason_bundle
90- name : Generate the sample project
91- runs-on : ubuntu-latest
92- timeout-minutes : 30
93- steps :
94- - name : Check out
95- uses : actions/checkout@v3
96- with :
97- ref : ${{ github.head_ref }}
98-
99- - name : Set up Flutter environment
100- uses : subosito/flutter-action@v2
101- with :
102- channel : ' stable'
103- flutter-version : ' 3.10.5'
104-
105- - name : Remove the old sample project
44+ - name : Layer 3 — Architecture invariants
10645 run : |
107- rm -rf sample
46+ cp specs/validation/invariant_architecture_test.dart sample/test/
47+ cd sample && flutter test test/invariant_architecture_test.dart
48+ rm -f test/invariant_architecture_test.dart
10849
109- - name : Set the project name "sample"
110- uses : jossef/action-set-json-field@v2.1
111- with :
112- file : mason-config.json
113- field : project_name
114- value : sample
115-
116- - name : Generate the new "sample" project
117- run : |
118- dart pub global activate mason_cli
119- mason get
120- mason make template -c mason-config.json -o sample
121-
122- - id : changes
123- name : Check for changes in the sample project
124- run : |
125- count=$(git status sample --porcelain | wc -l)
126- echo "count=$count" >> $GITHUB_OUTPUT
127-
128- - name : Commit & push the sample project changes
129- if : steps.changes.outputs.count > 0
130- run : |
131- git config user.name team-nimblehq
132- git config user.email bot@nimblehq.co
133- git add sample
134- git commit -m "[Chore] Generate & update sample project"
135- git push
50+ - name : Layer 3b — Run tests
51+ run : cd sample && flutter test --coverage
0 commit comments