From b0d97247e154db6a39cbc6841d47ac1f131c07a7 Mon Sep 17 00:00:00 2001 From: Nemu-x Date: Wed, 14 Oct 2026 23:21:59 +0300 Subject: [PATCH 1/4] ci: test the citrus branch on push and pull requests Go 1.26 on Linux and Windows with go vet, the minimum Go 1.20 on Linux, and a race detector run. Replaces the upstream matrix of 30 jobs. --- .github/workflows/ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++ .github/workflows/go.yml | 46 -------------------------------------- 2 files changed, 48 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..a1358005e9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: CI + +on: + push: + branches: [citrus] + pull_request: + branches: [citrus] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +permissions: + contents: read + +jobs: + test: + strategy: + fail-fast: false + matrix: + include: + - { os: ubuntu-latest, go: '1.26' } + - { os: windows-latest, go: '1.26' } + - { os: ubuntu-latest, go: '1.20' } + runs-on: ${{ matrix.os }} + env: + CGO_ENABLED: 0 + GOTOOLCHAIN: local + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-go@v6 + with: + go-version: ${{ matrix.go }} + - name: Vet + if: matrix.go == '1.26' + run: go vet ./... + - name: Test + run: go test -count=1 ./... + + race: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-go@v6 + with: + go-version: '1.26' + - name: Test with the race detector + run: go test -race -count=1 ./... diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index 381bbab17b..0000000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,46 +0,0 @@ -# This workflow will build a golang project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go - -name: "Go" - -on: - push: - pull_request: - -jobs: - build: - strategy: - matrix: - os: - - 'ubuntu-latest' # amd64 linux - - 'windows-latest' # amd64 windows - - 'macos-latest' # arm64 macos - - 'ubuntu-24.04-arm' # arm64 linux - - 'macos-15-intel' # amd64 macos - go-version: - - '1.25' - - '1.24' - - '1.23' - - '1.22' - - '1.21' - - '1.20' - fail-fast: false - runs-on: ${{ matrix.os }} - defaults: - run: - shell: bash - env: - CGO_ENABLED: 0 - GOTOOLCHAIN: local - # Fix mingw trying to be smart and converting paths https://github.com/moby/moby/issues/24029#issuecomment-250412919 - MSYS_NO_PATHCONV: true - steps: - - uses: actions/checkout@v5 - - uses: actions/setup-go@v6 - with: - go-version: ${{ matrix.go-version }} - - run: go version - - name: Build - run: go build -v ./... - - name: Test - run: go test -v ./... From 50ca4c49f5ac5bb6d1303f5de943a595387c1d42 Mon Sep 17 00:00:00 2001 From: Nemu-x Date: Wed, 14 Oct 2026 23:29:07 +0300 Subject: [PATCH 2/4] test: set serial numbers in the resumption trust certificates Go before 1.24 does not generate a serial number when the template has none, so CreateCertificate failed on Go 1.20. --- resumption_trust_test.go | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/resumption_trust_test.go b/resumption_trust_test.go index 4433c4907e..642eb40b2d 100644 --- a/resumption_trust_test.go +++ b/resumption_trust_test.go @@ -11,6 +11,7 @@ import ( "crypto/rand" "crypto/x509" "crypto/x509/pkix" + "math/big" "testing" "time" ) @@ -29,6 +30,7 @@ func testHandshakeChainExpiryResumption(t *testing.T, version uint16) { createChain := func(leafNotAfter, rootNotAfter time.Time) (leafDER, expiredLeafDER []byte, root *x509.Certificate) { tmpl := &x509.Certificate{ + SerialNumber: big.NewInt(1), Subject: pkix.Name{CommonName: "root"}, NotBefore: rootNotAfter.Add(-time.Hour * 24), NotAfter: rootNotAfter, @@ -45,11 +47,12 @@ func testHandshakeChainExpiryResumption(t *testing.T, version uint16) { } tmpl = &x509.Certificate{ - Subject: pkix.Name{}, - DNSNames: []string{"expired-resume.example.com"}, - NotBefore: leafNotAfter.Add(-time.Hour * 24), - NotAfter: leafNotAfter, - KeyUsage: x509.KeyUsageDigitalSignature, + SerialNumber: big.NewInt(2), + Subject: pkix.Name{}, + DNSNames: []string{"expired-resume.example.com"}, + NotBefore: leafNotAfter.Add(-time.Hour * 24), + NotAfter: leafNotAfter, + KeyUsage: x509.KeyUsageDigitalSignature, } leafCertDER, err := x509.CreateCertificate(rand.Reader, tmpl, root, &testECDSAPrivateKey.PublicKey, testECDSAPrivateKey) if err != nil { @@ -148,6 +151,7 @@ func TestHandshakeGetConfigForClientDifferentClientCAs(t *testing.T) { func testHandshakeGetConfigForClientDifferentClientCAs(t *testing.T, version uint16) { now := time.Now() tmpl := &x509.Certificate{ + SerialNumber: big.NewInt(1), Subject: pkix.Name{CommonName: "root"}, NotBefore: now.Add(-time.Hour * 24), NotAfter: now.Add(time.Hour * 24), @@ -172,11 +176,12 @@ func testHandshakeGetConfigForClientDifferentClientCAs(t *testing.T, version uin } tmpl = &x509.Certificate{ - Subject: pkix.Name{}, - DNSNames: []string{"example.com"}, - NotBefore: now.Add(-time.Hour * 24), - NotAfter: now.Add(time.Hour * 24), - KeyUsage: x509.KeyUsageDigitalSignature, + SerialNumber: big.NewInt(2), + Subject: pkix.Name{}, + DNSNames: []string{"example.com"}, + NotBefore: now.Add(-time.Hour * 24), + NotAfter: now.Add(time.Hour * 24), + KeyUsage: x509.KeyUsageDigitalSignature, } certA, err := x509.CreateCertificate(rand.Reader, tmpl, rootA, &testECDSAPrivateKey.PublicKey, testECDSAPrivateKey) if err != nil { @@ -266,6 +271,7 @@ func TestHandshakeChangeRootCAsResumption(t *testing.T) { func testHandshakeChangeRootCAsResumption(t *testing.T, version uint16) { now := time.Now() tmpl := &x509.Certificate{ + SerialNumber: big.NewInt(1), Subject: pkix.Name{CommonName: "root"}, NotBefore: now.Add(-time.Hour * 24), NotAfter: now.Add(time.Hour * 24), @@ -290,11 +296,12 @@ func testHandshakeChangeRootCAsResumption(t *testing.T, version uint16) { } tmpl = &x509.Certificate{ - Subject: pkix.Name{}, - DNSNames: []string{"example.com"}, - NotBefore: now.Add(-time.Hour * 24), - NotAfter: now.Add(time.Hour * 24), - KeyUsage: x509.KeyUsageDigitalSignature, + SerialNumber: big.NewInt(2), + Subject: pkix.Name{}, + DNSNames: []string{"example.com"}, + NotBefore: now.Add(-time.Hour * 24), + NotAfter: now.Add(time.Hour * 24), + KeyUsage: x509.KeyUsageDigitalSignature, } certA, err := x509.CreateCertificate(rand.Reader, tmpl, rootA, &testECDSAPrivateKey.PublicKey, testECDSAPrivateKey) if err != nil { From 42cb40a6bc25120cfd337b473940f82ebedf1dfd Mon Sep 17 00:00:00 2001 From: Nemu-x Date: Wed, 14 Oct 2026 23:29:07 +0300 Subject: [PATCH 3/4] test: report ApplyPreset errors without racing on err The client goroutine in testUtlsHandshake assigned the ApplyPreset result to the named return err, which the test goroutine also writes, and returned without sending on errChan when it failed. --- handshake_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/handshake_test.go b/handshake_test.go index ad6405b907..1b01a8d312 100644 --- a/handshake_test.go +++ b/handshake_test.go @@ -496,7 +496,11 @@ func testUtlsHandshake(t *testing.T, clientConfig, serverConfig *Config, spec *C } if spec != nil { ucli := UClient(c, clientConfig, HelloCustom) - if err = ucli.ApplyPreset(spec); err != nil { + // Do not assign to the outer err: the test goroutine writes it + // concurrently, and returning without a send would block it. + if err := ucli.ApplyPreset(spec); err != nil { + errChan <- fmt.Errorf("client: %v", err) + c.Close() return } cli = ucli From a6af36b78238de30d20e6bfafb6f05e9dc6dc84f Mon Sep 17 00:00:00 2001 From: Nemu-x Date: Wed, 14 Oct 2026 23:29:08 +0300 Subject: [PATCH 4/4] ci: run on main and dev, skip loopclosure in vet, keep LF on Windows --- .github/workflows/ci.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1358005e9..847173a70c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [citrus] + branches: [main, dev] pull_request: - branches: [citrus] + branches: [main, dev] concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -27,13 +27,21 @@ jobs: CGO_ENABLED: 0 GOTOOLCHAIN: local steps: + # Keep testdata byte-exact: autocrlf on Windows runners rewrites LF. + - name: Disable CRLF conversion + if: runner.os == 'Windows' + run: | + git config --global core.autocrlf false + git config --global core.eol lf - uses: actions/checkout@v5 - uses: actions/setup-go@v6 with: go-version: ${{ matrix.go }} + # go.mod says go 1.20, so loopclosure flags upstream Go tests that assume + # per-iteration loop variables; the rest of vet stays on. - name: Vet if: matrix.go == '1.26' - run: go vet ./... + run: go vet -loopclosure=false ./... - name: Test run: go test -count=1 ./...