b4e4982876
- Adjusted formatting in XML response strings for consistency in device_extended_test.go and device_security_test.go. - Improved readability by aligning XML declaration and body content. - Updated mock server responses to ensure proper handling of various ONVIF operations. Enhance device security and storage handling - Refactored struct field declarations in device_security.go and device_storage_test.go for improved clarity. - Ensured consistent formatting across struct definitions and XML tags. Standardize whitespace and formatting across multiple files - Removed unnecessary blank lines and adjusted indentation in discovery, imaging, media, and PTZ server files. - Improved overall code readability and maintainability by ensuring consistent formatting. Update example applications for better readability - Cleaned up whitespace in example applications to enhance code clarity. - Ensured consistent formatting in main.go files across various examples. Refactor server and SOAP handler code for consistency - Standardized struct field declarations and XML tag formatting in server and SOAP handler files. - Improved readability by aligning struct fields and ensuring consistent use of whitespace. General code cleanup and formatting adjustments - Applied consistent formatting across various files, including types.go and test files. - Enhanced readability by aligning struct fields and removing unnecessary blank lines.
209 lines
5.9 KiB
YAML
209 lines
5.9 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ master, main, develop ]
|
|
pull_request:
|
|
branches: [ master, main, develop ]
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
# Quick validation - fail fast on obvious issues
|
|
validate:
|
|
name: Quick Validation
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@d632cb752374ac6c22015e4b4bef1d19db85d69f # v4.2.0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@0a12ed9d6470c3512128ab8f076f97fbbff3da52 # v5.0.1
|
|
with:
|
|
go-version: '1.23'
|
|
|
|
- name: Cache Go modules
|
|
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
|
|
- name: Download dependencies
|
|
run: go mod download && go mod verify
|
|
|
|
- name: Check formatting
|
|
run: |
|
|
if [ "$(gofmt -s -l . | grep -v vendor | wc -l)" -gt 0 ]; then
|
|
echo "Code formatting issues found:"
|
|
gofmt -s -d . | grep -v vendor
|
|
exit 1
|
|
fi
|
|
|
|
- name: Lint
|
|
uses: golangci/golangci-lint-action@3cfe3a4ac716397848d91e4042119f51a40b6aaf # v4.0.0
|
|
with:
|
|
version: latest
|
|
args: --timeout=5m --fix=false
|
|
|
|
# Test on primary Go version
|
|
test:
|
|
name: Test (Go 1.23)
|
|
runs-on: ubuntu-latest
|
|
needs: validate
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@d632cb752374ac6c22015e4b4bef1d19db85d69f # v4.2.0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@0a12ed9d6470c3512128ab8f076f97fbbff3da52 # v5.0.1
|
|
with:
|
|
go-version: '1.23'
|
|
|
|
- name: Cache Go modules
|
|
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-1.23-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-1.23-
|
|
|
|
- name: Download dependencies
|
|
run: go mod download
|
|
|
|
- name: Run tests with coverage
|
|
run: go test -v -race -covermode=atomic -coverprofile=coverage.out ./...
|
|
|
|
- name: Generate coverage report
|
|
run: go tool cover -html=coverage.out -o coverage.html
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@8a4b2d1c64a2a31fb92d9fa9f1e2b02e35d2db1a # v4.0.1
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: ./coverage.out
|
|
flags: unittests
|
|
name: codecov-umbrella
|
|
fail_ci_if_error: true
|
|
|
|
- name: Archive coverage
|
|
if: always()
|
|
uses: actions/upload-artifact@89ef406dd8d8a50a2f1e5e903c0e970c27a27de8 # v4.3.5
|
|
with:
|
|
name: coverage-report
|
|
path: |
|
|
coverage.out
|
|
coverage.html
|
|
retention-days: 30
|
|
|
|
# Test on multiple Go versions (after primary test passes)
|
|
test-matrix:
|
|
name: Test (Go ${{ matrix.go-version }})
|
|
runs-on: ${{ matrix.os }}
|
|
needs: test
|
|
strategy:
|
|
fail-fast: true # Stop on first failure
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
go-version: ['1.21', '1.22']
|
|
exclude:
|
|
- os: macos-latest
|
|
go-version: '1.21'
|
|
- os: windows-latest
|
|
go-version: '1.21'
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@d632cb752374ac6c22015e4b4bef1d19db85d69f # v4.2.0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@0a12ed9d6470c3512128ab8f076f97fbbff3da52 # v5.0.1
|
|
with:
|
|
go-version: ${{ matrix.go-version }}
|
|
|
|
- name: Cache Go modules
|
|
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
|
|
with:
|
|
path: |
|
|
~/.cache/go-build
|
|
~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
|
|
|
- name: Download dependencies
|
|
run: go mod download
|
|
|
|
- name: Run tests
|
|
run: go test -v -race ./...
|
|
|
|
# Code quality - only run if tests pass
|
|
sonarcloud:
|
|
name: Code Quality (SonarCloud)
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@d632cb752374ac6c22015e4b4bef1d19db85d69f # v4.2.0
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Download coverage from test job
|
|
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
|
with:
|
|
name: coverage-report
|
|
|
|
- name: SonarCloud Scan
|
|
uses: SonarSource/sonarcloud-github-action@3b335e14ab49358d133eef17b8c1590fe7c21c0e # v2.2.0
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
with:
|
|
args: >
|
|
-Dsonar.projectKey=0x524a_go-onvif
|
|
-Dsonar.organization=0x524a
|
|
-Dsonar.go.coverage.reportPaths=coverage.out
|
|
|
|
# Build verification
|
|
build:
|
|
name: Build
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@d632cb752374ac6c22015e4b4bef1d19db85d69f # v4.2.0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@0a12ed9d6470c3512128ab8f076f97fbbff3da52 # v5.0.1
|
|
with:
|
|
go-version: '1.23'
|
|
|
|
- name: Cache Go modules
|
|
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-1.23-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-1.23-
|
|
|
|
- name: Download dependencies
|
|
run: go mod download
|
|
|
|
- name: Build main packages
|
|
run: go build -v ./...
|
|
|
|
- name: Build examples
|
|
run: |
|
|
for dir in examples/*/; do
|
|
echo "Building $dir"
|
|
(cd "$dir" && go build -v .)
|
|
done
|