-
Notifications
You must be signed in to change notification settings - Fork 5
315 lines (265 loc) · 13 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
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
name: .NET Core
on:
push:
branches: [ main, release* ]
tags: [ v* ]
pull_request:
branches: [ main, release* ]
env:
ECLINT_VERSION: "0.3.3"
_JAVA_OPTIONS: "-Xms10m -Xmx1024m"
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
env:
BUILD_ARTIFACTS_FOLDER: build_artifacts
steps:
- name: "[Setup] - Checkout code"
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for GitVersion
submodules: 'recursive'
- name: "[Setup] - Set HOME env variable (Windows)"
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
"HOME=${env:GITHUB_WORKSPACE}" >> $env:GITHUB_ENV
- name: "[Setup] - .NET Core"
uses: actions/setup-dotnet@v3
with:
global-json-file: ./global.json
- name: "[Setup] - Install GitVersion"
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.10.3'
- name: "[Setup] - Install Ruby"
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: "[Setup] - Java" # required to build/install `freshli-agent-java`
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: "[Setup] - Set HOME env variable (Windows)"
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
"HOME=${env:GITHUB_WORKSPACE}" >> $env:GITHUB_ENV
- name: "[Versioning] - GitVersion Config"
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
additionalArguments: '/showConfig'
- name: "[Versioning] - Determine Version"
uses: gittools/actions/gitversion/[email protected]
id: gitversion
with:
useConfigFile: true
- name: "[Versioning] - Update csproj Files"
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
additionalArguments: '/updateprojectfiles'
- name: "[Versioning] - Display updated csproj File"
run: cat Corgibytes.Freshli.Cli/Corgibytes.Freshli.Cli.csproj
- name: "[Build] - Build"
run: dotnet build --configuration Release
- name: "[Build] - Setup for Acceptance Test Coverage Collection, and for running the linters"
run: |
dotnet tool restore
- name: "[Build] - dotnet build"
run: |
dotnet build -o exe
- name: "[Lint] - Install eclint on Linux"
if: runner.os != 'Windows'
run: |
curl -L https://gitlab.com/greut/eclint/-/releases/v$ECLINT_VERSION/downloads/eclint_${ECLINT_VERSION}_linux_x86_64.tar.gz -o /tmp/eclint_${ECLINT_VERSION}_linux_x86_64.tar.gz && \
mkdir -p $HOME/.local/opt/eclint && \
tar -zxvf /tmp/eclint_${ECLINT_VERSION}_linux_x86_64.tar.gz -C $HOME/.local/opt/eclint && \
rm /tmp/eclint_${ECLINT_VERSION}_linux_x86_64.tar.gz
echo "$HOME/.local/opt/eclint" >> $GITHUB_PATH
- name: "[Lint] - Install eclint on Windows"
if: runner.os == 'Windows'
run: |
New-Item -Type Directory -Force $HOME\.local\opt\eclint
Invoke-WebRequest -Uri https://gitlab.com/greut/eclint/-/releases/v$env:ECLINT_VERSION/downloads/eclint_${env:ECLINT_VERSION}_windows_x86_64.tar.gz -OutFile $HOME\.local\opt\eclint\eclint_${env:ECLINT_VERSION}_windows_x86_64.tar.gz
Set-Location $HOME\.local\opt\eclint
tar -zxvf .\eclint_${env:ECLINT_VERSION}_windows_x86_64.tar.gz
Write-Output "$HOME\.local\opt\eclint" | Out-File -Append $env:GITHUB_PATH
- name: "[Lint] - Run all linters"
run: |
ruby bin/lint.rb
- name: "[Test] - Install freshli-agent-java on Linux"
if: runner.os != 'Windows'
run: |
mkdir -p $HOME/.local/opt
cd $HOME/.local/opt
git clone https://github.com/corgibytes/freshli-agent-java
cd freshli-agent-java
./gradlew installDist
chmod a-x build/install/freshli-agent-java/bin/freshli-agent-java.bat
echo "$HOME/.local/opt/freshli-agent-java/build/install/freshli-agent-java/bin" >> $GITHUB_PATH
- name: "[Test] - Install freshli-agent-java on Windows"
if: runner.os == 'Windows'
run: |
New-Item -Type Directory -Force $HOME\.local\opt
Set-Location $HOME\.local\opt
git clone https://github.com/corgibytes/freshli-agent-java
Set-Location .\freshli-agent-java
.\gradlew installDist
Write-Output "$HOME\.local\opt\freshli-agent-java\build\install\freshli-agent-java\bin" | Out-File -Append $env:GITHUB_PATH
- name: "[Test] - Confirm freshli-agent-java availability"
run: |
freshli-agent-java --help
- name: "[Test] - Install freshli-agent-dotnet on Linux"
if: runner.os != 'Windows'
run: |
mkdir -p $HOME/.local/opt
cd $HOME/.local/opt
git clone https://github.com/corgibytes/freshli-agent-dotnet
cd freshli-agent-dotnet
bundle install
bundle exec ./bin/build.rb
echo "$HOME/.local/opt/freshli-agent-dotnet/exe" >> $GITHUB_PATH
- name: "[Test] - Install freshli-agent-dotnet on Windows"
if: runner.os == 'Windows'
run: |
New-Item -Type Directory -Force $HOME\.local\opt
Set-Location $HOME\.local\opt
git clone https://github.com/corgibytes/freshli-agent-dotnet
Set-Location .\freshli-agent-dotnet
bundle install
bundle exec .\bin\build.rb
Write-Output "$HOME\.local\opt\freshli-agent-dotnet\exe" | Out-File -Append $env:GITHUB_PATH
- name: "[Test] - Confirm freshli-agent-dotnet availability"
run: |
freshli-agent-dotnet --help
- name: "[Test] - Install dotnet-CycloneDX on Linux"
if: runner.os != 'Windows'
run: |
dotnet tool install --global CycloneDX
echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
- name: "[Test] - Install dotnet-CycloneDX on Windows"
if: runner.os == 'Windows'
run: |
dotnet tool install --global CycloneDX
Write-Output "$HOME\.dotnet\tools" | Out-File -Append $env:GITHUB_PATH
- name: "[Test] - Confirm dotnet-CycloneDX availability"
run: |
dotnet-CycloneDX --help
- name: "[Test] - Test, Generate Code Coverage"
run: |
dotnet coverlet ./exe --target "dotnet" --targetargs 'test --logger "console;verbosity=detailed" --blame-hang-timeout 10min exe/Corgibytes.Freshli.Cli.Test.dll' --format lcov
- name: "[Test] - Behavior Acceptance Tests"
run: |
bundle exec cucumber
- name: "[Test] - Send Code Coverage Data to Code Climate"
uses: paambaati/[email protected]
if: ${{ github.actor != 'dependabot[bot]' && runner.os != 'Windows' }}
env:
CC_TEST_REPORTER_ID: ${{ secrets.TEST_REPORTER_ID }}
with:
coverageLocations: |
${{github.workspace}}/coverage.info:lcov
- name: "[Publish] - Publish win-x64, linux-x64 and osx-x64"
if: runner.os != 'Windows'
run: |
dotnet publish -r win-x64 -c Release --self-contained false
dotnet publish -r linux-x64 -c Release --self-contained false
dotnet publish -r osx-x64 -c Release --self-contained false
- name: "[Post Publish] - Zip win-x64 Release"
if: runner.os != 'Windows'
uses: papeloto/action-zip@v1
with:
files: Corgibytes.Freshli.Cli/bin/Release/net7.0/win-x64/publish
dest: ${{ env.BUILD_ARTIFACTS_FOLDER }}/freshli-cli-${{ steps.gitversion.outputs.majorMinorPatch }}-win-x64.zip
- name: "[Post Publish] - Zip linux-x64 Release"
if: runner.os != 'Windows'
uses: papeloto/action-zip@v1
with:
files: Corgibytes.Freshli.Cli/bin/Release/net7.0/linux-x64/publish
dest: ${{ env.BUILD_ARTIFACTS_FOLDER }}/freshli-cli-${{ steps.gitversion.outputs.majorMinorPatch }}-linux-x64.zip
- name: "[Post Publish] - Zip osx-x64 Release"
if: runner.os != 'Windows'
uses: papeloto/action-zip@v1
with:
files: Corgibytes.Freshli.Cli/bin/Release/net7.0/osx-x64/publish
dest: ${{ env.BUILD_ARTIFACTS_FOLDER }}/freshli-cli-${{ steps.gitversion.outputs.majorMinorPatch }}-osx-x64.zip
- name: "[Post Publish] - View Build Artifacts Folder"
if: runner.os != 'Windows'
run: ls -la ${{ env.BUILD_ARTIFACTS_FOLDER }}
- name: "[Post Publish] - Upload win-x64 Assets as Github Workflow Artifacts"
if: runner.os != 'Windows'
uses: actions/upload-artifact@v3
with:
name: freshli-cli-${{ steps.gitversion.outputs.majorMinorPatch }}-alpha-win-x64.zip
path: ${{ env.BUILD_ARTIFACTS_FOLDER }}/freshli-cli-${{ steps.gitversion.outputs.majorMinorPatch }}-win-x64.zip
- name: "[Post Publish] - Upload linux-x64 Assets as Github Workflow Artifacts"
if: runner.os != 'Windows'
uses: actions/upload-artifact@v3
with:
name: freshli-cli-${{ steps.gitversion.outputs.majorMinorPatch }}-alpha-linux-x64.zip
path: ${{ env.BUILD_ARTIFACTS_FOLDER }}/freshli-cli-${{ steps.gitversion.outputs.majorMinorPatch }}-linux-x64.zip
- name: "[Post Publish] - Upload osx-x64 Assets as Github Workflow Artifacts"
if: runner.os != 'Windows'
uses: actions/upload-artifact@v3
with:
name: freshli-cli-${{ steps.gitversion.outputs.majorMinorPatch }}-alpha-osx-x64.zip
path: ${{ env.BUILD_ARTIFACTS_FOLDER }}/freshli-cli-${{ steps.gitversion.outputs.majorMinorPatch }}-osx-x64.zip
- name: "[Publish, Docker] - Set up QEMU"
if: ${{ startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' }}
uses: docker/setup-qemu-action@v3
- name: "[Publish, Docker] - Set up Docker Buildx"
if: ${{ startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' }}
uses: docker/setup-buildx-action@v3
- name: "[Publish, Docker] - Login to DockerHub"
if: ${{ startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "[Publish, Docker] - Login to GitHub Container Registry"
if: ${{ startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "[Publish, Docker] - Build, Push to GitHub Container Registry"
if: ${{ startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' }}
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags:
ghcr.io/corgibytes/freshli-cli:latest,
ghcr.io/corgibytes/freshli-cli:${{ steps.gitversion.outputs.majorMinorPatch }},
ghcr.io/corgibytes/freshli-cli:${{ steps.gitversion.outputs.semVer }}-${{ steps.gitversion.outputs.fullBuildMetadata }}
cache-from: type=registry,ref=ghcr.io/corgibytes/freshli-cli:buildcache
cache-to: type=registry,ref=ghcr.io/corgibytes/freshli-cli:buildcache,mode=max
- name: "[Publish, Docker] - Smoke Test - `agents detect` via GitHub Container Registry image"
if: ${{ startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' }}
run: |
docker run --rm ghcr.io/corgibytes/freshli-cli:${{ steps.gitversion.outputs.majorMinorPatch }} agents detect
- name: "[Publish, Docker] - Smoke Test - Analyze Java Fixture Repo via GitHub Container Registry image"
if: ${{ startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' }}
run: |
docker run --rm ghcr.io/corgibytes/freshli-cli:${{ steps.gitversion.outputs.majorMinorPatch }} analyze https://github.com/corgibytes/freshli-fixture-java-test
- name: "[Publish, Docker] - Smoke Test - Analyze DotNet Fixture Repo via GitHub Container Registry image"
if: ${{ startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' }}
run: |
docker run --rm ghcr.io/corgibytes/freshli-cli:${{ steps.gitversion.outputs.majorMinorPatch }} analyze https://github.com/corgibytes/freshli-fixture-csharp-test
- name: "[Publish, Docker] - Push to Docker Hub"
if: ${{ startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' }}
run: |
docker buildx imagetools create \
--tag corgibytes/freshli-cli:latest,
--tag corgibytes/freshli-cli:${{ steps.gitversion.outputs.majorMinorPatch }},
--tag corgibytes/freshli-cli:${{ steps.gitversion.outputs.semVer }}-${{ steps.gitversion.outputs.fullBuildMetadata }}
ghcr.io/corgibytes/freshli-cli:latest