|
1 | | -name: Checkout |
| 1 | +name: CHECKOUT |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_dispatch: |
5 | | - push: |
6 | | - branches: |
7 | | - - "master" |
8 | | - - "develop" |
9 | | - - "feature/**" |
10 | | - - "bugfix/**" |
11 | | - - "hotfix/**" |
12 | | - - "support/**" |
13 | | - paths: |
14 | | - - "lib/**.dart" |
15 | | - - "test/**.dart" |
16 | | - - "example/**.dart" |
17 | | - - "pubspec.yaml" |
| 5 | + #push: |
| 6 | + # branches: |
| 7 | + # - "master" |
| 8 | + # - "develop" |
| 9 | + # - "feature/**" |
| 10 | + # - "bugfix/**" |
| 11 | + # - "hotfix/**" |
| 12 | + # - "support/**" |
| 13 | + # paths: |
| 14 | + # - ".github/workflows/*.yml" |
| 15 | + # - "lib/pubspec.yaml" |
| 16 | + # - "lib/**.dart" |
| 17 | + # - "test/**.dart" |
| 18 | + # - "example/**.dart" |
18 | 19 | pull_request: |
19 | 20 | branches: |
20 | 21 | - "master" |
|
24 | 25 | - "hotfix/**" |
25 | 26 | - "support/**" |
26 | 27 | paths: |
| 28 | + - ".github/workflows/*.yml" |
| 29 | + - "lib/pubspec.yaml" |
27 | 30 | - "lib/**.dart" |
28 | 31 | - "test/**.dart" |
29 | 32 | - "example/**.dart" |
30 | | - - "pubspec.yaml" |
31 | 33 |
|
32 | 34 | jobs: |
33 | 35 | checkout: |
34 | 36 | name: "Checkout" |
35 | 37 | runs-on: ubuntu-latest |
36 | | - container: |
37 | | - image: dart:beta |
38 | 38 | defaults: |
39 | 39 | run: |
40 | 40 | working-directory: ./ |
| 41 | + container: |
| 42 | + image: dart:stable |
| 43 | + env: |
| 44 | + pub-cache-name: pub |
| 45 | + threshold: 95 |
41 | 46 | timeout-minutes: 10 |
42 | 47 | steps: |
43 | 48 | - name: 🚂 Get latest code |
44 | | - uses: actions/checkout@v3 |
| 49 | + id: checkout |
| 50 | + uses: actions/checkout@v4 |
45 | 51 | with: |
46 | | - fetch-depth: 2 |
| 52 | + sparse-checkout: | |
| 53 | + .github |
| 54 | + pubspec.yaml |
| 55 | + lib |
| 56 | + test |
| 57 | + analysis_options.yaml |
| 58 | + CHANGELOG.md |
47 | 59 |
|
48 | | - - name: 🚃 Cache pub modules |
49 | | - uses: actions/cache@v2 |
50 | | - env: |
51 | | - cache-name: cache-pub-package |
| 60 | + - name: 📤 Restore Pub modules |
| 61 | + id: cache-pub-restore |
| 62 | + uses: actions/cache/restore@v4 |
52 | 63 | with: |
53 | 64 | path: | |
54 | | - $PWD/.pub_cache/ |
55 | | - key: ${{ runner.os }}-pub-${{ env.cache-name }}-${{ hashFiles('**/pubspec.yaml') }} |
| 65 | + $HOME/.pub-cache |
| 66 | + key: ${{ runner.os }}-${{ env.pub-cache-name }}-${{ hashFiles('**/pubspec.yaml') }} |
56 | 67 |
|
57 | | - - name: 🗄️ Export pub cache directory |
58 | | - run: export PUB_CACHE=$PWD/.pub_cache/ |
| 68 | + - name: 🗄️ Export Pub cache directory |
| 69 | + id: export-pub-cache |
| 70 | + timeout-minutes: 1 |
| 71 | + run: | |
| 72 | + export PUB_CACHE=$PWD/.pub_cache/ |
| 73 | + export PATH="$PATH":"$HOME/.pub-cache/bin" |
| 74 | + echo "${HOME}/.pub-cache/bin" >> $GITHUB_PATH |
59 | 75 |
|
60 | 76 | - name: 👷 Install Dependencies |
| 77 | + id: install-dependencies |
61 | 78 | timeout-minutes: 1 |
62 | 79 | run: | |
63 | | - dart pub get |
| 80 | + apt-get update && apt-get install -y lcov |
| 81 | + dart pub global activate coverage |
| 82 | + dart pub get --no-example |
| 83 | +
|
| 84 | + - name: 📥 Save Pub modules |
| 85 | + id: cache-pub-save |
| 86 | + uses: actions/cache/save@v4 |
| 87 | + with: |
| 88 | + path: | |
| 89 | + $HOME/.pub-cache |
| 90 | + key: ${{ runner.os }}-${{ env.pub-cache-name }}-${{ hashFiles('**/pubspec.yaml') }} |
64 | 91 |
|
65 | 92 | - name: 🔎 Check format |
| 93 | + id: check-format |
66 | 94 | timeout-minutes: 1 |
67 | | - run: dart format --set-exit-if-changed -l 80 -o none . |
| 95 | + run: dart format --set-exit-if-changed -l 80 -o none lib/ |
68 | 96 |
|
69 | 97 | - name: 📈 Check analyzer |
| 98 | + id: check-analyzer |
70 | 99 | timeout-minutes: 1 |
71 | | - run: dart analyze --fatal-infos --fatal-warnings lib |
| 100 | + run: dart analyze --fatal-infos --fatal-warnings lib/ |
| 101 | + |
| 102 | + - name: 👀 Verify versions |
| 103 | + id: verify-versions |
| 104 | + timeout-minutes: 1 |
| 105 | + run: | |
| 106 | + test -f pubspec.yaml && test -f CHANGELOG.md |
| 107 | + version_pubspec=$(grep '^version:' pubspec.yaml | awk '{print $2}' | sed 's/[^[:print:]]//g') |
| 108 | + test -n "$version_pubspec" |
| 109 | + echo "Version from pubspec.yaml: '$version_pubspec'" |
| 110 | + grep -q "# $version_pubspec" CHANGELOG.md || (echo "Version not found in CHANGELOG.md" >&2; exit 1) |
72 | 111 |
|
73 | 112 | #- name: Check with pana |
74 | 113 | # run: dart pub global activate pana && pana --json --no-warning --line-length 80 |
| 114 | + |
75 | 115 | - name: 🧪 Run tests |
| 116 | + id: run-tests |
| 117 | + timeout-minutes: 2 |
76 | 118 | run: | |
77 | | - dart test --coverage=coverage \ |
78 | | - && dart run coverage:format_coverage --lcov --in=coverage \ |
79 | | - --out=coverage/lcov.info --report-on=lib |
| 119 | + dart pub global run coverage:test_with_coverage -fb -o coverage -- \ |
| 120 | + --platform vm --compiler=kernel --coverage=coverage \ |
| 121 | + --reporter=github --file-reporter=json:coverage/tests.json \ |
| 122 | + --timeout=10m --concurrency=12 --color \ |
| 123 | + test/test.dart |
80 | 124 |
|
81 | | - - name: 📥 Upload coverage to Codecov |
82 | | - uses: codecov/codecov-action@v2.1.0 |
83 | | - with: |
84 | | - token: ${{ secrets.CODECOV_TOKEN }} |
| 125 | + - name: 🔍 Check coverage |
| 126 | + id: check-coverage |
| 127 | + timeout-minutes: 2 |
| 128 | + run: | |
| 129 | + mv coverage/lcov.info coverage/lcov.base.info |
| 130 | + lcov --remove coverage/lcov.base.info '*.g.dart' -o coverage/lcov.info |
| 131 | + lcov --list coverage/lcov.info |
| 132 | + THRESHOLD=${{ env.threshold }} |
| 133 | + COVERAGE=$(lcov --summary coverage/lcov.info | grep -i 'lines\|Total:' | tail -n 1 | awk '{print $2}' | sed 's/%//') |
| 134 | + echo "Coverage is $COVERAGE%" |
| 135 | + echo $COVERAGE | awk '{if ($1 < 50) exit 1}' |
| 136 | +
|
| 137 | + - name: 🧹 Cleanup artifacts |
| 138 | + id: cleanup-artifacts |
| 139 | + if: always() |
| 140 | + timeout-minutes: 2 |
| 141 | + run: | |
| 142 | + rm -rf ~/build |
85 | 143 |
|
86 | | - - name: 🧮 Check Code Coverage |
87 | | - uses: VeryGoodOpenSource/very_good_coverage@v1.2.1 |
| 144 | + - name: ✨ Upload coverage to Codecov |
| 145 | + id: upload-coverage |
| 146 | + timeout-minutes: 2 |
| 147 | + uses: codecov/codecov-action@v4 |
88 | 148 | with: |
89 | | - path: coverage/lcov.info |
90 | | - min_coverage: 90 |
91 | | - #exclude: '**.g.dart **.freezed.dart' |
| 149 | + token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos |
0 commit comments