-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (63 loc) · 2.5 KB
/
pr.yaml
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
name: PR Review
on:
pull_request:
types: [opened, reopened, ready_for_review]
paths:
- "**.dart"
- "pubspec.lock"
branches:
- main
env:
MIN_COVERAGE: 85
jobs:
validate_version_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get latest tag from repository
id: latest_tag
run: |
LATEST_TAG=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' --refs origin "refs/tags/*" | awk '{print substr($2, 11)}' | tail -n1)
echo "tag=${LATEST_TAG}" >> $GITHUB_OUTPUT
- name: Get latest version number of CHANGELOG.md
id: get_latest_changelog_version
run: |
LATEST_CHANGELOG_VERSION_NUMBER=$(grep -m 1 -oP '## \[\d+\.\d+\.\d+(-\S+)?\]' CHANGELOG.md | sed 's/## \[\(.*\)\]/\1/')
echo "version_number=${LATEST_CHANGELOG_VERSION_NUMBER}" >> $GITHUB_OUTPUT
- name: Compare versions
run: |
LATEST_TAG=${{ steps.latest_tag.outputs.tag }}
VERSION=v${{ steps.get_latest_changelog_version.outputs.version_number }}
if [[ "$(printf '%s\n' "$VERSION" "$LATEST_TAG" | tr '-' '~' | sort -V | head -n1 | tr '~' '-')" != "$LATEST_TAG" ]]; then
echo "Version from CHANGELOG.md ($VERSION) is not greater than the latest tag ($LATEST_TAG)"
exit 1
fi
- name: Restore Cache dependencies
id: restore-cache-deps
uses: actions/cache/restore@v3
with:
key: ${{ runner.os }}-pub-cache-${{ hashFiles('**/pubspec.lock') }}
path: ~/.pub-cache
- name: Setup Dart
uses: dart-lang/setup-dart@v1
- name: Install dependencies
run: dart pub get
- name: Save Cache dependencies
uses: actions/cache/save@v3
if: steps.restore-cache-deps.outputs.cache-hit != 'true'
with:
key: ${{ steps.restore-cache-deps.outputs.cache-primary-key }}
path: ~/.pub-cache
- name: Analyze project source
run: dart analyze
- name: Install Global Dependencies
run: |
dart pub global activate dlcov "<5.0.0"
dart pub global activate coverage "<2.0.0"
- name: Run tests
run: |
test_with_coverage --function-coverage --branch-coverage
- name: Analyze coverage
run: |
dlcov --coverage=$MIN_COVERAGE --include-untested-files=true