Skip to content

Commit ab833cb

Browse files
feat(front): Add new flutter templates (#461)
## πŸ“ Description Modified the Flutter pipeline files and properties files for Linux and Docker Added an iOS pipeline file and properties files ## βœ… Checklist - [x] I have tested this change - [ ] This change requires documentation update --------- Co-authored-by: Veljko Maksimovic <[email protected]>
1 parent 94bf362 commit ab833cb

File tree

6 files changed

+304
-113
lines changed

6 files changed

+304
-113
lines changed
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
2-
"title": "Flutter",
3-
"description": "Run tests and build your Flutter app in Docker with quality checks and dependency analysis. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-blue white'>Flutter</span><span class='f6 normal mr1 ph1 br2 bg-green white'>Docker</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>pub</span></div>",
4-
"short_description": "Run your Flutter suite",
2+
"title": "Flutter – Docker CI Pipeline",
3+
"description": "Run Flutter CI inside Docker, leveraging a Flutter/Android convenience image for faster toolchain startup. Includes dependency caching, code formatting and static analysis, parallelized tests via job parallelism, JUnit reports through junitreport/tojunit, and a release web build published as an artifact. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-cyan white'>Flutter</span><span class='f6 normal mr1 ph1 br2 bg-green white'>Docker</span><span class='f6 normal mr1 ph1 br2 bg-blue white'>Web</span><span class='f6 normal mr1 ph1 br2 bg-dark-green white'>Cache</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>Parallelism</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>JUnit</span><span class='f6 normal mr1 ph1 br2 bg-gray white'>Artifacts</span></div>",
4+
"short_description": "Docker-based Flutter CI with parallel tests and web artifact",
55
"group": "ci",
66
"language": "Dart",
77
"environment": "docker",
88
"use_case": "ci_pipeline",
9+
"tags": ["ci_pipeline", "security_checks"],
910
"icon": "lang-flutter.svg",
10-
"template_path": "templates/flutter_saas.yml",
11+
"template_path": "templates/flutter_docker.yml",
1112
"workflow_tip": "other"
1213
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"title": "Flutter – iOS CI Pipeline",
3+
"description": "Build and test your Flutter app for iOS using macOS runners with Xcode and Flutter preinstalled. This lean pipeline includes format and analyze checks, parallelized tests with JUnit reports, and an unsigned iOS release build published as an artifact. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-cyan white'>Flutter</span><span class='f6 normal mr1 ph1 br2 bg-red white'>iOS</span><span class='f6 normal mr1 ph1 br2 bg-dark-green white'>Cache</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>Parallelism</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>JUnit</span><span class='f6 normal mr1 ph1 br2 bg-gray white'>Artifacts</span></div>",
4+
"short_description": "Build and test Flutter iOS apps on macOS",
5+
"group": "ci",
6+
"language": "Dart",
7+
"environment": "macos",
8+
"use_case": "ci_pipeline",
9+
"tags": ["ci_pipeline"],
10+
"icon": "lang-flutter.svg",
11+
"template_path": "templates/flutter_macos.yml",
12+
"workflow_tip": "other"
13+
}

β€Žfront/workflow_templates/saas_new/properties/flutter_saas.properties.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"title": "Flutter",
3-
"description": "Run a robust CI/CD pipeline for Flutter projects, including dependency management, linting, unit/widget tests, UI tests, and iOS build artifact generation. This pipeline leverages Semaphore's caching and parallelism to optimize execution for mobile app development. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-blue white'>Flutter</span><span class='f6 normal mr1 ph1 br2 bg-green white'>iOS</span><span class='f6 normal mr1 ph1 br2 bg-red white'>Android</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>UI Tests</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>pub</span></div>",
4-
"short_description": "Run your Flutter application",
2+
"title": "Flutter CI Pipeline",
3+
"description": "Run a production-ready Flutter CI with dependency caching, code formatting and static analysis (format + analyze), parallelized tests using job parallelism, JUnit reports via junitreport/tojunit, and a release web build published as an artifact. <div class='flex items-center mt1 mb3'><span class='f6 normal mr1 ph1 br2 bg-cyan white'>Flutter</span><span class='f6 normal mr1 ph1 br2 bg-blue white'>Web</span><span class='f6 normal mr1 ph1 br2 bg-dark-green white'>Cache</span><span class='f6 normal mr1 ph1 br2 bg-purple white'>Parallelism</span><span class='f6 normal mr1 ph1 br2 bg-orange white'>JUnit</span><span class='f6 normal mr1 ph1 br2 bg-gray white'>Artifacts</span></div>",
4+
"short_description": "Parallel Flutter tests and web build with JUnit reports",
55
"group": "ci",
66
"language": "Dart",
7-
"environment": "macOS",
7+
"environment": "linux",
88
"use_case": "ci_pipeline",
9+
"tags": ["ci_pipeline", "security_checks"],
910
"icon": "lang-flutter.svg",
1011
"template_path": "templates/flutter_saas.yml",
1112
"workflow_tip": "other"
Lines changed: 87 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,123 @@
1-
# This is a Semaphore configuration file for Flutter projects using Docker
2-
# For more information about Semaphore configuration visit:
3-
# https://docs.semaphoreci.com/reference/pipeline-yaml-reference/
1+
# πŸ“š Semaphore docs:
2+
# - Pipeline YAML reference: https://docs.semaphoreci.com/reference/pipeline-yaml
3+
# - Job parallelism: https://docs.semaphoreci.com/using-semaphore/jobs/#job-parallelism
4+
# - Cache: https://docs.semaphoreci.com/using-semaphore/optimization/cache
5+
# - Test Reports: https://docs.semaphoreci.com/using-semaphore/tests/test-reports
6+
# - Artifacts: https://docs.semaphoreci.com/using-semaphore/artifacts
47

