-
Notifications
You must be signed in to change notification settings - Fork 33
134 lines (114 loc) · 4.19 KB
/
test.nhost_dart.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
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
# This is a template that is used to produce package-specific workflows
#
# The reason we want package-specific workflows at all is so we can
#
# 1. Limit the workflow to only being triggered on changes to files on the
# package's path, and that of its dependents
# 2. Display a package-specific testing badge (at the time of writing, you can't
# request badges for matrix configurations)
#
# Instantiations of this template are produced by the Melos postbootstrap script
# which can be found in `melos.yaml`.
name: "nhost_dart tests"
on:
push:
branches:
- main
pull_request:
branches:
- main
# schedule:
# Run the quality job at 4am every day
# - cron: '0 4 * * *'
env: {}
jobs:
# Ensure that the package meets a suitably high pub.dev score
score-package-quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: .github/workflows/scripts/make-pana-pubspecs.sh
- uses: axel-op/dart-package-analyzer@v3
# Set an id for the current step, so we can reference it later
id: analysis
with:
githubToken: ${{ github.token }}
relativePath: packages/nhost_dart
- name: Require analysis (near) perfection
env:
# "analysis" is the id set above
TOTAL: ${{ steps.analysis.outputs.total }}
TOTAL_MAX: ${{ steps.analysis.outputs.total_max }}
run: |
PERCENTAGE=$((( $TOTAL ) * 100 / ( $TOTAL_MAX - ${MAX_PANA_MISSING_POINTS:-10} )))
if (( $PERCENTAGE < 100 ))
then
echo "Score to low ($TOTAL/$TOTAL_MAX)."
exit 1
fi
# Analyzes, checks formatting, and tests the packages
test-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache Flutter dependencies
uses: actions/cache@v1
with:
path: /opt/hostedtoolcache/flutter
key: ${{ runner.OS }}-flutter-install-cache-${{ steps.flutter-version.outputs.version }}
# Setup the flutter environment
- name: Setup Dart/Flutter (specific channel)
uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.9"
channel: "stable"
# Get binary dependencies
- name: Install tools
run: |
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
dart pub get
dart pub global activate junitreport
dart pub global activate melos 3.2.0
- name: Bootstrap packages
run: melos bootstrap
# Run analysis on all packages
- name: Analyze packages
run: dart run melos analyze
# Install the latest Nhost CLI
- name: Install Nhost CLI
id: install-nhost-cli
uses: nhost-actions/install-nhost-cli@v1
- name: Start the nhost test_backend
run: |
cd packages/nhost_dart/test/test_backend
nhost --data-folder /tmp/nhost-cli up
# Run tests for package in question
- name: Execute tests
run: melos exec --scope=nhost_dart --dir-exists=test -- 'flutter test --no-pub --machine --coverage | tojunit > test-results.xml'
- name: Stop the nhost test_backend
run: |
cd packages/nhost_dart/test/test_backend
nhost down
# Report test results
- name: Report test results
uses: mikepenz/action-junit-report@v2
with:
check_name: "Test results: nhost_dart"
require_tests: false
report_paths: "packages/nhost_dart/test-results.xml"
github_token: ${{ github.token }}
# Check if coverage was generated
- name: Check for coverage file
id: check_coverage_exists
uses: andstor/file-existence-action@v1
with:
files: "packages/nhost_dart/coverage/lcov.info"
# Report coverage
- name: Report coverage
uses: zgosalvez/github-actions-report-lcov@v1
with:
artifact-name: "Test coverage for nhost_dart"
coverage-files: packages/nhost_dart/coverage/lcov.info
working-directory: packages/nhost_dart/
github-token: ${{ github.token }}
if: ${{ github.event_name != 'pull_request' && steps.check_coverage_exists.outputs.files_exists == 'true' }}