Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/pr-agent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: PR Agent
on:
pull_request:
types: [opened, reopened, ready_for_review, synchronize]
issue_comment:
types: [created, edited]
jobs:
pr_agent_job:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
contents: write
checks: write
if: ${{ github.event.sender.type != 'Bot' }}
steps:
- name: PR Agent action step
uses: the-pr-agent/pr-agent@570f67ed5fc8db5be74c18df070bc20079b64b0d # v0.41.0
env:
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
OPENAI_API_BASE: ${{ secrets.OPENAI_API_BASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
github_action_config.auto_review: "true"
github_action_config.auto_describe: "true"
github_action_config.auto_improve: "true"
github_action_config.pr_actions: '["opened", "reopened", "ready_for_review", "synchronize"]'
config.model: "openai/preview/Qwen3.6-35B-A3B"
config.custom_model_max_tokens: 32000
35 changes: 35 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: "2"
run:
tests: true
linters:
enable:
- govet
- ineffassign
- staticcheck
- unused
- bodyclose
- gocognit
- dupl
- errcheck
- modernize
- errname
- errorlint
- prealloc

settings:
gocognit:
min-complexity: 15
dupl:
threshold: 100
modernize:
disable:
- plusbuild
errcheck:
exclude-functions:
- fmt.Fprintf
- (io.Closer).Close
- (*os.File).Close
- (*net.TCPConn).Close
- (*net.TCPListener).Close
- (*bytes.Buffer).Write
- (*strings.Builder).WriteString
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
all: check

check:
go test ./...
go test -v ./...

lint:
golangci-lint run ./...
10 changes: 5 additions & 5 deletions selfsigned.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ func TLSConfig(opts ...ConfigOption) (*tls.Config, error) {
// Generate a new private key
privateKey, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader)
if err != nil {
return nil, fmt.Errorf("failed to generate private key: %v", err)
return nil, fmt.Errorf("failed to generate private key: %w", err)
}

// Generate a random serial number
// Generate a random serial number (64 bits, as is common practice)
serial, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 64))
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to generate serial number: %w", err)
}

// Create a self-signed certificate
Expand All @@ -78,13 +78,13 @@ func TLSConfig(opts ...ConfigOption) (*tls.Config, error) {
}
certBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &privateKey.PublicKey, privateKey)
if err != nil {
return nil, fmt.Errorf("failed to create certificate: %v", err)
return nil, fmt.Errorf("failed to create certificate: %w", err)
}

// Encode the private key and certificate to PEM format
derKeyByte, err := x509.MarshalECPrivateKey(privateKey)
if err != nil {
return nil, fmt.Errorf("failed to marshal private key: %v", err)
return nil, fmt.Errorf("failed to marshal private key: %w", err)
}
keyBytes := pem.EncodeToMemory(
&pem.Block{
Expand All @@ -102,7 +102,7 @@ func TLSConfig(opts ...ConfigOption) (*tls.Config, error) {
// Create a TLS certificate
cert, err := tls.X509KeyPair(certBytesPEM, keyBytes)
if err != nil {
return nil, fmt.Errorf("failed to load key pair: %v", err)
return nil, fmt.Errorf("failed to load key pair: %w", err)
}

return &tls.Config{
Expand Down
7 changes: 6 additions & 1 deletion selfsigned_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package selfsigned
import (
"crypto/ecdsa"
"crypto/tls"
"io"
"net"
"net/http"
"testing"
Expand Down Expand Up @@ -47,7 +48,7 @@ func TestTLSConfig_HTTPSServer(t *testing.T) {

mux := http.NewServeMux()
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("ok"))
_, _ = w.Write([]byte("ok"))
})
server := &http.Server{
Handler: mux,
Expand All @@ -69,6 +70,10 @@ func TestTLSConfig_HTTPSServer(t *testing.T) {
}
resp, err := client.Get(baseURL + "/healthz")
assert.NoError(t, err, "unexpected error")
defer func() {
_, _ = io.Copy(io.Discard, resp.Body)
resp.Body.Close()
}()
assert.Equal(t, http.StatusOK, resp.StatusCode, "expected status OK")
assert.NotNil(t, resp.TLS, "expected resp.TLS to be non-nil")
assert.Greater(t, len(resp.TLS.PeerCertificates), 0, "expected at least one peer certificate")
Expand Down