-
-
Notifications
You must be signed in to change notification settings - Fork 11
105 lines (101 loc) · 3.78 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
name: CI
on:
pull_request:
branches:
- main
- release/v*
jobs:
security_hardening:
name: Check security hardening
runs-on: ubuntu-latest
steps:
- name: Clone the repository
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- name: Ensure SHA pinned actions
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@8877889a5717dad0b139f1d2925689aa68f88a43
testing:
name: Run ${{ matrix.category }} testing
needs: security_hardening
runs-on: ubuntu-latest
strategy:
matrix:
category: [static, unit, widget]
fail-fast: false
steps:
- name: Clone the repository
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
path: code
- name: Get Flutter version
id: get-flutter-version
uses: zgosalvez/github-actions-get-flutter-version-env@b5f12dbe2915d60c827758258d6193df1dacca1d
with:
pubspec-file-path: code/pubspec.yaml
- name: Cache Flutter
id: flutter-cache
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353
with:
path: flutter
key: ${{ env.cache-name }}-ubuntu-latest-${{ steps.get-flutter-version.outputs.version }}-${{ hashFiles('code/pubspec.lock') }}
restore-keys: |
${{ env.cache-name }}-ubuntu-latest-${{ steps.get-flutter-version.outputs.version }}-
${{ env.cache-name }}-ubuntu-latest-
${{ env.cache-name }}-
env:
cache-name: flutter-cache
- name: Clone the Flutter repository
if: steps.flutter-cache.outputs.cache-hit != 'true'
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
repository: flutter/flutter
ref: ${{ steps.get-flutter-version.outputs.version }}
path: flutter
- name: Add the flutter tool to the path
run: |
echo "$GITHUB_WORKSPACE/flutter/bin" >> $GITHUB_PATH
echo "$GITHUB_WORKSPACE/flutter/bin/cache/dart-sdk/bin" >> $GITHUB_PATH
- name: Populate the Flutter tool's cache of binary artifacts
if: steps.flutter-cache.outputs.cache-hit != 'true'
run: |
flutter config --no-analytics
flutter precache
- name: Get Flutter packages
run: flutter pub get
working-directory: code
- name: Analyze Flutter
if: matrix.category == 'static'
uses: zgosalvez/github-actions-analyze-dart@bc72307ba08e59e62f4d6e5ae311cc464dc0f296
with:
fail-on-warnings: true
working-directory: code
- name: Run Flutter ${{ matrix.category }} tests
if: matrix.category != 'static'
run: flutter test --no-pub --coverage --coverage-path=./coverage/lcov.${{ matrix.category }}.info test/${{ matrix.category }}s
working-directory: code
- name: Upload code coverage to GitHub
if: matrix.category != 'static'
uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074
with:
name: code-coverage
path: code/coverage/lcov.${{ matrix.category }}.info
coverage_report:
name: Generate coverage report
needs: testing
runs-on: ubuntu-latest
steps:
- name: Clone the repository
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- name: Download code coverage from GitHub
uses: actions/download-artifact@3be87be14a055c47b01d3bd88f8fe02320a9bb60
with:
name: code-coverage
path: coverage
- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@f5da1b26b0dcf5d893077a3c4f29cf78079c841d
- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@2b329bb35d65e3c02715d5dd88582b9822151085
with:
coverage-files: coverage/lcov.*.info
minimum-coverage: 90
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}