5-
version: v1.0 # Semaphore configuration version
6-
name: "πŸ’™ Flutter CI Pipeline" # Pipeline display name
8+
version: v1.0
9+
name: "🐳 Flutter (Docker) β€’ Web build"
710

8-
# Define the machine type, OS image, and containers
911
agent:
1012
machine:
1113
type: {{ machine_type }}
1214
os_image: {{ os_image }}
13-
1415
containers:
1516
- name: main
16-
image: 'registry.semaphoreci.com/flutter:3.16' # Flutter 3.16 container
17+
image: registry.semaphoreci.com/android:34-flutter
18+
1719

18-
# Configure when to stop the pipeline early
1920
fail_fast:
21+
# πŸ”΄ Stop all running jobs on failure (configurable):
22+
# https://docs.semaphoreci.com/reference/pipeline-yaml/#fail_fast
2023
stop:
21-
when: branch != 'main' # Stop all blocks if a job fails on non-main branches
24+
when: branch != 'main'
25+
2226
auto_cancel:
27+
# πŸ” Auto-cancel superseded pipelines on new pushes to the same branch:
28+
# https://docs.semaphoreci.com/reference/pipeline-yaml/#auto_cancel
2329
running:
24-
when: branch != 'main' # Cancel running pipelines on non-main branches
30+
when: branch != 'main'
2531
queued:
26-
when: branch = 'main' # Cancel queued pipelines on main branch
32+
when: branch != 'main'
2733

28-
# Commands to run before each job
2934
global_job_config:
35+
env_vars:
36+
- name: FLUTTER_HOME
37+
value: $HOME/flutter
38+
- name: PATH
39+
value: '$HOME/.pub-cache/bin:$FLUTTER_HOME/bin:$PATH'
40+
- name: JUNIT_FILE
41+
value: test-results/junit.xml
3042
prologue:
3143
commands:
32-
- checkout # Get the code from repository
33-
- flutter pub get # Install dependencies
34-
- cache restore # Restore cached dependencies
44+
- checkout
45+
# πŸ’Ύ Restore dependency cache (keyed by pubspec.lock):
46+
# https://docs.semaphoreci.com/using-semaphore/optimization/cache
47+
- cache restore "pub-cache-$(checksum pubspec.lock)"
48+
# If the container doesn't include Flutter, install it; otherwise, reuse preinstalled toolchain.
49+
- 'command -v flutter >/dev/null 2>&1 || git clone --depth 1 -b stable https://github.com/flutter/flutter.git "$FLUTTER_HOME"'
50+
- flutter --version
51+
- flutter doctor -v
52+
- flutter pub get
53+
# 🧾 JUnit converter used by Test Reports:
54+
# https://docs.semaphoreci.com/using-semaphore/tests/test-reports
55+
- dart pub global activate junitreport
56+
epilogue:
57+
always:
58+
commands:
59+
# πŸ“ˆ Publish job-level test results to Test Reports UI (safe if file missing):
60+
# https://docs.semaphoreci.com/using-semaphore/tests/test-reports
61+
- '[[ -f "$JUNIT_FILE" ]] && test-results publish "$JUNIT_FILE" || true'
3562

