-
-
Notifications
You must be signed in to change notification settings - Fork 4
148 lines (135 loc) · 4.28 KB
/
checkout.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Checkout
on:
workflow_dispatch:
#push:
# branches:
# - "master"
# - "develop"
# - "feature/**"
# - "bugfix/**"
# - "hotfix/**"
# - "support/**"
# paths:
# - ".github/workflows/*.yml"
# - "lib/pubspec.yaml"
# - "lib/**.dart"
# - "test/**.dart"
# - "example/**.dart"
pull_request:
branches:
- "master"
- "develop"
- "feature/**"
- "bugfix/**"
- "hotfix/**"
- "support/**"
paths:
- "pubspec.yaml"
- "example/pubspec.yaml"
- ".github/workflows/*.yml"
- "lib/pubspec.yaml"
- "lib/**.dart"
- "test/**.dart"
- "example/**.dart"
jobs:
checkout:
name: "Checkout"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./
container:
image: plugfox/flutter:stable
env:
pub-cache-name: pub
threshold: 50
timeout-minutes: 15
steps:
- name: 🚂 Get latest code
id: checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
.github
pubspec.yaml
lib
test
analysis_options.yaml
CHANGELOG.md
- name: 📤 Restore Pub modules
id: cache-pub-restore
uses: actions/cache/restore@v4
with:
path: |
$HOME/.pub-cache
key: ${{ runner.os }}-${{ env.pub-cache-name }}-${{ hashFiles('**/pubspec.yaml') }}
- name: 🗄️ Export Pub cache directory
id: export-pub-cache
timeout-minutes: 1
run: |
export PUB_CACHE=$PWD/.pub_cache/
export PATH="$PATH":"$HOME/.pub-cache/bin"
echo "${HOME}/.pub-cache/bin" >> $GITHUB_PATH
- name: 👷 Install Dependencies
id: install-dependencies
timeout-minutes: 1
run: |
apt-get update && apt-get install -y lcov
flutter pub get --no-example
- name: 📥 Save Pub modules
id: cache-pub-save
uses: actions/cache/save@v4
with:
path: |
$HOME/.pub-cache
key: ${{ runner.os }}-${{ env.pub-cache-name }}-${{ hashFiles('**/pubspec.yaml') }}
- name: 🔎 Check format
id: check-format
timeout-minutes: 1
run: dart format --set-exit-if-changed -l 80 -o none lib/
- name: 📈 Check analyzer
id: check-analyzer
timeout-minutes: 1
run: dart analyze --fatal-infos --fatal-warnings lib/
- name: 👀 Verify versions
id: verify-versions
timeout-minutes: 1
run: |
test -f pubspec.yaml && test -f CHANGELOG.md
version_pubspec=$(grep '^version:' pubspec.yaml | awk '{print $2}' | sed 's/[^[:print:]]//g')
test -n "$version_pubspec"
echo "Version from pubspec.yaml: '$version_pubspec'"
grep -q "# $version_pubspec" CHANGELOG.md || (echo "Version not found in CHANGELOG.md" >&2; exit 1)
- name: 🧪 Run tests
id: run-tests
timeout-minutes: 2
run: |
flutter test test/octopus_test.dart
# dart pub global run coverage:test_with_coverage -fb -o coverage -- \
# --platform vm --compiler=kernel --coverage=coverage \
# --reporter=github --file-reporter=json:coverage/tests.json \
# --timeout=10m --concurrency=12 --color \
# test/test.dart
#- name: 🔍 Check coverage
# id: check-coverage
# timeout-minutes: 2
# run: |
# mv coverage/lcov.info coverage/lcov.base.info
# lcov --remove coverage/lcov.base.info '*.g.dart' -o coverage/lcov.info
# lcov --list coverage/lcov.info
# THRESHOLD=${{ env.threshold }}
# COVERAGE=$(lcov --summary coverage/lcov.info | grep -i 'lines\|Total:' | tail -n 1 | awk '{print $2}' | sed 's/%//')
# echo "Coverage is $COVERAGE%"
# echo $COVERAGE | awk '{if ($1 < 50) exit 1}'
- name: 🧹 Cleanup artifacts
id: cleanup-artifacts
if: always()
timeout-minutes: 2
run: |
rm -rf ~/build
#- name: ✨ Upload coverage to Codecov
# id: upload-coverage
# timeout-minutes: 2
# uses: codecov/codecov-action@v4
# with:
# token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos