Skip to content

Commit 9dee1d4

Browse files
author
privapps
committed
Squashed commit of the following:
Date: Fri Aug 8 22:38:37 2025 -0700 Update Go version to 1.23, enhance Makefile for multi-OS builds, and improve authentication handling - Updated Go version in CI and release workflows - Added Makefile targets for building binaries for different OS/architectures - Enhanced AuthService to support configurable token refresh and path for tests - Updated ProxyService to validate tokens and handle errors more effectively - Improved error handling in API requests and tests for better coverage Date: Fri Aug 8 15:44:53 2025 -0700 Remove Prometheus metrics integration from proxy and circuit breaker Eliminate Prometheus client dependencies and related metric registration from proxy and circuit breaker code. Update documentation to reflect removal of worker pool metrics and production monitoring. This simplifies the codebase and reduces external dependencies. Date: Fri Aug 8 15:37:14 2025 -0700 Add unit tests for ProxyService and Server components - Implement comprehensive tests for ProxyService including handler, caching, circuit breaker, retry logic, streaming responses, error handling, and concurrent requests. - Introduce tests for Server creation, configuration, worker pool functionality, HTTP client timeout handling, and memory management. - Ensure proper handling of various request scenarios and validate server routes and concurrency. - Utilize mock servers and helper functions to simulate and validate expected behaviors. Date: Fri Aug 8 12:34:29 2025 -0700 Implement HTTP server with graceful shutdown and worker pool - Added internal server implementation with HTTP server and worker pool for handling requests. - Introduced new request/response structures for OpenAI compatibility in transform package. - Updated integration tests to validate API endpoints, ensuring server is running before tests. - Refactored test utilities to support new server structure and configuration. - Created unit tests for authentication, configuration loading, and logger initialization. - Enhanced error handling and logging throughout the application. Date: Thu Aug 7 12:15:25 2025 -0700 Refactor: Remove existing tests and server implementation - Deleted proxy_test.go, server.go, and server_test.go files to clean up the codebase. - Added valid_config.json and models_response.json fixtures for testing. - Introduced integration tests for API endpoints in api_test.go. - Created helper functions in testutils for configuration and server mocking. - Implemented unit tests for authentication, configuration, and logging functionalities. Date: Thu Aug 7 01:32:52 2025 -0700 Refactor CI/CD workflows and improve code quality - Updated GitHub Actions workflows to use the latest versions of actions. - Enhanced security checks by replacing Gosec with Go vet and go mod verify. - Removed the Create Release step and replaced it with softprops/action-gh-release for better asset management. - Improved error handling in authentication and token management functions. - Refactored timeout constants and validation logic in the configuration. - Enhanced test coverage and error handling in various test cases. - Improved logging and graceful shutdown handling in the server. - Updated HTTP response handling to use http.NoBody for clarity. Date: Thu Aug 7 00:34:29 2025 -0700 Merge branch 'main' of https://github.com/privapps/github-copilot-svcs into dev Date: Thu Aug 7 00:34:16 2025 -0700 Add comprehensive tests for logger, main functionality, models, and proxy handling - Introduced logger tests to validate logging levels and initialization. - Enhanced main function tests to cover command execution and environment variable handling. - Added tests for model fetching and validation, including error scenarios. - Implemented proxy request handling tests to ensure proper request processing and error management. - Established server tests for health checks and graceful shutdowns. - Refactored existing code to improve testability and maintainability. Date: Wed Aug 6 12:13:00 2025 -0700 Add support for customizable HTTP headers and cross-platform builds - Introduced new build targets for Linux, macOS, and Windows in Makefile. - Updated README with build instructions for different platforms. - Enhanced configuration to include customizable HTTP headers. - Refactored authentication and API request functions to utilize new header configuration. - Set default header values in config loading.
1 parent 85e5217 commit 9dee1d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+6668
-1708
lines changed

.dockerignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Build artifacts
2+
github-copilot-svcs
3+
github-copilot-svcs-*
4+
*.exe
5+
6+
# Go build cache
7+
.go-build-cache
8+
9+
# Test artifacts
10+
coverage.out
11+
coverage.html
12+
13+
# IDE files
14+
.vscode/
15+
.idea/
16+
17+
# OS files
18+
.DS_Store
19+
Thumbs.db
20+
21+
# Temporary files
22+
*.tmp
23+
*.log
24+
25+
# Config files (sensitive)
26+
config.json

