forked from AmityCo/amity_social_cloud_sdk_flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (122 loc) · 4.75 KB
/
flutter-test-coverage.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
136
137
138
139
140
141
142
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Flutter Test Coverage
on:
push:
branches:
- master
- develop
- sprint
- "release-**"
pull_request:
branches:
- master
- develop
- "release-**"
permissions:
contents: read # Required when overriding permissions
pull-requests: write # <== Add this to allow action to modify your PR
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
# Note: This workflow uses the latest stable version of the Dart SDK.
# You can specify other versions if desired, see documentation here:
# https://github.com/dart-lang/setup-dart/blob/main/README.md
# - uses: dart-lang/setup-dart@v1
- uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603
- name: Dart version
run: dart --version
- name: Install Flutter
# You may pin to the exact commit or the version.
# uses: britannio/action-install-flutter@a486b7e3148e54a76390d849100b9dee819ff810
uses: britannio/[email protected]
with:
channel: "stable"
- name: Flutter version
run: flutter --version
- name: Flutter Clean
run: flutter clean
- name: Install dependencies
run: flutter pub get
- name: Dart Analyze
uses: zgosalvez/github-actions-analyze-dart@v1
continue-on-error: true
- name: Flutter test
run: |
flutter pub global activate junitreport
flutter test --machine | tojunit --output report.xml
continue-on-error: true
- name: Create Test Report
id: createJunitReport
uses: mikepenz/action-junit-report@v3
# if: always()
with:
report_paths: ./report.xml
- name: Flutter Test Coverage
run: flutter test --coverage
continue-on-error: true
- name: Create Coverage Report for base branch
run: |
mv ./coverage/lcov.info ./coverage/lcov_head.info
git fetch
git checkout origin/${{ github.event.pull_request.base.ref }}
flutter clean
flutter pub get
flutter test --coverage
continue-on-error: true
- name: Generate and Comment coverage report
if: always()
uses: andybelltree/[email protected]
with:
lcov-file: ./coverage/lcov_head.info
lcov-base: ./coverage/lcov.info
delete-old-comments: true
github-token: ${{ secrets.GITHUB_TOKEN }}
filter-changed-files: true
- name: Compose Message Body for Pull Request Event
# if: ${{ github.event_name == 'pull_request' }}
id: pull_body_message
run: |
echo "MESSAGE=${{ format('🥇 PR - #{0} {1} \n👉 Link - {2}\n🥇 Branch - into {3} from {4}\n',
github.event.pull_request.number,
github.event.pull_request.title,
github.event.pull_request._links.html.href,
github.base_ref,
github.head_ref
) }}" >> $GITHUB_OUTPUT
- name: Generate String test report
id: string_test_report
run: |
echo "MESSAGE=${{ format('Test Report\n🧑🏻💻Total=>{0}\t🕺🏻Passed=>{1}\t🤦🏻♂️Failed=>{2}\t🤷🏻♂️Skipped=>{3}',
steps.createJunitReport.outputs.total,
steps.createJunitReport.outputs.passed,
steps.createJunitReport.outputs.failed,
steps.createJunitReport.outputs.skipped
) }}" >> $GITHUB_OUTPUT
- name: Compose Full Report Message to Send
id: compose_full_report
run: |
echo "MESSAGE=${{ format('{0}\n\n{1}',
steps.pull_body_message.outputs.MESSAGE,
steps.string_test_report.outputs.MESSAGE
) }}" >> $GITHUB_OUTPUT
- name: Publish test repo to PR Comment
id: testToPrComment
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Flutter Test Result
message: ${{steps.compose_full_report.outputs.MESSAGE }}
continue-on-error: true
- name: Send Message to Eko Chat
uses: fjogeleit/http-request-action@v1
with:
url: ${{ secrets.BOT_EKO_CHAT_MESSAGING_URL }}
method: "POST"
bearerToken: ${{ secrets.BOT_AUTH_TOKEN }}
customHeaders: '{"Content-Type": "application/json"}'
data: '{"gid": "${{ secrets.BOT_GROUP_ID }}", "tid": "${{ secrets.BOT_CHAT_ID }}","message": {"data": "${{ steps.compose_full_report.outputs.MESSAGE }}", "type": "text"}}'