This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
166 lines (156 loc) · 4.82 KB
/
ci.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
name: CI
on:
pull_request:
push:
branches:
- "staging"
- "main"
env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dprint/[email protected]
lint-commits:
runs-on: ubuntu-latest
if: github.event.ref != 'refs/heads/main'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get all commits on current main
run: git fetch origin main
- name: Log all commits we will analyze
run: git log --pretty=format:%s origin/main..HEAD
- name: Disallow fixup! commits
run: git log --pretty=format:%s origin/main..HEAD | grep -zv fixup!
- name: Disallow squash! commits
run: git log --pretty=format:%s origin/main..HEAD | grep -zv squash!
# job to run change detection
changes:
runs-on: ubuntu-latest
# Set job outputs to values from filter step
outputs:
rust: ${{ steps.filter.outputs.rust }}
flutter: ${{ steps.filter.outputs.flutter }}
maker: ${{ steps.filter.outputs.maker }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
token: ${{ secrets.GITHUB_TOKEN }}
filters: |
rust:
- '.github/workflows/**'
- 'rust/**'
- 'rust-toolchain.toml'
- 'Cargo.*'
maker:
- '.github/workflows/**'
- 'maker/**'
- 'rust-toolchain.toml'
- 'Cargo.*'
flutter:
- '.github/workflows/**'
- 'lib/**'
- 'integration_test/**'
- 'android/**'
- 'ios/**'
- 'linux/**'
- 'macos/**'
- 'web/**'
- 'windows/**'
- 'pubspec.*'
clippy:
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.maker == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup rust toolchain
run: rustup show
- uses: Swatinem/[email protected]
- uses: subosito/flutter-action@v2
with:
channel: "stable"
- name: Install FFI bindings
run: cargo install flutter_rust_bridge_codegen
- name: Generate FFI bindings
working-directory: .
run: make gen
- run: cargo clippy --all-targets -- -D warnings
working-directory: .
cargo-test:
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.maker == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup rust toolchain
run: rustup show
- uses: Swatinem/[email protected]
- uses: subosito/flutter-action@v2
with:
channel: "stable"
- name: Install FFI bindings
run: cargo install flutter_rust_bridge_codegen
- name: Generate FFI bindings
working-directory: .
run: make gen
- run: cargo test
working-directory: .
lint-flutter:
needs: changes
if: ${{ needs.changes.outputs.flutter == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: "stable"
- name: Setup rust toolchain
run: rustup show
- name: Install FFI bindings
run: cargo install flutter_rust_bridge_codegen
- name: Generate FFI bindings
run: make gen
- name: Install dependencies
run: flutter pub get
- name: Verify flutter formatting
run: flutter format --output=none --set-exit-if-changed --line-length 100 .
- name: Analyze flutter code
run: flutter analyze --fatal-infos
# See: https://betterprogramming.pub/test-flutter-apps-on-android-with-github-actions-abdba2137b4
flutter-android-test:
needs: changes
if: ${{ (needs.changes.outputs.rust == 'true' || needs.changes.outputs.flutter == 'true') && github.ref != 'refs/heads/main' && github.ref != 'refs/heads/staging'}}
name: Flutter (Android) integration test
strategy:
matrix:
device:
- "pixel"
- "Nexus 6"
fail-fast: false
uses: ./.github/workflows/flutter_android_test.yml
with:
device: ${{ matrix.device }}
# Use an "accummulation" job here because bors often fails (timeouts)
ci-success:
name: CI
needs:
# TODO: Add flutter-android-test when bors is stable
- changes
- formatting
- lint-commits
- clippy
- cargo-test
- lint-flutter
runs-on: ubuntu-latest
if: ${{ always() && contains(needs.*.result, 'success') && !(contains(needs.*.result, 'failure')) }}
steps:
- name: CI succeeded
run: exit 0