-
-
Notifications
You must be signed in to change notification settings - Fork 34
172 lines (151 loc) · 4.91 KB
/
code_quality.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Quality checks 👌🧪
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
pull_request:
paths-ignore:
- '**/*.md'
workflow_call:
workflow_dispatch:
jobs:
ci:
name: Dart CI Checks
runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# work_dir: [ openapi-generator, openapi-generator-annotations ]
# defaults:
# run:
# working-directory: ${{ matrix.work_dir }}
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
- uses: bluefireteam/melos-action@v3
# - name: Checkout
# uses: actions/checkout@v3
# - name: Setup Dart
# uses: dart-lang/setup-dart@v1
# with:
# sdk: stable
# - name: Setup Flutter
# uses: subosito/flutter-action@v3
# with:
# channel: stable
#
# - name: Install Melos
# run: dart pub global activate melos
# - name: Bootstrap Melos
# run: melos bootstrap
- name: Install Dependencies
run: melos exec -- "dart pub get"
- name: Build runner
run: melos exec --scope=openapi-generator -- dart run build_runner build --delete-conflicting-outputs
- name: Validate formatting
run: melos format --set-exit-if-changed
- name: Run analyzer
run: melos analyze --fatal-warnings
- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Start Docker compose containers
# if: ${{ matrix.work_dir == 'openapi-generator' }}
run: docker-compose -f "docker-compose.yaml" up -d --build
- name: Run tests
run: melos run test:all
- name: Install coverage tools
run: dart pub global activate coverage
- name: Install Coverage Tools
run: dart pub global activate coverage combine_coverage
- name: Format Coverage for Each Package
run: |
# Find each package's coverage directory and format to lcov
for dir in $(find . -name "coverage" -type d); do
$HOME/.pub-cache/bin/format_coverage \
--lcov \
--in=$dir \
--out=$dir/coverage.lcov \
--packages=$dir/../.packages \
--report-on=lib
done
- name: Combine Coverage Reports
run: |
mkdir -p coverage # Create a root coverage folder if it doesn't exist
dart pub global run combine_coverage \
--repo-path="." \
--output=coverage/combined.lcov # Combines all into a single lcov file
- name: Upload Combined Coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage/combined.lcov
flags: combined_coverage
name: Combined Code Coverage
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # Required only for private repositories
- name: Stop Docker Container
run: docker-compose -f "docker-compose.yaml" down
build:
name: Build example project 🛠️
runs-on: ubuntu-latest
strategy:
fail-fast: false
defaults:
run:
working-directory: example
steps:
- name: Checkout ⬇️
uses: actions/checkout@v3
- name: Setup Java 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Build Example Project 🛠
uses: subosito/flutter-action@v2
with:
cache: true
channel: 'stable'
- run: flutter pub get
- run: flutter pub run build_runner build --delete-conflicting-outputs
- run: flutter build apk
# - name: Upload artifact (Client) ⬆️💻
# uses: actions/[email protected]
# with:
# name: example
# path: |
# example/build/web
pr_context:
name: Save PR context as artifact
if: ${{ always() && !cancelled() && github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
needs:
# - dependency-review
- build
- ci
steps:
- name: Save PR context
env:
PR_NUMBER: ${{ github.event.number }}
PR_SHA: ${{ github.sha }}
run: |
echo $PR_NUMBER > PR_number
echo $PR_SHA > PR_sha
- name: Upload PR number as artifact
uses: actions/[email protected]
with:
name: PR_context
path: |
PR_number
PR_sha
conventional_commits:
name: Conventional commits check 💬
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- name: Checkout ⬇️
uses: actions/[email protected]
- name: Check if all commits comply with the specification
uses: webiny/[email protected]