Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
  • Loading branch information
sagikazarmark committed Jan 6, 2025
1 parent 3c7ed50 commit c147060
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 141 deletions.
15 changes: 8 additions & 7 deletions .dagger/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module github.com/twirphp/twirp/.dagger
go 1.23.1

require (
github.com/99designs/gqlgen v0.17.55
github.com/99designs/gqlgen v0.17.57
github.com/Khan/genqlient v0.7.0
github.com/containerd/platforms v0.2.1
github.com/sagikazarmark/dagx v0.1.0
github.com/vektah/gqlparser/v2 v2.5.17
github.com/vektah/gqlparser/v2 v2.5.19
go.opentelemetry.io/otel v1.27.0
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0
Expand All @@ -19,8 +19,8 @@ require (
go.opentelemetry.io/otel/trace v1.27.0
go.opentelemetry.io/proto/otlp v1.3.1
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
golang.org/x/sync v0.8.0
google.golang.org/grpc v1.66.1
golang.org/x/sync v0.10.0
google.golang.org/grpc v1.68.0
)

require (
Expand All @@ -41,17 +41,18 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/sosodev/duration v1.3.1 // indirect
github.com/stretchr/testify v1.10.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0
go.opentelemetry.io/otel/sdk/metric v1.27.0
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
google.golang.org/protobuf v1.35.2 // indirect
)

replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88
Expand Down
34 changes: 18 additions & 16 deletions .dagger/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/99designs/gqlgen v0.17.55 h1:3vzrNWYyzSZjGDFo68e5j9sSauLxfKvLp+6ioRokVtM=
github.com/99designs/gqlgen v0.17.55/go.mod h1:3Bq768f8hgVPGZxL8aY9MaYmbxa6llPM/qu1IGH1EJo=
github.com/99designs/gqlgen v0.17.57 h1:Ak4p60BRq6QibxY0lEc0JnQhDurfhxA67sp02lMjmPc=
github.com/99designs/gqlgen v0.17.57/go.mod h1:Jx61hzOSTcR4VJy/HFIgXiQ5rJ0Ypw8DxWLjbYDAUw0=
github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w=
github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
Expand All @@ -18,6 +18,8 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
Expand Down Expand Up @@ -47,10 +49,10 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/vektah/gqlparser/v2 v2.5.17 h1:9At7WblLV7/36nulgekUgIaqHZWn5hxqluxrxGUhOmI=
github.com/vektah/gqlparser/v2 v2.5.17/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/vektah/gqlparser/v2 v2.5.19 h1:bhCPCX1D4WWzCDvkPl4+TP1N8/kLrWnp43egplt7iSg=
github.com/vektah/gqlparser/v2 v2.5.19/go.mod h1:y7kvl5bBlDeuWIvLtA9849ncyvx6/lj06RsMrEjVy3U=
go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg=
go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 h1:oM0GTNKGlc5qHctWeIGTVyda4iFFalOzMZ3Ehj5rwB4=
Expand Down Expand Up @@ -91,21 +93,21 @@ golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 h1:hjSy6tcFQZ171igDaN5QHOw2n6vx40juYbC/x67CEhc=
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:qpvKtACPCQhAdu3PyQgV4l3LMXZEtft7y8QcarRsp9I=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.66.1 h1:hO5qAXR19+/Z44hmvIM4dQFMSYX9XcWsByfoxutBpAM=
google.golang.org/grpc v1.66.1/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0=
google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA=
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
55 changes: 55 additions & 0 deletions .dagger/lint.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package main

import (
"context"

"github.com/sagikazarmark/dagx/pipeline"
"github.com/twirphp/twirp/.dagger/internal/dagger"
)

// Run linters.
func (m *Twirp) Lint() *Lint {
return &Lint{
Main: m,
}
}

type Lint struct {
// +private
Main *Twirp
}

func (m *Lint) All(ctx context.Context) error {
p := pipeline.New(ctx)

pipeline.AddSyncStep(p, m.Go())
pipeline.AddSyncStep(p, m.Phpstan())
pipeline.AddSyncStep(p, m.PhpCsFixer())

return pipeline.Run(p)
}

func (m *Lint) Go() *dagger.Container {
return dag.GolangciLint(dagger.GolangciLintOpts{
Version: golangciLintVersion,
GoVersion: goVersion, // do not use goBase here for now to avoid parallel jobs overwriting cache volumes
}).
WithLinterCache(cacheVolume("golangci-lint")).
Run(m.Main.Source, dagger.GolangciLintRunOpts{
Verbose: true,
})
}

func (m *Lint) Phpstan() *dagger.Container {
return dag.Phpstan(dagger.PhpstanOpts{
Version: phpstanVersion,
PhpVersion: defaultPhpVersion,
}).Analyse(m.Main.source())
}

func (m *Lint) PhpCsFixer() *dagger.Container {
return dag.PhpCsFixer(dagger.PhpCsFixerOpts{
Version: phpCsFixerVersion,
PhpVersion: defaultPhpVersion,
}).Check(m.Main.source())
}
33 changes: 14 additions & 19 deletions .dagger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ func (m *Twirp) build(platform dagger.Platform, version string) *dagger.File {
platform = m.Platform
}

return dag.Go(dagger.GoOpts{
Version: goVersion,
}).
return goBase().
WithCgoDisabled().
WithSource(m.Source).
Build(dagger.GoWithSourceBuildOpts{
Expand Down Expand Up @@ -125,31 +123,28 @@ func (m *Twirp) generate(source *dagger.Directory) *dagger.Directory {
Directory("generated")
}

func (m *Twirp) Phpstan() *dagger.Container {
source := phpBase(defaultPhpVersion).
func (m *Twirp) source() *dagger.Directory {
return phpBaseDefault().
WithSource(m.Source).
WithComposerInstall().
Source()

return dag.Phpstan(dagger.PhpstanOpts{
Version: phpstanVersion,
PhpVersion: defaultPhpVersion,
}).Analyse(source)
}

func (m *Twirp) PhpCsFixer() *dagger.Container {
source := phpBase(defaultPhpVersion).
WithSource(m.Source).
WithComposerInstall().
Source()
func goBase() *dagger.Go {
return dag.Go(dagger.GoOpts{Version: goVersion}).
WithModuleCache(cacheVolume("go-mod")).
WithBuildCache(cacheVolume("go-build"))
}

return dag.PhpCsFixer(dagger.PhpCsFixerOpts{
Version: phpCsFixerVersion,
PhpVersion: defaultPhpVersion,
}).Check(source)
func phpBaseDefault() *dagger.Php {
return phpBase("")
}

func phpBase(phpVersion string) *dagger.Php {
if phpVersion == "" {
phpVersion = defaultPhpVersion
}

return dag.Php(dagger.PhpOpts{
Version: phpVersion,
}).
Expand Down
5 changes: 5 additions & 0 deletions .dagger/versions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package main

const (
golangciLintVersion = "v1.63.2"
)
8 changes: 5 additions & 3 deletions .dagger/versions_pinned.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package main

const (
goVersion = "1.23.0"
goVersion = "1.23.4"

defaultPhpVersion = "8.3"
composerVersion = "2.2.24"

composerVersion = "2.8.4"

phpstanVersion = "2"
phpCsFixerVersion = "3"

twirpVersion = "v8.1.3"

protobufVersion = "28.3"

alpineBaseImage = "alpine:3.20.3@sha256:beefdbd8a1da6d2915566fde36db9db0b524eb737fc57cd1367effd16dc0d06d"
alpineBaseImage = "alpine:3.21.0@sha256:21dc6063fd678b478f57c0e13f47560d0ea4eeba26dfc947b2a4f81f686b9f45"
)
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permissions:
contents: read

env:
DAGGER_VERSION: 0.14.0
DAGGER_VERSION: 0.15.1

jobs:
test:
Expand Down
67 changes: 17 additions & 50 deletions .github/workflows/static.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
permissions:
contents: read

env:
DAGGER_VERSION: 0.15.1

jobs:
phpstan:
name: PHPStan
Expand All @@ -25,54 +28,18 @@ jobs:
# cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
version: ${{ env.DAGGER_VERSION }}

# php-cs-fixer:
# name: PHP-CS-Fixer
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout repository
# uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
#
# - name: Set up Nix
# uses: cachix/install-nix-action@3715ab1a11cac9e991980d7b4a28d80c7ebdd8f9 # v27
# with:
# extra_nix_config: |
# access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
#
# - name: Set up magic Nix cache
# uses: DeterminateSystems/magic-nix-cache-action@87b14cf437d03d37989d87f0fa5ce4f5dc1a330b # v8
#
# - name: Prepare Nix shell
# run: nix develop --impure .#ci_lowest
#
# - name: Download dependencies
# run: nix develop --impure .#ci_lowest -c composer update --no-interaction --no-progress
#
# - name: Run PHP CS Fixer
# run: nix develop --impure .#ci_lowest -c php-cs-fixer fix --diff --dry-run
php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

# psalm:
# name: Psalm
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout repository
# uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
#
# - name: Set up Nix
# uses: cachix/install-nix-action@3715ab1a11cac9e991980d7b4a28d80c7ebdd8f9 # v27
# with:
# extra_nix_config: |
# access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
#
# - name: Set up magic Nix cache
# uses: DeterminateSystems/magic-nix-cache-action@87b14cf437d03d37989d87f0fa5ce4f5dc1a330b # v8
#
# - name: Prepare Nix shell
# run: nix develop --impure .#ci_lowest
#
# - name: Download dependencies
# run: nix develop --impure .#ci_lowest -c composer update --no-interaction --no-progress
#
# - name: Run Psalm
# run: nix develop --impure .#ci_lowest -c psalm --no-progress --root $PWD --output-format=github
- name: Run pipeline
uses: dagger/dagger-for-github@e5153f5610d82ac9f3f848f3a25ad9d696641068 # v7.0.1
with:
verb: call
args: php-cs-fixer
# cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
version: ${{ env.DAGGER_VERSION }}
4 changes: 4 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
'@Symfony:risky' => true,
'yoda_style' => false,
'modernize_strpos' => false,

// until PHP 8.0
'trailing_comma_in_multiline' => false,
'native_function_invocation' => false,
])
->setFinder(
PhpCsFixer\Finder::create()
Expand Down
13 changes: 9 additions & 4 deletions dagger.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twirp",
"engineVersion": "v0.14.0",
"engineVersion": "v0.15.1",
"sdk": "go",
"exclude": [
".devenv",
Expand All @@ -10,9 +10,9 @@
],
"dependencies": [
{
"name": "php-cs-fixer",
"source": "github.com/sagikazarmark/daggerverse/php-cs-fixer@php-cs-fixer/v0.1.0",
"pin": "84e479601ced57c999880867f0beb56e2afd683d"
"name": "golangci-lint",
"source": "github.com/sagikazarmark/daggerverse/golangci-lint",
"pin": "c1be27189ce47d28f84014b715f78e47db9fbadc"
},
{
"name": "arc",
Expand All @@ -29,6 +29,11 @@
"source": "github.com/sagikazarmark/daggerverse/php@php/v0.2.0",
"pin": "77ecc6dfd82c8d8c1cc37a7f97b719203cfa9cf0"
},
{
"name": "php-cs-fixer",
"source": "github.com/sagikazarmark/daggerverse/php-cs-fixer@php-cs-fixer/v0.1.0",
"pin": "84e479601ced57c999880867f0beb56e2afd683d"
},
{
"name": "phpstan",
"source": "github.com/sagikazarmark/daggerverse/phpstan@phpstan/v0.3.0",
Expand Down
Loading

0 comments on commit c147060

Please sign in to comment.