chore: publish IntegraCI build modules 732ec6c83925
This commit is contained in:
1 parent
7a84930dea
commit
5f8a24d014
133 files changed
+18990
-2
No files matched your search
@@ -0,0 +1,3 @@
|
||||
/dagger.gen.go linguist-generated
|
||||
/internal/dagger/** linguist-generated
|
||||
/internal/telemetry/** linguist-generated
|
||||
@@ -0,0 +1,4 @@
|
||||
/dagger.gen.go
|
||||
/internal/dagger
|
||||
/internal/telemetry
|
||||
/.env
|
||||
@@ -0,0 +1,50 @@
|
||||
# e2e-test (Dagger module)
|
||||
|
||||
> **Verified 2026-07-16**: dagger v0.21.7 `develop` + `go build` + `dagger
|
||||
> functions` pass. Generated code (`dagger.gen.go`, `internal/`) is
|
||||
> gitignored; run `dagger develop` to regenerate.
|
||||
|
||||
Runs web end-to-end tests (Playwright or Cypress) against a target
|
||||
`baseURL`, uploads the report artifact, and POSTs results to the IntegraCI
|
||||
API. Mirrors the structure and idioms of the `security-scan` module.
|
||||
|
||||
## Functions
|
||||
|
||||
### `run`
|
||||
|
||||
| Param | Required | Default | Description |
|
||||
| ------------ | -------- | -------------------- | --------------------------------------------- |
|
||||
| `source` | yes | — | Source directory containing the e2e suite |
|
||||
| `base-url` | yes | — | Base URL the tests run against |
|
||||
| `tool` | no | `playwright` | Test runner: `playwright` or `cypress` |
|
||||
| `report-path`| no | `playwright-report` | Report artifact path inside the source |
|
||||
| `api-url` | no | — | IntegraCI API URL for posting results |
|
||||
| `token` | no | — | JWT token for API authentication |
|
||||
| `service-id` | no | — | Service ID to link test results |
|
||||
|
||||
Results are POSTed to the API only when `api-url`, `token`, and
|
||||
`service-id` are all supplied.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Playwright (default)
|
||||
dagger call run --source . --base-url https://staging.example.com --tool playwright
|
||||
|
||||
# Cypress, with result posting
|
||||
dagger call run \
|
||||
--source . \
|
||||
--base-url https://staging.example.com \
|
||||
--tool cypress \
|
||||
--api-url http://localhost:8000 \
|
||||
--token "$TOKEN" \
|
||||
--service-id "$SVC_ID"
|
||||
```
|
||||
|
||||
## Before you trust this
|
||||
|
||||
```bash
|
||||
dagger develop # generate the Dagger Go SDK bindings
|
||||
dagger functions # confirm `run` is registered with the expected params
|
||||
dagger call run --source . --base-url https://example.com # smoke test
|
||||
```
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "e2e-test",
|
||||
"engineVersion": "v0.21.7",
|
||||
"sdk": {
|
||||
"source": "go"
|
||||
},
|
||||
"include": [
|
||||
"./main.go"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
module dagger/e-2-e-test
|
||||
|
||||
go 1.26.4
|
||||
|
||||
require (
|
||||
github.com/Khan/genqlient v0.8.1
|
||||
github.com/dagger/otel-go v1.43.0
|
||||
github.com/dagger/querybuilder v0.0.0-20260402040506-574a5e81cb59
|
||||
github.com/vektah/gqlparser/v2 v2.5.32
|
||||
go.opentelemetry.io/otel v1.43.0
|
||||
go.opentelemetry.io/otel/trace v1.43.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/99designs/gqlgen v0.17.89 // indirect
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/go-logr/logr v1.4.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirect
|
||||
github.com/sosodev/duration v1.4.0 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.17.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.17.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.41.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.41.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.41.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.41.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.41.0 // indirect
|
||||
go.opentelemetry.io/otel/log v0.17.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.43.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.43.0
|
||||
go.opentelemetry.io/otel/sdk/log v0.17.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk/metric v1.43.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
|
||||
golang.org/x/net v0.57.0 // indirect
|
||||
golang.org/x/sync v0.22.0 // indirect
|
||||
golang.org/x/sys v0.47.0 // indirect
|
||||
golang.org/x/text v0.40.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260414002931-afd174a4e478 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 // indirect
|
||||
google.golang.org/grpc v1.82.1 // indirect
|
||||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.16.0
|
||||
|
||||
replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.16.0
|
||||
|
||||
replace go.opentelemetry.io/otel/log => go.opentelemetry.io/otel/log v0.16.0
|
||||
|
||||
replace go.opentelemetry.io/otel/sdk/log => go.opentelemetry.io/otel/sdk/log v0.16.0
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
github.com/99designs/gqlgen v0.17.89 h1:KzEcxPiMgQoMw3m/E85atUEHyZyt0PbAflMia5Kw8z8=
|
||||
github.com/99designs/gqlgen v0.17.89/go.mod h1:GFqruTVGB7ZTdrf1uzOagpXbY7DrEt1pIxnTdhIbWvQ=
|
||||
github.com/Khan/genqlient v0.8.1 h1:wtOCc8N9rNynRLXN3k3CnfzheCUNKBcvXmVv5zt6WCs=
|
||||
github.com/Khan/genqlient v0.8.1/go.mod h1:R2G6DzjBvCbhjsEajfRjbWdVglSH/73kSivC9TLWVjU=
|
||||
github.com/agnivade/levenshtein v1.2.1 h1:EHBY3UOn1gwdy/VbFwgo4cxecRznFk7fKWN1KOX7eoM=
|
||||
github.com/agnivade/levenshtein v1.2.1/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU=
|
||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
|
||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
|
||||
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/dagger/otel-go v1.43.0 h1:AYCnAamWmxtSxigWPTgC+8EWqiWPcDZEegh8y05gdJ8=
|
||||
github.com/dagger/otel-go v1.43.0/go.mod h1:83CTuXi70zcx1kaym5buqmb7RNzg1E9dEiQSFyLbLdU=
|
||||
github.com/dagger/querybuilder v0.0.0-20260402040506-574a5e81cb59 h1:g6vfdGRyz6fAjfHz5FyYPZgHy8qcQ31fHrBl1iCOzxw=
|
||||
github.com/dagger/querybuilder v0.0.0-20260402040506-574a5e81cb59/go.mod h1:jsdUJeYzcbyK1j/EqMGPrQgNYxl/Zfg06vvM9C/xXxs=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/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.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 h1:HWRh5R2+9EifMyIHV7ZV+MIZqgz+PMpZ14Jynv3O2Zs=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0/go.mod h1:JfhWUomR1baixubs02l85lZYYOm7LV6om4ceouMv45c=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
|
||||
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
|
||||
github.com/sosodev/duration v1.4.0 h1:35ed0KiVFriGHHzZZJaZLgmTEEICIyt8Sx0RQfj9IjE=
|
||||
github.com/sosodev/duration v1.4.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/vektah/gqlparser/v2 v2.5.32 h1:k9QPJd4sEDTL+qB4ncPLflqTJ3MmjB9SrVzJrawpFSc=
|
||||
github.com/vektah/gqlparser/v2 v2.5.32/go.mod h1:c1I28gSOVNzlfc4WuDlqU7voQnsqI6OG2amkBAFmgts=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||
go.opentelemetry.io/otel v1.43.0 h1:mYIM03dnh5zfN7HautFE4ieIig9amkNANT+xcVxAj9I=
|
||||
go.opentelemetry.io/otel v1.43.0/go.mod h1:JuG+u74mvjvcm8vj8pI5XiHy1zDeoCS2LB1spIq7Ay0=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.16.0 h1:ZVg+kCXxd9LtAaQNKBxAvJ5NpMf7LpvEr4MIZqb0TMQ=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.16.0/go.mod h1:hh0tMeZ75CCXrHd9OXRYxTlCAdxcXioWHFIpYw2rZu8=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.16.0 h1:djrxvDxAe44mJUrKataUbOhCKhR3F8QCyWucO16hTQs=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.16.0/go.mod h1:dt3nxpQEiSoKvfTVxp3TUg5fHPLhKtbcnN3Z1I1ePD0=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.41.0 h1:VO3BL6OZXRQ1yQc8W6EVfJzINeJ35BkiHx4MYfoQf44=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.41.0/go.mod h1:qRDnJ2nv3CQXMK2HUd9K9VtvedsPAce3S+/4LZHjX/s=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.41.0 h1:MMrOAN8H1FrvDyq9UJ4lu5/+ss49Qgfgb7Zpm0m8ABo=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.41.0/go.mod h1:Na+2NNASJtF+uT4NxDe0G+NQb+bUgdPDfwxY/6JmS/c=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.41.0 h1:ao6Oe+wSebTlQ1OEht7jlYTzQKE+pnx/iNywFvTbuuI=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.41.0/go.mod h1:u3T6vz0gh/NVzgDgiwkgLxpsSF6PaPmo2il0apGJbls=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.41.0 h1:mq/Qcf28TWz719lE3/hMB4KkyDuLJIvgJnFGcd0kEUI=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.41.0/go.mod h1:yk5LXEYhsL2htyDNJbEq7fWzNEigeEdV5xBF/Y+kAv0=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.41.0 h1:inYW9ZhgqiDqh6BioM7DVHHzEGVq76Db5897WLGZ5Go=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.41.0/go.mod h1:Izur+Wt8gClgMJqO/cZ8wdeeMryJ/xxiOVgFSSfpDTY=
|
||||
go.opentelemetry.io/otel/log v0.16.0 h1:DeuBPqCi6pQwtCK0pO4fvMB5eBq6sNxEnuTs88pjsN4=
|
||||
go.opentelemetry.io/otel/log v0.16.0/go.mod h1:rWsmqNVTLIA8UnwYVOItjyEZDbKIkMxdQunsIhpUMes=
|
||||
go.opentelemetry.io/otel/metric v1.43.0 h1:d7638QeInOnuwOONPp4JAOGfbCEpYb+K6DVWvdxGzgM=
|
||||
go.opentelemetry.io/otel/metric v1.43.0/go.mod h1:RDnPtIxvqlgO8GRW18W6Z/4P462ldprJtfxHxyKd2PY=
|
||||
go.opentelemetry.io/otel/sdk v1.43.0 h1:pi5mE86i5rTeLXqoF/hhiBtUNcrAGHLKQdhg4h4V9Dg=
|
||||
go.opentelemetry.io/otel/sdk v1.43.0/go.mod h1:P+IkVU3iWukmiit/Yf9AWvpyRDlUeBaRg6Y+C58QHzg=
|
||||
go.opentelemetry.io/otel/sdk/log v0.16.0 h1:e/b4bdlQwC5fnGtG3dlXUrNOnP7c8YLVSpSfEBIkTnI=
|
||||
go.opentelemetry.io/otel/sdk/log v0.16.0/go.mod h1:JKfP3T6ycy7QEuv3Hj8oKDy7KItrEkus8XJE6EoSzw4=
|
||||
go.opentelemetry.io/otel/sdk/log/logtest v0.16.0 h1:/XVkpZ41rVRTP4DfMgYv1nEtNmf65XPPyAdqV90TMy4=
|
||||
go.opentelemetry.io/otel/sdk/log/logtest v0.16.0/go.mod h1:iOOPgQr5MY9oac/F5W86mXdeyWZGleIx3uXO98X2R6Y=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.43.0 h1:S88dyqXjJkuBNLeMcVPRFXpRw2fuwdvfCGLEo89fDkw=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.43.0/go.mod h1:C/RJtwSEJ5hzTiUz5pXF1kILHStzb9zFlIEe85bhj6A=
|
||||
go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09nk+3A=
|
||||
go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0=
|
||||
go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A=
|
||||
go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
|
||||
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
|
||||
golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
|
||||
golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
|
||||
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
||||
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
||||
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
|
||||
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
||||
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
|
||||
golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
|
||||
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
|
||||
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
|
||||
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
|
||||
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
|
||||
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260226221140-a57be14db171 h1:tu/dtnW1o3wfaxCOjSLn5IRX4YDcJrtlpzYkhHhGaC4=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260226221140-a57be14db171/go.mod h1:M5krXqk4GhBKvB596udGL3UyjL4I1+cTbK0orROM9ng=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260414002931-afd174a4e478 h1:yQugLulqltosq0B/f8l4w9VryjV+N/5gcW0jQ3N8Qec=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260414002931-afd174a4e478/go.mod h1:C6ADNqOxbgdUUeRTU+LCHDPB9ttAMCTff6auwCVa4uc=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260226221140-a57be14db171 h1:ggcbiqK8WWh6l1dnltU4BgWGIGo+EVYxCaAPih/zQXQ=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260226221140-a57be14db171/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 h1:RmoJA1ujG+/lRGNfUnOMfhCy5EipVMyvUE+KNbPbTlw=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||
google.golang.org/grpc v1.79.3 h1:sybAEdRIEtvcD68Gx7dmnwjZKlyfuc61Dyo9pGXXkKE=
|
||||
google.golang.org/grpc v1.79.3/go.mod h1:KmT0Kjez+0dde/v2j9vzwoAScgEPx/Bw1CYChhHLrHQ=
|
||||
google.golang.org/grpc v1.82.1 h1:NnAxzGRA0677vCa4BUkOAnO5+FfQqVl9iUXeD0IqcGE=
|
||||
google.golang.org/grpc v1.82.1/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA=
|
||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
@@ -0,0 +1,240 @@
|
||||
// Verified 2026-07-16: dagger v0.21.7 develop + go build + dagger functions
|
||||
// pass. Generated code (dagger.gen.go, internal/) is gitignored; run
|
||||
// 'dagger develop' to regenerate.
|
||||
//
|
||||
// Package main implements the IntegraCI e2e-test Dagger module.
|
||||
//
|
||||
// Runs web end-to-end tests (Playwright or Cypress) against a target
|
||||
// baseURL, uploads the report artifact, and POSTs results to the
|
||||
// IntegraCI API.
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// dagger call run --source . --base-url https://staging.example.com --tool playwright
|
||||
// dagger call run --source . --base-url https://staging.example.com --tool cypress --api-url http://localhost:8000 --token $TOKEN --service-id $SVC_ID
|
||||
// dagger call run --source . --base-url https://staging.example.com --tool selenium --command "pytest -m e2e"
|
||||
// dagger call run --source . --base-url https://staging.example.com --tool none
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"dagger/e-2-e-test/internal/dagger"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// E2eTest is the IntegraCI web end-to-end testing module.
|
||||
type E2eTest struct{}
|
||||
|
||||
// E2EResult contains the output of an end-to-end test run.
|
||||
type E2EResult struct {
|
||||
Tool string `json:"tool"`
|
||||
BaseURL string `json:"base_url"`
|
||||
ExitCode int `json:"exit_code"`
|
||||
Output string `json:"output"`
|
||||
ReportPath string `json:"report_path,omitempty"`
|
||||
ReportSize int `json:"report_size"`
|
||||
Posted bool `json:"posted"`
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
|
||||
// Run executes a web end-to-end test suite against baseURL using either
|
||||
// Playwright (default) or Cypress, uploads the report artifact, and
|
||||
// optionally POSTs the results to the IntegraCI API.
|
||||
func (m *E2eTest) Run(
|
||||
ctx context.Context,
|
||||
// Source directory containing the e2e test suite
|
||||
source *dagger.Directory,
|
||||
// Base URL the tests run against
|
||||
baseURL string,
|
||||
// Test runner to use: "playwright" | "cypress" | "selenium" | "none"
|
||||
// +optional
|
||||
// +default="playwright"
|
||||
tool string,
|
||||
// Command to run for the selenium tool (engine-agnostic; no official action)
|
||||
// +optional
|
||||
// +default="pytest -m e2e"
|
||||
command string,
|
||||
// Path inside the source the report artifact is written to
|
||||
// +optional
|
||||
// +default="playwright-report"
|
||||
reportPath string,
|
||||
// IntegraCI API URL for posting results
|
||||
// +optional
|
||||
apiURL string,
|
||||
// JWT token for API authentication
|
||||
// +optional
|
||||
token *dagger.Secret,
|
||||
// Service ID to link test results
|
||||
// +optional
|
||||
serviceID string,
|
||||
) (*E2EResult, error) {
|
||||
result := &E2EResult{
|
||||
Tool: tool,
|
||||
BaseURL: baseURL,
|
||||
ReportPath: reportPath,
|
||||
}
|
||||
|
||||
var (
|
||||
output string
|
||||
report string
|
||||
err error
|
||||
)
|
||||
|
||||
switch strings.ToLower(strings.TrimSpace(tool)) {
|
||||
case "none":
|
||||
// No-op skip, mirroring the adapter's _comment_skip intent.
|
||||
result.Tool = "none"
|
||||
result.Output = "Web E2E disabled (tool=none)"
|
||||
result.Success = true
|
||||
return result, nil
|
||||
case "cypress":
|
||||
output, report, err = m.runCypress(ctx, source, baseURL, reportPath)
|
||||
case "selenium":
|
||||
output, report, err = m.runSelenium(ctx, source, baseURL, command)
|
||||
case "", "playwright":
|
||||
result.Tool = "playwright"
|
||||
output, report, err = m.runPlaywright(ctx, source, baseURL, reportPath)
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported tool %q: use \"playwright\", \"cypress\", \"selenium\" or \"none\"", tool)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s run failed: %w", result.Tool, err)
|
||||
}
|
||||
|
||||
result.Output = output
|
||||
result.ReportSize = len(report)
|
||||
result.Success = true
|
||||
|
||||
// POST results to the IntegraCI API when API params are supplied.
|
||||
if apiURL != "" && token != nil && serviceID != "" {
|
||||
if err := m.postResults(ctx, apiURL, token, serviceID, result); err != nil {
|
||||
return result, fmt.Errorf("post results: %w", err)
|
||||
}
|
||||
result.Posted = true
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// runPlaywright installs Playwright browsers and runs the suite against
|
||||
// baseURL, then reads the report artifact back out of the container.
|
||||
func (m *E2eTest) runPlaywright(
|
||||
ctx context.Context,
|
||||
source *dagger.Directory,
|
||||
baseURL string,
|
||||
reportPath string,
|
||||
) (string, string, error) {
|
||||
runner := dag.Container().
|
||||
From("mcr.microsoft.com/playwright:v1.44.0-jammy").
|
||||
WithMountedDirectory("/src", source).
|
||||
WithWorkdir("/src").
|
||||
WithEnvVariable("BASE_URL", baseURL).
|
||||
WithExec([]string{"npm", "ci"}).
|
||||
WithExec([]string{"npx", "playwright", "install", "--with-deps"}).
|
||||
WithExec([]string{"npx", "playwright", "test"})
|
||||
|
||||
output, err := runner.Stdout(ctx)
|
||||
if err != nil {
|
||||
return output, "", fmt.Errorf("playwright test: %w", err)
|
||||
}
|
||||
|
||||
report, rerr := runner.File("/src/" + reportPath + "/index.html").Contents(ctx)
|
||||
if rerr != nil {
|
||||
// Report artifact is best-effort; absence is not fatal.
|
||||
report = ""
|
||||
}
|
||||
|
||||
return output, report, nil
|
||||
}
|
||||
|
||||
// runCypress installs dependencies and runs the Cypress suite against
|
||||
// baseURL, then reads the report artifact back out of the container.
|
||||
func (m *E2eTest) runCypress(
|
||||
ctx context.Context,
|
||||
source *dagger.Directory,
|
||||
baseURL string,
|
||||
reportPath string,
|
||||
) (string, string, error) {
|
||||
runner := dag.Container().
|
||||
From("cypress/included:13.11.0").
|
||||
WithMountedDirectory("/src", source).
|
||||
WithWorkdir("/src").
|
||||
WithEnvVariable("CYPRESS_BASE_URL", baseURL).
|
||||
WithExec([]string{"npm", "ci"}).
|
||||
WithExec([]string{"cypress", "run", "--config", "baseUrl=" + baseURL})
|
||||
|
||||
output, err := runner.Stdout(ctx)
|
||||
if err != nil {
|
||||
return output, "", fmt.Errorf("cypress run: %w", err)
|
||||
}
|
||||
|
||||
report, rerr := runner.File("/src/" + reportPath).Contents(ctx)
|
||||
if rerr != nil {
|
||||
report = ""
|
||||
}
|
||||
|
||||
return output, report, nil
|
||||
}
|
||||
|
||||
// runSelenium runs a configurable test command (default "pytest -m e2e")
|
||||
// against baseURL. Selenium has no official CI action, so the canonical
|
||||
// recipe is to run the project's own command inside a Python image with a
|
||||
// Selenium runtime. The baseURL is exposed via BASE_URL for the suite.
|
||||
func (m *E2eTest) runSelenium(
|
||||
ctx context.Context,
|
||||
source *dagger.Directory,
|
||||
baseURL string,
|
||||
command string,
|
||||
) (string, string, error) {
|
||||
cmd := strings.TrimSpace(command)
|
||||
if cmd == "" {
|
||||
cmd = "pytest -m e2e"
|
||||
}
|
||||
|
||||
output, err := dag.Container().
|
||||
From("python:3.12-slim").
|
||||
WithMountedDirectory("/src", source).
|
||||
WithWorkdir("/src").
|
||||
WithEnvVariable("BASE_URL", baseURL).
|
||||
WithExec([]string{"sh", "-c", cmd}).
|
||||
Stdout(ctx)
|
||||
if err != nil {
|
||||
return output, "", fmt.Errorf("selenium command: %w", err)
|
||||
}
|
||||
|
||||
return output, "", nil
|
||||
}
|
||||
|
||||
// postResults POSTs the E2E result summary to the IntegraCI API. Mirrors
|
||||
// the security-scan post-to-API pattern: a small curl invocation inside a
|
||||
// throwaway container so no host network access is required.
|
||||
func (m *E2eTest) postResults(
|
||||
ctx context.Context,
|
||||
apiURL string,
|
||||
token *dagger.Secret,
|
||||
serviceID string,
|
||||
result *E2EResult,
|
||||
) error {
|
||||
payload := fmt.Sprintf(
|
||||
`{"service_id":%q,"tool":%q,"base_url":%q,"success":%t,"report_size":%d}`,
|
||||
serviceID, result.Tool, result.BaseURL, result.Success, result.ReportSize,
|
||||
)
|
||||
|
||||
_, err := dag.Container().
|
||||
From("curlimages/curl:8.10.1").
|
||||
WithSecretVariable("API_TOKEN", token).
|
||||
WithExec([]string{
|
||||
"sh", "-c",
|
||||
"curl -sS -X POST " +
|
||||
"-H \"Authorization: Bearer $API_TOKEN\" " +
|
||||
"-H \"Content-Type: application/json\" " +
|
||||
"-d '" + payload + "' " +
|
||||
strings.TrimRight(apiURL, "/") + "/api/v1/e2e-results",
|
||||
}).
|
||||
Stdout(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("curl post: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user