.github/workflows/ci.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, dev ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v4
22+
with:
23+
go-version: '1.23'
24+
25+
- name: Cache Go modules
26+
uses: actions/cache@v3
27+
with:
28+
path: ~/go/pkg/mod
29+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
30+
restore-keys: |
31+
${{ runner.os }}-go-
32+
33+
- name: Download dependencies
34+
run: go mod download
35+
36+
- name: Run tests
37+
run: |
38+
go test -v -race -coverprofile=coverage.out ./...
39+
go tool cover -html=coverage.out -o coverage.html
40+
41+
- name: Upload coverage reports
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: coverage-report
45+
path: |
46+
coverage.out
47+
coverage.html
48+
49+
- name: Upload coverage to Codecov
50+
uses: codecov/codecov-action@v3
51+
with:
52+
file: ./coverage.out
53+
flags: unittests
54+
name: codecov-umbrella
55+
56+
lint:
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Checkout code
60+
uses: actions/checkout@v4
61+
62+
- name: Set up Go
63+
uses: actions/setup-go@v4
64+
with:
65+
go-version: '1.23'
66+
67+
- name: golangci-lint
68+
uses: golangci/golangci-lint-action@v3
69+
with:
70+
version: latest
71+
args: --timeout=5m --out-format=colored-line-number
72+
73+
security:
74+
runs-on: ubuntu-latest
75+
steps:
76+
- name: Checkout code
77+
uses: actions/checkout@v4
78+
79+
- name: Set up Go
80+
uses: actions/setup-go@v4
81+
with:
82+
go-version: '1.23'
83+
84+
- name: Run Go Security Checks
85+
run: |
86+
echo "Running Go vet for security analysis..."
87+
go vet ./...
88+
echo "Running go mod verify for dependency integrity..."
89+
go mod verify
90+
echo "Security checks completed successfully"
91+
92+
build:
93+
runs-on: ubuntu-latest
94+
needs: [test, lint, security]
95+
steps:
96+
- name: Checkout code
97+
uses: actions/checkout@v4
98+
99+
- name: Set up Go
100+
uses: actions/setup-go@v4
101+
with:
102+
go-version: '1.23'
103+
104+
- name: Build binary
105+
run: |
106+
go build -ldflags="-s -w -X main.version=ci-${{ github.sha }}" -o github-copilot-svcs ./cmd/github-copilot-svcs
107+
108+
- name: Upload build artifact
109+
uses: actions/upload-artifact@v4
110+
with:
111+
name: github-copilot-svcs-${{ github.sha }}
112+
path: github-copilot-svcs
113+
114+
docker:
115+
runs-on: ubuntu-latest
116+
needs: [test, lint]
117+
steps:
118+
- name: Checkout code
119+
uses: actions/checkout@v4
120+
121+
- name: Set up Docker Buildx
122+
uses: docker/setup-buildx-action@v3
123+
124+
- name: Login to GitHub Container Registry
125+
if: github.event_name != 'pull_request'
126+
uses: docker/login-action@v3
127+
with:
128+
registry: ghcr.io
129+
username: ${{ github.actor }}
130+
password: ${{ secrets.GITHUB_TOKEN }}
131+
132+
- name: Extract metadata
133+
id: meta
134+
uses: docker/metadata-action@v5
135+
with:
136+
images: ghcr.io/${{ github.repository }}
137+
tags: |
138+
type=ref,event=branch
139+
type=ref,event=pr
140+
type=sha,prefix={{branch}}-
141+
type=raw,value=latest,enable={{is_default_branch}}
142+
143+
- name: Build and push Docker image
144+
uses: docker/build-push-action@v5
145+
with:
146+
context: .
147+
platforms: linux/amd64,linux/arm64
148+
push: ${{ github.event_name != 'pull_request' }}
149+
tags: ${{ steps.meta.outputs.tags }}
150+
labels: ${{ steps.meta.outputs.labels }}
151+
cache-from: type=gha
152+
cache-to: type=gha,mode=max

.github/workflows/release.yml

Lines changed: 60 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ on:
77

88
permissions:
99
contents: write
10+
packages: write
1011

1112
jobs:
1213
release:
1314
runs-on: ubuntu-latest
1415
outputs:
1516
version: ${{ steps.version.outputs.version }}
16-
upload_url: ${{ steps.create_release.outputs.upload_url }}
1717
steps:
1818
- name: Checkout code
1919
uses: actions/checkout@v4
@@ -23,7 +23,7 @@ jobs:
2323
- name: Set up Go
2424
uses: actions/setup-go@v4
2525
with:
26-
go-version: '1.21'
26+
go-version: '1.23'
2727

