forked from cybersonic/LuCLI
-
Notifications
You must be signed in to change notification settings - Fork 0
226 lines (195 loc) · 6.6 KB
/
Copy pathci.yml
File metadata and controls
226 lines (195 loc) · 6.6 KB
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name: CI
on:
push:
branches: [ main, master, develop ]
pull_request:
branches: [ main, master ]
workflow_call:
jobs:
# ==================================================
# Unit Tests (JUnit)
# ==================================================
unit-tests:
name: Unit Tests (${{ matrix.os }}, Java ${{ matrix.java }})
runs-on: ${{ matrix.os }}
permissions:
contents: read
checks: write
pull-requests: write
issues: write
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
java: [21]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ matrix.java }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2-${{ matrix.java }}-
${{ runner.os }}-m2-
- name: Run Unit Tests with Coverage
run: mvn clean test
- name: Upload JUnit Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: unit-test-results-${{ matrix.os }}-java${{ matrix.java }}
path: target/surefire-reports/*.xml
retention-days: 7
if-no-files-found: warn
- name: Upload Coverage Report
if: matrix.os == 'ubuntu-latest' && matrix.java == 21
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: target/site/jacoco/
retention-days: 7
if-no-files-found: warn
- name: Publish Unit Test Results (Linux only)
if: always() && runner.os == 'Linux'
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: target/surefire-reports/*.xml
check_name: Unit Tests (${{ matrix.os }}, Java ${{ matrix.java }})
# ==================================================
# Integration Tests (BATS)
# ==================================================
integration-tests:
name: Integration Tests (${{ matrix.os }}, Java ${{ matrix.java }})
runs-on: ${{ matrix.os }}
permissions:
contents: read
checks: write
pull-requests: write
issues: write
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
java: [21]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ matrix.java }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2-${{ matrix.java }}-
${{ runner.os }}-m2-
- name: Install bats (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y bats
- name: Install bats-core (macOS)
if: runner.os == 'macOS'
run: brew install bats-core
- name: Build JAR and Binary
run: |
mvn clean package -DskipTests -Pbinary
chmod +x target/lucli
- name: Verify binary works
run: ./target/lucli --version
- name: Run Integration Tests (BATS)
run: |
chmod +x tests/*.sh tests/lib/*.sh 2>/dev/null || true
./tests/test-bats.sh
env:
CI: true
BATS_JUNIT_XML_OUTPUT: integration-test-results.xml
- name: Upload Integration Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: integration-test-results-${{ matrix.os }}-java${{ matrix.java }}
path: integration-test-results.xml
retention-days: 7
if-no-files-found: warn
- name: Publish Integration Test Results (Linux only)
if: always() && runner.os == 'Linux'
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: integration-test-results.xml
check_name: Integration Tests (${{ matrix.os }}, Java ${{ matrix.java }})
# ==================================================
# Build Verification
# ==================================================
build:
name: Build (${{ matrix.os }}, Java ${{ matrix.java }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
java: [21]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ matrix.java }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2-${{ matrix.java }}-
${{ runner.os }}-m2-
- name: Build JAR
run: mvn clean package -DskipTests
- name: Test JAR execution
run: java -jar target/lucli.jar --version
- name: Build binary (Unix)
if: runner.os != 'Windows'
run: |
mvn clean package -DskipTests -Pbinary
chmod +x target/lucli
./target/lucli --version
- name: Build Windows executable (Launch4j)
if: runner.os == 'Windows'
run: mvn package -DskipTests -Pwindows-exe
- name: Verify Windows executable works
if: runner.os == 'Windows'
run: .\target\lucli.exe --version
# ==================================================
# Published APT Repository Smoke Test
# ==================================================
apt-install-smoke:
name: APT Install Smoke (Ubuntu)
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
steps:
- name: Install apt prerequisites
run: |
sudo apt-get update
sudo apt-get install -y curl ca-certificates gnupg
- name: Configure LuCLI apt source
run: |
curl -fsSL https://lucli.dev/apt/gpg.key | sudo tee /usr/share/keyrings/lucli-archive-keyring.asc >/dev/null
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/lucli-archive-keyring.asc] https://lucli.dev/apt stable main" | sudo tee /etc/apt/sources.list.d/lucli.list >/dev/null
sudo apt-get update
- name: Install and verify lucli from apt
run: |
sudo apt-get install -y lucli
lucli --version