-
Notifications
You must be signed in to change notification settings - Fork 4
192 lines (153 loc) · 5.75 KB
/
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
name: CI
on:
pull_request:
branches: [ main ]
types: [opened, labeled, unlabeled, synchronize]
push:
branches: [ main ]
jobs:
check_label:
runs-on: ubuntu-latest
steps:
- uses: mheap/github-action-required-labels@v2
if: github.ref != 'refs/heads/main'
with:
mode: exactly
count: 0
labels: "not ready"
get_flutter_version:
needs: check_label
runs-on: ubuntu-latest
outputs:
flutter-version: ${{ steps.step_extract_version.outputs.flutter-version }}
steps:
- uses: actions/checkout@v3
- uses: kuhnroyal/flutter-fvm-config-action@v1
with:
path: '.fvm/fvm_config.json'
- id: step_extract_version
run: |
FLUTTER_VERSION=${{ env.FLUTTER_VERSION }}
echo "flutter-version=${FLUTTER_VERSION}" >> $GITHUB_OUTPUT
get_last_released_version:
needs: check_label
runs-on: ubuntu-latest
outputs:
last_released_version: ${{ steps.step1.outputs.last_released_version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # we need the tags here
- id: step1
name: Get latest version
run: |
tag=$(git describe --tags --abbrev=0)
version="${tag#releases/}"
version="${version#v}"
echo "last_released_version=${version}" >> $GITHUB_OUTPUT
analysis:
needs: [check_label, get_flutter_version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ needs.get_flutter_version.outputs.flutter-version }}
channel: 'any'
cache-path: '${{ runner.tool_cache }}/flutter-${{ needs.get_flutter_version.outputs.flutter-version }}-any'
- name: Verify formatting
run: dart format --set-exit-if-changed .
- name: Install dependencies
run: dart pub get
- name: Verify Builder have been run
run: |
dart pub run build_runner build --delete-conflicting-outputs
git diff --exit-code HEAD
- name: Analyze project source
run: dart analyze --fatal-infos --fatal-warnings .
semver:
needs: [get_last_released_version, get_flutter_version]
uses: bmw-tech/dart_apitool/.github/workflows/check_version.yml@workflow/v1
with:
runs-on: ubuntu-latest
old: "pub://dart_apitool/${{ needs.get_last_released_version.outputs.last_released_version }}"
new: "."
ignore-prerelease: 'on'
flutter-channel: 'any'
flutter-version: ${{ needs.get_flutter_version.outputs.flutter-version }}
semver-dogfood:
needs: [get_last_released_version, get_flutter_version]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '${{ inputs.flutter-version }}'
channel: '${{ inputs.flutter-channel }}'
cache-path: '${{ runner.tool_cache }}/flutter-${{ needs.get_flutter_version.outputs.flutter-version }}-any'
- name: Install dependencies
run: dart pub get
- name: check version
run: dart bin/main.dart diff --old pub://dart_apitool/${{ needs.get_last_released_version.outputs.last_released_version }} --new . --ignore-prerelease on
test:
needs: [check_label, get_flutter_version]
strategy:
matrix:
platform: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ needs.get_flutter_version.outputs.flutter-version }}
channel: 'any'
cache-path: '${{ runner.tool_cache }}/flutter-${{ needs.get_flutter_version.outputs.flutter-version }}-any'
- name: Install dependencies
run: dart pub get
- name: Run tests
run: dart test
coverage:
needs: [check_label, get_flutter_version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ needs.get_flutter_version.outputs.flutter-version }}
channel: 'any'
cache-path: '${{ runner.tool_cache }}/flutter-${{ needs.get_flutter_version.outputs.flutter-version }}-any'
- name: Install dependencies
run: |
dart pub get
dart pub global activate coverage
dart pub global activate dlcov
- name: Gather coverage
run: |
dart pub global run coverage:test_with_coverage
- name: Check threshold
run: |
dart pub global run dlcov:dlcov -c 75
pana:
needs: [check_label, get_flutter_version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ needs.get_flutter_version.outputs.flutter-version }}
channel: 'any'
cache-path: '${{ runner.tool_cache }}/flutter-${{ needs.get_flutter_version.outputs.flutter-version }}-any'
- name: Install Dependencies
run: |
dart pub get
dart pub global activate pana 0.21.45 #temporary as the latest version 0.22.0 has issues with the dartdoc interface
- name: Verify Pub Score
run: |
dart --version
flutter --version
PANA=$(pana . --no-warning); PANA_SCORE=$(echo $PANA | sed -n "s/.*Points: \([0-9]*\)\/\([0-9]*\)./\1\/\2/p")
echo "score: $PANA_SCORE"
IFS='/'; read -a SCORE_ARR <<< "$PANA_SCORE"; SCORE=SCORE_ARR[0]; TOTAL=SCORE_ARR[1]
if (( $SCORE < $TOTAL )); then echo $PANA; echo "minimum score not met!"; exit 1; fi