36-
# Pipeline blocks represent groups of jobs that can run in parallel
3763
blocks:
38-
# Block for setting up dependencies and caching
39-
- name: "πŸ›  Setup and Cache"
40-
dependencies: []
64+
- name: "🧹 Quality"
4165
task:
4266
jobs:
43-
- name: Install Dependencies
67+
- name: "🧼 Format"
4468
commands:
45-
- cache store # Cache dependencies for future runs
46-
47-
# Block for code quality checks
48-
- name: "πŸ” Code Quality"
49-
dependencies: ["πŸ›  Setup and Cache"]
50-
task:
51-
jobs:
52-
- name: Analyze and Format
69+
- flutter format --set-exit-if-changed .
70+
- name: "πŸ”Ž Analyze"
5371
commands:
54-
- flutter analyze # Static code analysis
55-
- flutter format --set-exit-if-changed . # Check code formatting
72+
- flutter analyze .
73+
dependencies: []
5674

57-
# Block for security checks
58-
- name: "πŸ” Security Checks"
59-
dependencies: ["πŸ›  Setup and Cache"]
75+
- name: "πŸ§ͺ Tests (parallel)"
6076
task:
6177
jobs:
62-
- name: Security Scan
78+
- name: "πŸ§ͺ Flutter tests (sharded)"
79+
# ⚑️ Fan out a single job into N parallel jobs:
80+
# https://docs.semaphoreci.com/using-semaphore/jobs/#job-parallelism
81+
parallelism: 4
6382
commands:
64-
- flutter pub outdated # Check for outdated dependencies
65-
- flutter pub deps # Display dependency tree
83+
- mkdir -p test-results
84+
# Convert 1-based SEMAPHORE_JOB_INDEX -> 0-based shard index for Flutter/Dart
85+
- export SHARD_INDEX=$((SEMAPHORE_JOB_INDEX - 1))
86+
- echo "Shard $SHARD_INDEX of $SEMAPHORE_JOB_COUNT"
87+
# 🧾 Produce JUnit via tojunit for Test Reports:
88+
# https://docs.semaphoreci.com/using-semaphore/tests/test-reports
89+
- flutter test --machine --total-shards $SEMAPHORE_JOB_COUNT --shard-index $SHARD_INDEX | tojunit --output $JUNIT_FILE
90+
dependencies:
91+
- "🧹 Quality"
6692

67-
# Block for running tests
68-
- name: "πŸ§ͺ Test Suite"
69-
dependencies: ["πŸ›  Setup and Cache"]
93+
- name: "πŸ›‘οΈ Security (pub deps)"
7094
task:
7195
jobs:
72-
- name: "🟒 Flutter Tests"
73-
parallelism: 4 # Run tests in parallel
96+
- name: "πŸ›‘οΈ Pub outdated (informational)"
7497
commands:
75-
- flutter test --coverage # Run tests with coverage
76-
- flutter pub global activate remove_from_coverage
77-
- flutter pub global run remove_from_coverage:remove_from_coverage -f coverage/lcov.info -r '.g.dart$' # Remove generated files from coverage
98+
- dart pub outdated || true
99+
dependencies:
100+
- "πŸ§ͺ Tests (parallel)"
78101

