-
-
Notifications
You must be signed in to change notification settings - Fork 1
135 lines (119 loc) · 4 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
name: "Checkout"
on:
workflow_dispatch:
push:
branches:
- "main"
- "master"
pull_request:
branches:
- "main"
- "master"
- "dev"
- "develop"
- "feature/**"
- "bugfix/**"
- "hotfix/**"
- "support/**"
paths:
- "pubspec.yaml"
- ".github/**.yaml"
- ".github/**.yml"
- "lib/**.dart"
- "test/**.dart"
- "example/**.dart"
permissions:
contents: read
actions: read
checks: write
jobs:
checkout:
name: "🧪 Check code with analysis, format, and tests"
runs-on: ubuntu-latest
env:
threshold: 5
defaults:
run:
working-directory: ./
timeout-minutes: 10
steps:
- name: 📦 Get the .github actions
uses: actions/checkout@v4
with:
fetch-depth: 2
sparse-checkout: |
.github
- name: 🚂 Setup Dart and dependencies
uses: ./.github/actions/setup
with:
dart-version: 3.7.0
- name: 👷 Install Dependencies
timeout-minutes: 1
run: |
dart pub get
#- name: 🚦 Check code format
# id: check-format
# timeout-minutes: 1
# run: |
# find lib test -name "*.dart" ! -name "*.*.dart" -print0 | xargs -0 dart format --set-exit-if-changed --line-length 120 -o none lib/ test/
- name: 📈 Check analyzer
id: check-analyzer
timeout-minutes: 1
run: dart analyze --fatal-infos --fatal-warnings lib/ test/
#- 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'"
# echo "$version_pubspec" > /tmp/version_pubspec
# grep -q "# $version_pubspec" CHANGELOG.md || (echo "Version not found in CHANGELOG.md" >&2; exit 1)
#- name: Check with pana
# run: dart pub global activate pana && pana --json --no-warning --line-length 120
#- name: 🌐 Setup chrome
# uses: browser-actions/setup-chrome@v1
- name: 🧪 Run tests
timeout-minutes: 5
run: |
dart pub global activate coverage
dart pub global run coverage:test_with_coverage -fb -o coverage -- \
--platform=vm --compiler=kernel --coverage=coverage \
--reporter=github --file-reporter=json:reports/tests.json \
--timeout=10m --concurrency=12 --color \
test/unit_test.dart
- name: 🎁 Setup LCOV
timeout-minutes: 5
uses: hrishikesh-kadam/setup-lcov@v1
#- name: 🔍 Check coverage
# id: check-coverage
# timeout-minutes: 1
# run: |
# 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: 🔍 Report code coverage
# uses: zgosalvez/github-actions-report-lcov@v4
# with:
# coverage-files: coverage/lcov.info
# minimum-coverage: ${{ env.threshold }}
# artifact-name: code-coverage-report
# github-token: ${{ secrets.GITHUB_TOKEN }}
# working-directory: ./
# update-comment: true
#- name: 📥 Upload coverage report
# timeout-minutes: 5
# if: ${{ github.actor != 'dependabot[bot]' }}
# uses: codecov/codecov-action@v2
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# files: ./coverage/lcov.info
- name: 📥 Upload test report
uses: actions/upload-artifact@v4
if: (success() || failure()) && ${{ github.actor != 'dependabot[bot]' }}
with:
name: test-results
path: reports/tests.json