2828
- name: Get next version
2929
id: version
@@ -59,29 +59,6 @@ jobs:
5959
git tag ${{ steps.version.outputs.version }}
6060
git push origin ${{ steps.version.outputs.version }}
6161
62-
- name: Create Release
63-
id: create_release
64-
uses: actions/create-release@v1
65-
env:
66-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67-
with:
68-
tag_name: ${{ steps.version.outputs.version }}
69-
release_name: Release ${{ steps.version.outputs.version }}
70-
body: |
71-
## Changes in ${{ steps.version.outputs.version }}
72-
73-
Auto-generated release from main branch.
74-
75-
### Downloads
76-
- Linux AMD64: `github-copilot-svcs-linux-amd64.gz`
77-
- Linux ARM64: `github-copilot-svcs-linux-arm64.gz`
78-
- macOS AMD64: `github-copilot-svcs-darwin-amd64.gz`
79-
- macOS ARM64: `github-copilot-svcs-darwin-arm64.gz`
80-
- Windows AMD64: `github-copilot-svcs-windows-amd64.exe.gz`
81-
- Windows ARM64: `github-copilot-svcs-windows-arm64.exe.gz`
82-
draft: false
83-
prerelease: false
84-
8562
build:
8663
needs: release
8764
runs-on: ubuntu-latest
@@ -114,7 +91,7 @@ jobs:
11491
- name: Set up Go
11592
uses: actions/setup-go@v4
11693
with:
117-
go-version: '1.21'
94+
go-version: '1.23'
11895

11996
- name: Build binary
12097
env:
@@ -123,7 +100,7 @@ jobs:
123100
CGO_ENABLED: 0
124101
run: |
125102
BINARY_NAME="github-copilot-svcs-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}"
126-
go build -ldflags="-s -w -X main.version=${{ needs.release.outputs.version }}" -o "$BINARY_NAME" .
103+
go build -ldflags="-s -w -X main.version=${{ needs.release.outputs.version }}" -o "$BINARY_NAME" ./cmd/github-copilot-svcs
127104
128105
# Make the binary executable (important for Unix systems)
129106
chmod +x "$BINARY_NAME"
@@ -136,11 +113,60 @@ jobs:
136113
ls -la "$GZ_BINARY_NAME"
137114
138115
- name: Upload Release Asset
139-
uses: actions/upload-release-asset@v1
140-
env:
141-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
uses: softprops/action-gh-release@v2
117+
with:
118+
tag_name: ${{ needs.release.outputs.version }}
119+
files: ./github-copilot-svcs-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}.gz
120+
body: |
121+
## Changes in ${{ needs.release.outputs.version }}
122+
123+
Auto-generated release from main branch.
124+
125+
### Downloads
126+
- Linux AMD64: `github-copilot-svcs-linux-amd64.gz`
127+
- Linux ARM64: `github-copilot-svcs-linux-arm64.gz`
128+
- macOS AMD64: `github-copilot-svcs-darwin-amd64.gz`
129+
- macOS ARM64: `github-copilot-svcs-darwin-arm64.gz`
130+
- Windows AMD64: `github-copilot-svcs-windows-amd64.exe.gz`
131+
- Windows ARM64: `github-copilot-svcs-windows-arm64.exe.gz`
132+
133+
docker:
134+
needs: release
135+
runs-on: ubuntu-latest
136+
steps:
137+
- name: Checkout code
138+
uses: actions/checkout@v4
139+
140+
- name: Set up Docker Buildx
141+
uses: docker/setup-buildx-action@v3
142+
143+
- name: Login to GitHub Container Registry
144+
uses: docker/login-action@v3
145+
with:
146+
registry: ghcr.io
147+
username: ${{ github.actor }}
148+
password: ${{ secrets.GITHUB_TOKEN }}
149+
150+
- name: Extract metadata
151+
id: meta
152+
uses: docker/metadata-action@v5
153+
with:
154+
images: ghcr.io/${{ github.repository }}
155+
tags: |
156+
type=semver,pattern={{version}},value=${{ needs.release.outputs.version }}
157+
type=semver,pattern={{major}}.{{minor}},value=${{ needs.release.outputs.version }}
158+
type=semver,pattern={{major}},value=${{ needs.release.outputs.version }}
159+
type=raw,value=latest
160+
161+
- name: Build and push Docker image
162+
uses: docker/build-push-action@v5
142163
with:
143-
upload_url: ${{ needs.release.outputs.upload_url }}
144-
asset_path: ./github-copilot-svcs-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}.gz
145-
asset_name: github-copilot-svcs-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}.gz
146-
asset_content_type: application/gzip
164+
context: .
165+
platforms: linux/amd64,linux/arm64
166+
push: true
167+
tags: ${{ steps.meta.outputs.tags }}
168+
labels: ${{ steps.meta.outputs.labels }}
169+
build-args: |
170+
VERSION=${{ needs.release.outputs.version }}
171+
cache-from: type=gha
172+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)