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
38 changes: 18 additions & 20 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: gzip

on:
push:
branches:
Expand All @@ -9,86 +8,85 @@ on:
branches:
- master
- stable

jobs:
gzip_test:
name: GZIP plugin (Go ${{ matrix.go }}, PHP ${{ matrix.php }}, OS ${{matrix.os}})
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
matrix:
php: [ "8.4" ]
go: [ stable ]
os: [ "ubuntu-latest" ]
php: ["8.5"]
go: [stable]
os: ["ubuntu-latest"]
steps:
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v6 # action page: <https://github.com/actions/setup-go>
with:
go-version: ${{ matrix.go }}

- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2 # action page: <https://github.com/shivammathur/setup-php>
with:
php-version: ${{ matrix.php }}
extensions: sockets

- name: Check out code
uses: actions/checkout@v6

- name: Get Composer Cache Directory
id: composer-cache
run: |
cd tests/php_test_files
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Init Composer Cache # Docs: <https://git.io/JfAKn#php---composer>
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: cd tests/php_test_files && composer update --prefer-dist --no-progress --ansi

- name: Init Go modules Cache # Docs: <https://git.io/JfAKn#go---modules>
uses: actions/cache@v5
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-

- name: Install Go dependencies
run: go mod download

- name: Run golang tests with coverage
run: |
cd tests
mkdir ./coverage-ci

go test -timeout 20m -v -race -cover -tags=debug -failfast -coverpkg=$(cat pkgs.txt) -coverprofile=./coverage-ci/gzip.out -covermode=atomic plugin_test.go

- name: Archive code coverage results
uses: actions/upload-artifact@v6
with:
name: coverage
path: ./tests/coverage-ci/gzip.out

path: ./tests/coverage-ci
codecov:
name: Upload codecov
runs-on: ubuntu-latest
needs:
- gzip_test

timeout-minutes: 60
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Download code coverage results
uses: actions/download-artifact@v7
with:
name: coverage
path: coverage
- run: |
echo 'mode: atomic' > summary.txt
tail -q -n +2 *.out >> summary.txt
sed -i '2,${/roadrunner/!d}' summary.txt

tail -q -n +2 coverage/*.out >> summary.txt
awk '
NR == 1 { print; next }
/^github\.com\/roadrunner-server\/gzip\/v5\// {
sub(/^github\.com\/roadrunner-server\/gzip\/v5\//, "", $0)
print
}
' summary.txt > summary.filtered.txt
mv summary.filtered.txt summary.txt
- name: upload to codecov
uses: codecov/codecov-action@v5 # Docs: <https://github.com/codecov/codecov-action>
with:
Expand Down
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ linters:
for-loops: true
wsl:
allow-assign-and-anything: true
revive:
enable-default-rules: true
rules:
- name: var-naming
disabled: true
Comment on lines +60 to +64
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabling Revive’s default rules can introduce new lint failures and effectively changes the repo’s lint policy. Since the PR description is about gzip-only compression, consider calling this out explicitly (or splitting lint-policy changes into a separate PR) to keep scope clear.

Copilot uses AI. Check for mistakes.
exclusions:
generated: lax
presets:
Expand Down
2 changes: 2 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package gzip provides the RoadRunner Gzip plugin.
package gzip
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/roadrunner-server/gzip/v5

go 1.25

toolchain go1.25.7
go 1.26

require (
github.com/klauspost/compress v1.18.4
Expand Down
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.25
go 1.26
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumping the workspace go version to 1.26 changes the minimum Go toolchain needed to work in this repo (including the ./tests module used in the workspace). Please confirm this is intended and kept consistent with the module go.mod / CI toolchains.

Suggested change
go 1.26
go 1.22

Copilot uses AI. Check for mistakes.

use (
.
Expand Down
19 changes: 18 additions & 1 deletion plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gzip

import (
"net/http"
"sync"

"github.com/klauspost/compress/gzhttp"
rrcontext "github.com/roadrunner-server/context"
Expand All @@ -20,14 +21,30 @@ type Plugin struct {
prop propagation.TextMapPropagator
}

var onceDefault sync.Once //nolint:gochecknoglobals
var defaultWrapper func(http.Handler) http.HandlerFunc //nolint:gochecknoglobals

// GzipHandler allows to easily wrap an http handler with default settings.
func gzipHandler(h http.Handler) http.HandlerFunc {
onceDefault.Do(func() {
var err error
defaultWrapper, err = gzhttp.NewWrapper(gzhttp.PreferZstd(false), gzhttp.EnableZstd(false), gzhttp.EnableGzip(true))
if err != nil {
panic(err)
}
})
Comment on lines +24 to +35
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gzhttp.NewWrapper errors are currently handled via panic, which can crash the whole process at runtime. Consider constructing the wrapper during (*Plugin).Init() (storing it on the Plugin struct) and returning the error from Init, which also avoids the need for global state and //nolint:gochecknoglobals.

Copilot uses AI. Check for mistakes.

return defaultWrapper(h)
}

func (g *Plugin) Init() error {
g.prop = propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{}, jprop.Jaeger{})

return nil
}

func (g *Plugin) Middleware(next http.Handler) http.Handler {
return gzhttp.GzipHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
return gzipHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if val, ok := r.Context().Value(rrcontext.OtelTracerNameKey).(string); ok {
tp := trace.SpanFromContext(r.Context()).TracerProvider()
ctx, span := tp.Tracer(val, trace.WithSchemaURL(semconv.SchemaURL),
Expand Down
2 changes: 2 additions & 0 deletions tests/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package gzip contains integration tests for the RoadRunner Gzip plugin.
package gzip
2 changes: 2 additions & 0 deletions tests/mock/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package mocklogger provides test logger mocks and observed log utilities.
package mocklogger
Loading