-
-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (121 loc) · 3.79 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
name: Checkout
on:
workflow_dispatch:
push:
branches:
- "main"
- "master"
#- "dev"
#- "develop"
#- "feature/**"
#- "bugfix/**"
#- "hotfix/**"
#- "support/**"
paths:
- "lib/**.dart"
- "test/**.dart"
- "example/**.dart"
- ".github/workflows/*.yml"
- "pubspec.yaml"
- "analysis_options.yaml"
pull_request:
branches:
- "main"
- "master"
- "dev"
- "develop"
- "feature/**"
- "bugfix/**"
- "hotfix/**"
- "support/**"
paths:
- "lib/**.dart"
- "test/**.dart"
- "example/**.dart"
- ".github/workflows/*.yml"
- "pubspec.yaml"
- "analysis_options.yaml"
permissions:
contents: read
actions: read
checks: write
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
checkout:
name: "Checkout"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./
container:
image: dart:stable
env:
pub-cache: pub
PUB_CACHE: /github/home/.pub-cache
timeout-minutes: 10
steps:
- name: 🚂 Get latest code
id: checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
.github
pubspec.yaml
lib
test
analysis_options.yaml
README.md
CHANGELOG.md
- name: 📤 Restore Pub modules
id: cache-pub-restore
uses: actions/cache/restore@v4
with:
path: |
/home/runner/.pub-cache
key: ${{ runner.os }}-pub-${{ env.pub-cache }}-${{ hashFiles('pubspec.yaml') }}
- name: 👷 Install Dependencies
id: install-dependencies
timeout-minutes: 1
run: |
echo $PUB_CACHE/bin >> $GITHUB_PATH
dart pub get --no-example
- name: 📥 Save Pub modules
id: cache-pub-save
if: steps.cache-pub-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
/home/runner/.pub-cache
key: ${{ steps.cache-pub-restore.outputs.cache-primary-key }}
- 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 80 -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 lib/src/model/pubspec.yaml.g.dart && test -f CHANGELOG.md
version_pubspec=$(grep '^version:' pubspec.yaml | awk '{print $2}' | sed 's/[^[:print:]]//g')
version_dart=$(grep 'representation: r' lib/src/model/pubspec.yaml.g.dart | awk -F"'" '{print $2}' | sed 's/[^[:print:]]//g')
test -n "$version_pubspec" && test -n "$version_dart"
echo "Version from pubspec.yaml: '$version_pubspec'"
echo "Version from pubspec.yaml.g.dart: '$version_dart'"
echo "$version_pubspec" > /tmp/version_pubspec
echo "$version_dart" > /tmp/version_dart
diff /tmp/version_pubspec /tmp/version_dart
grep -q "# $version_pubspec" CHANGELOG.md || (echo "Version not found in CHANGELOG.md" >&2; exit 1)
- name: 🧪 Run unit tests
id: run-unit-tests
timeout-minutes: 2
run: |
dart test --color --platform=vm --concurrency=12 \
--timeout=60s --reporter=github --file-reporter=json:reports/tests.json \
--coverage=coverage -- test/unit_test.dart