-
-
Notifications
You must be signed in to change notification settings - Fork 136
127 lines (111 loc) · 4 KB
/
flutter-ci.yml
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Flutter CI
on:
pull_request:
branches:
- main
paths:
- "mobile-app/**"
- ".github/**"
push:
branches:
- main
schedule:
- cron: "0 0 * * *"
jobs:
flutter_test:
name: flutter test
defaults:
run:
working-directory: ./mobile-app
runs-on: ubuntu-latest
steps:
- name: Remove unused software
working-directory: /
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
echo "Free space:"
df -h /
- name: Checkout files
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Gradle cache
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3
with:
gradle-version: 7.6.3
- name: Setup Java 17
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4
with:
distribution: "temurin"
java-version: "17"
- name: AVD cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-33
- name: Ceate AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@77986be26589807b8ebab3fde7bbf5c60dabec32 # v2
with:
api-level: 33
target: google_apis
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Setup Flutter 3.24.x
uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # v2
with:
flutter-version: "3.24.x"
channel: "stable"
cache: true
cache-key: flutter-3.24.x
cache-path: ${{ runner.tool_cache }}/flutter
- name: Create .env file
run: |
echo "HASHNODE_PUBLICATION_ID=$HASHNODE_PUBLICATION_ID" > .env
echo "ALGOLIAAPPID=$ALGOLIA_APP_ID" >> .env
echo "ALGOLIAKEY=$ALGOLIA_KEY" >> .env
echo "AUTH0_DOMAIN=$AUTH0_DOMAIN" >> .env
echo "AUTH0_CLIENT_ID=$AUTH0_CLIENT_ID" >> .env
env:
HASHNODE_PUBLICATION_ID: ${{ secrets.HASHNODE_PUBLICATION_ID }}
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_KEY: ${{ secrets.ALGOLIA_KEY }}
AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }}
AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }}
- name: Install packages
run: flutter pub get
- name: Analyze code
run: flutter analyze
- name: Run unit tests
run: |
cd test
flutter test unit
flutter test services
- name: Run tests in emulator
uses: reactivecircus/android-emulator-runner@77986be26589807b8ebab3fde7bbf5c60dabec32 # v2
with:
api-level: 33
target: google_apis
arch: x86_64
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: cd mobile-app && if adb shell pm list packages | grep -q org.freecodecamp; then adb uninstall org.freecodecamp; fi && dart integration_test_runner.dart
- name: Upload screenshots
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4
if: always()
with:
name: screenshots
path: mobile-app/screenshots/
if-no-files-found: error
retention-days: 7