Add helpful targets via Makefile (#211)
## Motivation and Context <!-- Why is this change needed? What problem does it solve? --> The following PR: * Adds a Makefile with the most common project-related commands * Updates the CI workflow to leverage that (people testing locally will use the same commands as the CI) * Switches to using the official Golangci-lint action instead of downloading it via curl * Bumps the golangci version (supersedes #144) * Fixes any formatting/linting issues found * Updates the README to reference the new make targets * Runs the schema validation scripts as part of the CI **Next:** * If you are okay I can file a follow up PR afterwards where I can tidy up the CI workflows a bit, it feels there's some overlap. ## How Has This Been Tested? <!-- Have you tested this in a real application? Which scenarios were tested? --> Locally by running the make targets ## Breaking Changes <!-- Will users need to update their code or configurations? --> ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed ## Additional context <!-- Add any other context, implementation notes, or design decisions --> --------- Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com> Co-authored-by: Adam Jones <adamj+git@anthropic.com>
This commit is contained in:
parent
5acd00024f
commit
f5bf542697
3 changed files with 195 additions and 221 deletions
114
.github/workflows/ci.yml
vendored
114
.github/workflows/ci.yml
vendored
|
|
@ -2,45 +2,17 @@ name: CI Pipeline
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop ]
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main, develop ]
|
||||
branches: [ main ]
|
||||
|
||||
env:
|
||||
GO_VERSION: '1.23.x'
|
||||
|
||||
jobs:
|
||||
# Lint and Format Check
|
||||
lint:
|
||||
name: Lint and Format
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Install golangci-lint
|
||||
run: |
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.3.1
|
||||
|
||||
- name: Run golangci-lint
|
||||
run: golangci-lint run --timeout=5m
|
||||
|
||||
- name: Check Go formatting
|
||||
run: |
|
||||
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
|
||||
echo "The following files are not properly formatted:"
|
||||
gofmt -s -l .
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build check
|
||||
build:
|
||||
name: Build Check
|
||||
# Build, Lint, and Validate
|
||||
build-lint-validate:
|
||||
name: Build, Lint, and Validate
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
|
|
@ -64,20 +36,28 @@ jobs:
|
|||
- name: Download dependencies
|
||||
run: go mod download
|
||||
|
||||
- name: Build application
|
||||
- name: Install golangci-lint
|
||||
run: |
|
||||
go build -v ./cmd/...
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.3.1
|
||||
|
||||
- name: Run lint
|
||||
run: make lint
|
||||
|
||||
- name: Validate schemas and examples
|
||||
run: make validate
|
||||
|
||||
- name: Build application
|
||||
run: make build
|
||||
|
||||
- name: Check for vulnerabilities
|
||||
run: |
|
||||
go install golang.org/x/vuln/cmd/govulncheck@latest
|
||||
govulncheck ./...
|
||||
|
||||
# Unit Tests
|
||||
unit-tests:
|
||||
name: Unit Tests
|
||||
# All Tests
|
||||
tests:
|
||||
name: Tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: [lint, build]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
|
@ -100,9 +80,8 @@ jobs:
|
|||
- name: Download dependencies
|
||||
run: go mod download
|
||||
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/...
|
||||
- name: Run all tests
|
||||
run: make test-all
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
|
|
@ -111,54 +90,3 @@ jobs:
|
|||
flags: unittests
|
||||
name: codecov-unit
|
||||
fail_ci_if_error: false
|
||||
|
||||
# Integration Tests
|
||||
integration-tests:
|
||||
name: Integration Tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: [lint, build]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
- name: Download dependencies
|
||||
run: go mod download
|
||||
|
||||
- name: Run integration tests
|
||||
run: |
|
||||
chmod +x ./tests/integration/run.sh
|
||||
./tests/integration/run.sh
|
||||
|
||||
# Overall status check
|
||||
test-summary:
|
||||
name: Test Summary
|
||||
runs-on: ubuntu-latest
|
||||
needs: [unit-tests, integration-tests]
|
||||
if: always()
|
||||
steps:
|
||||
- name: Check test results
|
||||
run: |
|
||||
if [[ "${{ needs.unit-tests.result }}" == "success" && "${{ needs.integration-tests.result }}" == "success" ]]; then
|
||||
echo "✅ All tests passed!"
|
||||
exit 0
|
||||
else
|
||||
echo "❌ Some tests failed:"
|
||||
echo " Unit tests: ${{ needs.unit-tests.result }}"
|
||||
echo " Integration tests: ${{ needs.integration-tests.result }}"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
52
.github/workflows/integration-tests.yml
vendored
52
.github/workflows/integration-tests.yml
vendored
|
|
@ -1,52 +0,0 @@
|
|||
name: Integration Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop ]
|
||||
pull_request:
|
||||
branches: [ main, develop ]
|
||||
|
||||
jobs:
|
||||
integration-tests:
|
||||
name: Run Integration Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: ['1.23.x']
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
- name: Download dependencies
|
||||
run: go mod download
|
||||
|
||||
- name: Verify dependencies
|
||||
run: go mod verify
|
||||
|
||||
- name: Set up test environment
|
||||
run: |
|
||||
# Create any necessary directories for test data
|
||||
mkdir -p /tmp/test-data
|
||||
|
||||
- name: Run integration tests
|
||||
run: |
|
||||
# Run integration tests using the existing script
|
||||
chmod +x ./tests/integration/run.sh
|
||||
./tests/integration/run.sh
|
||||
63
.github/workflows/unit-tests.yml
vendored
63
.github/workflows/unit-tests.yml
vendored
|
|
@ -1,63 +0,0 @@
|
|||
name: Unit Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop ]
|
||||
pull_request:
|
||||
branches: [ main, develop ]
|
||||
|
||||
jobs:
|
||||
unit-tests:
|
||||
name: Run Unit Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: ['1.23.x']
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
- name: Download dependencies
|
||||
run: go mod download
|
||||
|
||||
- name: Verify dependencies
|
||||
run: go mod verify
|
||||
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
# Run unit tests with coverage, excluding integration tests
|
||||
go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/...
|
||||
|
||||
- name: Generate coverage report
|
||||
run: go tool cover -html=coverage.out -o coverage.html
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
file: ./coverage.out
|
||||
flags: unittests
|
||||
name: codecov-umbrella
|
||||
fail_ci_if_error: false
|
||||
|
||||
- name: Upload coverage artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: coverage-report
|
||||
path: coverage.html
|
||||
Loading…
Reference in a new issue