79-
# Block for building the app
80-
- name: "πŸ“¦ Build"
81-
dependencies: ["πŸ§ͺ Test Suite"]
102+
- name: "πŸ“¦ Build Web (artifact)"
103+
dependencies:
104+
- "πŸ§ͺ Tests (parallel)"
105+
skip:
106+
when: branch != 'main'
82107
task:
83108
jobs:
84-
- name: Android Build
109+
- name: "🌐 flutter build web"
85110
commands:
86-
- flutter build apk --release # Build Android APK
87-
- name: iOS Build
88-
commands:
89-
- flutter build ios --release --no-codesign # Build iOS without signing
111+
- flutter build web --release
112+
# πŸ“¦ Store build output as an artifact:
113+
# https://docs.semaphoreci.com/using-semaphore/artifacts
114+
- artifact push job build/web
115+
116+
after_pipeline:
117+
task:
118+
jobs:
119+
- name: "πŸ“Š Merge test reports"
120+
commands:
121+
# 🧩 Merge all job reports into a single pipeline report:
122+
# https://docs.semaphoreci.com/using-semaphore/tests/test-reports
123+
- test-results gen-pipeline-report
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# πŸ“š Semaphore docs:
2+
# - Pipeline YAML reference: https://docs.semaphoreci.com/reference/pipeline-yaml
3+
# - Apple macOS images: https://docs.semaphoreci.com/reference/os-apple
4+
# - Job parallelism: https://docs.semaphoreci.com/using-semaphore/jobs/#job-parallelism
5+
# - Test Reports: https://docs.semaphoreci.com/using-semaphore/tests/test-reports
6+
# - Artifacts: https://docs.semaphoreci.com/using-semaphore/artifacts
7+
8+
version: v1.0
9+
name: "🍏 Flutter iOS β€’ Build & Test (macOS)"
10+
11+
agent:
12+
machine:
13+
type: {{ machine_type }}
14+
os_image: {{ os_image }}
15+
16+
fail_fast:
17+
# πŸ”΄ Stop all running jobs on failure (configurable):
18+
# https://docs.semaphoreci.com/reference/pipeline-yaml/#fail_fast
19+
stop:
20+
when: branch != 'main'
21+
22+
auto_cancel:
23+
# πŸ” Auto-cancel superseded pipelines on new pushes to the same branch:
24+
# https://docs.semaphoreci.com/reference/pipeline-yaml/#auto_cancel
25+
running:
26+
when: branch != 'main'
27+
queued:
28+
when: branch != 'main'
29+
30+
global_job_config:
31+
env_vars:
32+
- name: JUNIT_FILE
33+
value: test-results/junit.xml
34+
- name: PATH
35+
value: "$HOME/.pub-cache/bin:$PATH"
36+
prologue:
37+
commands:
38+
- checkout
39+
# πŸ’Ύ Restore dependency cache (keyed by pubspec.lock):
40+
# https://docs.semaphoreci.com/using-semaphore/optimization/cache
41+
- cache restore "pub-cache-$(checksum pubspec.lock)"
42+
- flutter --version
43+
- flutter doctor -v
44+
- flutter pub get
45+
# 🧾 JUnit converter used by Test Reports:
46+
# https://docs.semaphoreci.com/using-semaphore/tests/test-reports
47+
- dart pub global activate junitreport
48+
epilogue:
49+
always:
50+
commands:
51+
# πŸ“ˆ Publish job-level test results to Test Reports UI (safe if file missing):
52+
# https://docs.semaphoreci.com/using-semaphore/tests/test-reports
53+
- '[[ -f "$JUNIT_FILE" ]] && test-results publish "$JUNIT_FILE" || true'
54+
55+
blocks:
56+
- name: "🧹 Quality"
57+
task:
58+
jobs:
59+
- name: "🧼 Format"
60+
commands:
61+
- flutter format --set-exit-if-changed .
62+
- name: "πŸ”Ž Analyze"
63+
commands:
64+
- flutter analyze .
65+
dependencies: []
66+
67+
- name: "πŸ§ͺ Tests (parallel)"
68+
task:
69+
jobs:
70+
- name: "πŸ§ͺ Flutter tests (sharded)"
71+
# ⚑️ Fan out a single job into N parallel jobs:
72+
# https://docs.semaphoreci.com/using-semaphore/jobs/#job-parallelism
73+
parallelism: 4
74+
commands:
75+
- mkdir -p test-results
76+
# Convert 1-based SEMAPHORE_JOB_INDEX -> 0-based shard index for Flutter/Dart
77+
- export SHARD_INDEX=$((SEMAPHORE_JOB_INDEX - 1))
78+
- echo "Shard $SHARD_INDEX of $SEMAPHORE_JOB_COUNT"
79+
# 🧾 Produce JUnit via tojunit for Test Reports:
80+
# https://docs.semaphoreci.com/using-semaphore/tests/test-reports
81+
- flutter test --machine --total-shards $SEMAPHORE_JOB_COUNT --shard-index $SHARD_INDEX | tojunit --output $JUNIT_FILE
82+
dependencies:
83+
- "🧹 Quality"
84+
85+
- name: "πŸ“¦ Build iOS (artifact)"
86+
dependencies:
87+
- "πŸ§ͺ Tests (parallel)"
88+
skip:
89+
when: branch != 'main'
90+
task:
91+
jobs:
92+
- name: "πŸ“¦ flutter build ios (no codesign)"
93+
commands:
94+
# Builds an unsigned iOS app bundle; suitable for local install/signing later
95+
- flutter build ios --release --no-codesign
96+
# πŸ“¦ Store build output as an artifact (Runner.app and products):
97+
# https://docs.semaphoreci.com/using-semaphore/artifacts
98+
- artifact push job build/ios
99+
# Optionally cache pub again (if dependencies changed in this job)
100+
- cache store "pub-cache-$(checksum pubspec.lock)" "$HOME/.pub-cache"
101+
102+
after_pipeline:
103+
task:
104+
jobs:
105+
- name: "πŸ“Š Merge test reports"
106+
commands:
107+
# 🧩 Merge all job reports into a single pipeline report:
108+
# https://docs.semaphoreci.com/using-semaphore/tests/test-reports
109+
- test-results gen-pipeline-report

0 commit comments

Comments
Β (0)