Skip to content

Commit d7ad62d

Browse files
committed
update ci
1 parent 6964b9c commit d7ad62d

File tree

4 files changed

+236
-0
lines changed

4 files changed

+236
-0
lines changed

.github/workflows/ci.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, dev ]
6+
pull_request:
7+
branches: [ main, dev ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-and-test:
12+
name: Build and Test
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, windows-latest, macos-latest]
17+
dotnet-version: ['8.0.x', '9.0.x']
18+
fail-fast: false
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Setup .NET
27+
uses: actions/setup-dotnet@v4
28+
with:
29+
dotnet-version: ${{ matrix.dotnet-version }}
30+
31+
- name: Restore dependencies
32+
run: dotnet restore
33+
34+
- name: Build
35+
run: dotnet build --configuration Release --no-restore
36+
37+
- name: Run tests
38+
run: dotnet test --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx" --collect:"XPlat Code Coverage" --results-directory ./TestResults
39+
40+
- name: Upload test results
41+
uses: actions/upload-artifact@v4
42+
if: always()
43+
with:
44+
name: test-results-${{ matrix.os }}-${{ matrix.dotnet-version }}
45+
path: ./TestResults/*.trx
46+
47+
- name: Upload coverage reports
48+
uses: actions/upload-artifact@v4
49+
if: always()
50+
with:
51+
name: coverage-${{ matrix.os }}-${{ matrix.dotnet-version }}
52+
path: ./TestResults/**/coverage.cobertura.xml
53+
54+
code-coverage:
55+
name: Code Coverage Report
56+
runs-on: ubuntu-latest
57+
needs: build-and-test
58+
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
59+
60+
steps:
61+
- name: Checkout code
62+
uses: actions/checkout@v4
63+
64+
- name: Download coverage reports
65+
uses: actions/download-artifact@v4
66+
with:
67+
pattern: coverage-ubuntu-latest-9.0.x
68+
path: ./coverage
69+
70+
- name: Code Coverage Summary
71+
uses: irongut/[email protected]
72+
with:
73+
filename: ./coverage/**/coverage.cobertura.xml
74+
badge: true
75+
fail_below_min: false
76+
format: markdown
77+
hide_branch_rate: false
78+
hide_complexity: false
79+
indicators: true
80+
output: both
81+
thresholds: '60 80'
82+
83+
- name: Add Coverage PR Comment
84+
uses: marocchino/sticky-pull-request-comment@v2
85+
if: github.event_name == 'pull_request'
86+
with:
87+
recreate: true
88+
path: code-coverage-results.md
89+
90+
build-status:
91+
name: Build Status
92+
runs-on: ubuntu-latest
93+
needs: [build-and-test]
94+
if: always()
95+
96+
steps:
97+
- name: Check build status
98+
run: |
99+
if [ "${{ needs.build-and-test.result }}" != "success" ]; then
100+
echo "Build or tests failed!"
101+
exit 1
102+
fi
103+
echo "All builds and tests passed successfully!"

.github/workflows/code-quality.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
branches: [ main, dev ]
6+
pull_request:
7+
branches: [ main, dev ]
8+
schedule:
9+
- cron: '0 0 * * 0' # Weekly on Sunday at midnight
10+
workflow_dispatch:
11+
12+
jobs:
13+
lint:
14+
name: Code Analysis
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Setup .NET
24+
uses: actions/setup-dotnet@v4
25+
with:
26+
dotnet-version: '9.0.x'
27+
28+
- name: Restore dependencies
29+
run: dotnet restore
30+
31+
- name: Run dotnet format
32+
run: dotnet format --verify-no-changes --verbosity diagnostic
33+
34+
- name: Run dotnet build analyzers
35+
run: dotnet build --configuration Release /p:TreatWarningsAsErrors=true
36+
37+
security:
38+
name: Security Scan
39+
runs-on: ubuntu-latest
40+
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
45+
- name: Run Trivy vulnerability scanner
46+
uses: aquasecurity/trivy-action@master
47+
with:
48+
scan-type: 'fs'
49+
scan-ref: '.'
50+
format: 'sarif'
51+
output: 'trivy-results.sarif'
52+
53+
- name: Upload Trivy results to GitHub Security
54+
uses: github/codeql-action/upload-sarif@v3
55+
if: always()
56+
with:
57+
sarif_file: 'trivy-results.sarif'
58+
59+
dependency-review:
60+
name: Dependency Review
61+
runs-on: ubuntu-latest
62+
if: github.event_name == 'pull_request'
63+
64+
steps:
65+
- name: Checkout code
66+
uses: actions/checkout@v4
67+
68+
- name: Dependency Review
69+
uses: actions/dependency-review-action@v4
70+
with:
71+
fail-on-severity: moderate

.github/workflows/publish.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Publish to NuGet
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Package version (e.g., 1.0.0)'
10+
required: true
11+
type: string
12+
13+
jobs:
14+
publish:
15+
name: Build and Publish
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup .NET
25+
uses: actions/setup-dotnet@v4
26+
with:
27+
dotnet-version: '9.0.x'
28+
29+
- name: Restore dependencies
30+
run: dotnet restore
31+
32+
- name: Build
33+
run: dotnet build --configuration Release --no-restore
34+
35+
- name: Run tests
36+
run: dotnet test --configuration Release --no-build --verbosity normal
37+
38+
- name: Get version
39+
id: get_version
40+
run: |
41+
if [ "${{ github.event_name }}" == "release" ]; then
42+
VERSION=${GITHUB_REF#refs/tags/v}
43+
else
44+
VERSION=${{ inputs.version }}
45+
fi
46+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
47+
echo "Package version: $VERSION"
48+
49+
- name: Pack NuGet package
50+
run: dotnet pack LanguageServer.Framework/LanguageServer.Framework.csproj --configuration Release --no-build -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output ./artifacts
51+
52+
- name: Publish to NuGet
53+
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
54+
if: success()
55+
56+
- name: Upload artifacts
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: nuget-package
60+
path: ./artifacts/*.nupkg

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
44
[![NuGet](https://img.shields.io/nuget/v/EmmyLua.LanguageServer.Framework.svg)](https://www.nuget.org/packages/EmmyLua.LanguageServer.Framework/)
5+
[![CI](https://github.com/CppCXY/LanguageServer.Framework/actions/workflows/ci.yml/badge.svg)](https://github.com/CppCXY/LanguageServer.Framework/actions/workflows/ci.yml)
6+
[![Code Quality](https://github.com/CppCXY/LanguageServer.Framework/actions/workflows/code-quality.yml/badge.svg)](https://github.com/CppCXY/LanguageServer.Framework/actions/workflows/code-quality.yml)
57

68
A modern, high-performance .NET framework for building [Language Server Protocol (LSP)](https://microsoft.github.io/language-server-protocol/) servers with full LSP 3.18 specification support.
79

0 commit comments

Comments
 (0)