From 49eac69c6d790dc21e04534af9913cbc40a77c44 Mon Sep 17 00:00:00 2001 From: Daniel Strebel Date: Wed, 3 Jan 2024 13:54:37 +0100 Subject: [PATCH 1/9] feat: add info endpoint for data as json format --- hello.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hello.go b/hello.go index 5bad02d..56874f8 100644 --- a/hello.go +++ b/hello.go @@ -173,6 +173,13 @@ func main() { tmpl.Execute(w, data) }) + http.HandleFunc("/info", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + encoder := json.NewEncoder(w) + encoder.SetIndent("", " ") + encoder.Encode(data) + }) + http.HandleFunc("/robots.txt", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "User-agent: *\nDisallow: /\n") }) From 39263f53b5d4e86c1ec8686ca9e774acaef4d2a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Mar 2024 12:20:26 -0700 Subject: [PATCH 2/9] Bump github.com/cloudevents/sdk-go/v2 from 2.3.1 to 2.15.2 (#84) Bumps [github.com/cloudevents/sdk-go/v2](https://github.com/cloudevents/sdk-go) from 2.3.1 to 2.15.2. - [Release notes](https://github.com/cloudevents/sdk-go/releases) - [Commits](https://github.com/cloudevents/sdk-go/compare/v2.3.1...v2.15.2) --- updated-dependencies: - dependency-name: github.com/cloudevents/sdk-go/v2 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 94 ++++++++++++++++++---------------------------------------- 2 files changed, 30 insertions(+), 66 deletions(-) diff --git a/go.mod b/go.mod index cfe274b..945f913 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module github.com/googlecloudplatform/cloud-run-hello go 1.14 -require github.com/cloudevents/sdk-go/v2 v2.3.1 // indirect +require github.com/cloudevents/sdk-go/v2 v2.15.2 diff --git a/go.sum b/go.sum index 8a03290..bda6282 100644 --- a/go.sum +++ b/go.sum @@ -1,88 +1,52 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudevents/sdk-go v1.2.0 h1:2AxI14EJUw1PclJ5gZJtzbxnHIfNMdi76Qq3P3G1BRU= -github.com/cloudevents/sdk-go/v2 v2.3.1 h1:QRTu0yRA4FbznjRSds0/4Hy6cVYpWV2wInlNJSHWAtw= -github.com/cloudevents/sdk-go/v2 v2.3.1/go.mod h1:4fO2UjPMYYR1/7KPJQCwTPb0lFA8zYuitkUpAZFSY1Q= +github.com/cloudevents/sdk-go/v2 v2.15.2 h1:54+I5xQEnI73RBhWHxbI1XJcqOFOVJN85vb41+8mHUc= +github.com/cloudevents/sdk-go/v2 v2.15.2/go.mod h1:lL7kSWAE/V8VI4Wh0jbL2v/jvqsm6tjmaQBSvxcv4uE= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8Bppgk= -github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/lightstep/tracecontext.go v0.0.0-20181129014701-1757c391b1ac h1:+2b6iGRJe3hvV/yVXrd41yVEjxuFHxasJqDhkIjS4gk= -github.com/lightstep/tracecontext.go v0.0.0-20181129014701-1757c391b1ac/go.mod h1:Frd2bnT3w5FB5q49ENTfVlztJES+1k/7lyWX2+9gq/M= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs= +golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From a59ee84202f1d642aa2e1f31c1f561fce2851730 Mon Sep 17 00:00:00 2001 From: Adam Ross Date: Fri, 15 Mar 2024 14:53:08 -0700 Subject: [PATCH 3/9] ci: new jobs image publishing configuration (#85) --- testing/README.md | 12 ++----- testing/jobs.merge.cloudbuild.yaml | 6 ++++ testing/jobs.publish.cloudbuild.yaml | 47 ++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 testing/jobs.publish.cloudbuild.yaml diff --git a/testing/README.md b/testing/README.md index 17407b3..2909404 100644 --- a/testing/README.md +++ b/testing/README.md @@ -4,7 +4,7 @@ A Google Cloud Project is required in order to run the tests in the Cloud Run Sa * Cloud Run * Cloud Build -* Container Registry +* Artifact Registry ## Test Project Setup @@ -20,13 +20,13 @@ A Google Cloud Project is required in order to run the tests in the Cloud Run Sa Each sample has Cloud Build triggers: * A **Pull Request trigger** which checks incoming changes. -* A **Merge trigger** which builds and pushes new container images. +* A **Publish trigger** which builds and pushes new container images. * A **Nightly trigger** which checks the affects of product changes, environment changes, and flakiness. The trigger configs are defined in `testing/triggers` and can be imported via: ```sh -gcloud beta builds triggers import --source=testing/triggers/jobs..yaml +gcloud builds triggers import --source=testing/triggers/jobs..yaml ``` ## Manually Start Cloud Builds @@ -38,9 +38,3 @@ gcloud builds submit \ --config "testing/$SAMPLE.pr.cloudbuild.yaml" \ --substitutions "SHORT_SHA=manual" ``` - -## Manually Provide Pack CLI Cloud Builders - -Follow [instructions][pack] for creating your own Cloud Builder with the `pack` CLI. - -[pack]: https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/pack \ No newline at end of file diff --git a/testing/jobs.merge.cloudbuild.yaml b/testing/jobs.merge.cloudbuild.yaml index 7904847..9601e33 100644 --- a/testing/jobs.merge.cloudbuild.yaml +++ b/testing/jobs.merge.cloudbuild.yaml @@ -12,6 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. + +# +# This configuration is deprecated by job/publish.cloudbuild.yaml. +# It is retained for cutover purposes and will be deleted. +# + steps: - id: 'Build Container Image' diff --git a/testing/jobs.publish.cloudbuild.yaml b/testing/jobs.publish.cloudbuild.yaml new file mode 100644 index 0000000..dd192e9 --- /dev/null +++ b/testing/jobs.publish.cloudbuild.yaml @@ -0,0 +1,47 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Publishes the hello-job sample image to Artifact Registry. +steps: + +# Build the image once. +- id: 'Build Container Image' + name: 'gcr.io/k8s-skaffold/pack:latest' + dir: 'job/' + script: | + pack build --builder "gcr.io/buildpacks/builder:google-22" "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest" + +# Support commonly used variants of the image tag. +- id: 'Tag Container Image Aliases' + name: 'gcr.io/cloud-builders/docker:latest' + script: | + docker tag "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest" "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE_ALIAS}:latest" + docker tag "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest" "gcr.io/${PROJECT_ID}/${_IMAGE_ALIAS}:latest" + +images: + # Push image with Cloud Build context. + - "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest" + - "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE_ALIAS}:latest" + - "gcr.io/${PROJECT_ID}/${_IMAGE_ALIAS}:latest" + +substitutions: + _IMAGE: hello-job + _IMAGE_ALIAS: job + _LOCATION: us + _REPO: container + +options: + # Automatically make substitutions available as environment variables to scripts. + # https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values#mapping_substitutions_to_environment_variables + automapSubstitutions: true From dee465e702e6887b9b7fd1e8a456e193ce404331 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 10:32:54 -0700 Subject: [PATCH 4/9] Bump golang from 1.21 to 1.22 (#82) Bumps golang from 1.21 to 1.22. --- updated-dependencies: - dependency-name: golang dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Adam Ross --- Dockerfile | 2 +- placeholder.dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index fa2a51f..bd7e579 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Use the official Golang image to create a build artifact. # This is based on Debian and sets the GOPATH to /go. # https://hub.docker.com/_/golang -FROM golang:1.21 as builder +FROM golang:1.22 as builder # Create and change to the app directory. WORKDIR /app # Retrieve application dependencies using go modules. diff --git a/placeholder.dockerfile b/placeholder.dockerfile index 5e0e558..9e5ae9f 100644 --- a/placeholder.dockerfile +++ b/placeholder.dockerfile @@ -1,7 +1,7 @@ # Use the official Golang image to create a build artifact. # This is based on Debian and sets the GOPATH to /go. # https://hub.docker.com/_/golang -FROM golang:1.21 as builder +FROM golang:1.22 as builder # Create and change to the app directory. WORKDIR /app # Retrieve application dependencies using go modules. From f96aee6d35290a38830822c49c11df2c6c0cab30 Mon Sep 17 00:00:00 2001 From: Adam Ross Date: Fri, 19 Apr 2024 14:56:23 -0700 Subject: [PATCH 5/9] feat(jobs): complete migration to new jobs pipeline (#86) --- testing/README.md | 17 +++++++---- testing/jobs.merge.cloudbuild.yaml | 48 ------------------------------ testing/triggers/jobs.merge.yaml | 9 ------ testing/triggers/jobs.nightly.yaml | 9 +++++- testing/triggers/jobs.pr.yaml | 13 ++++++-- testing/triggers/jobs.publish.yaml | 17 +++++++++++ 6 files changed, 47 insertions(+), 66 deletions(-) delete mode 100644 testing/jobs.merge.cloudbuild.yaml delete mode 100644 testing/triggers/jobs.merge.yaml create mode 100644 testing/triggers/jobs.publish.yaml diff --git a/testing/README.md b/testing/README.md index 2909404..4282627 100644 --- a/testing/README.md +++ b/testing/README.md @@ -1,6 +1,6 @@ # Testing for Cloud Run Samples -A Google Cloud Project is required in order to run the tests in the Cloud Run Samples. The project should have the following API's enabled: +A Google Cloud Project is required in order to run the tests in the Cloud Run Samples. The project should have the following APIs enabled: * Cloud Run * Cloud Build @@ -19,14 +19,21 @@ A Google Cloud Project is required in order to run the tests in the Cloud Run Sa Each sample has Cloud Build triggers: -* A **Pull Request trigger** which checks incoming changes. -* A **Publish trigger** which builds and pushes new container images. -* A **Nightly trigger** which checks the affects of product changes, environment changes, and flakiness. +* A **Pull Request trigger** [pr] which checks incoming changes. +* A **Publish trigger** [publish] which builds and pushes new container images. +* A **Nightly trigger** [nightly] which checks the affects of product changes, environment changes, and flakiness. The trigger configs are defined in `testing/triggers` and can be imported via: ```sh -gcloud builds triggers import --source=testing/triggers/jobs..yaml +gcloud builds triggers import --source testing/triggers/jobs.{TYPE}.yaml +``` + +These triggers are created or updated via: + +```sh +gcloud beta builds triggers export jobs-{TYPE} \ + --destination testing/triggers/jobs.{TYPE}.yaml ``` ## Manually Start Cloud Builds diff --git a/testing/jobs.merge.cloudbuild.yaml b/testing/jobs.merge.cloudbuild.yaml deleted file mode 100644 index 9601e33..0000000 --- a/testing/jobs.merge.cloudbuild.yaml +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# -# This configuration is deprecated by job/publish.cloudbuild.yaml. -# It is retained for cutover purposes and will be deleted. -# - -steps: - -- id: 'Build Container Image' - name: 'gcr.io/${PROJECT_ID}/pack:latest' - dir: 'job/' - args: ['build', '--builder', 'gcr.io/buildpacks/builder:google-22', 'gcr.io/${PROJECT_ID}/${_IMAGE}:latest'] - -- id: 'Push Container Image to Container Registry' - name: 'gcr.io/cloud-builders/docker:latest' - args: ['push', 'gcr.io/${PROJECT_ID}/${_IMAGE}:latest'] - -- id: 'Tag Container Image for Artifact Registry' - name: 'gcr.io/cloud-builders/docker:latest' - args: ['tag', 'gcr.io/${PROJECT_ID}/${_IMAGE}:latest', '${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest'] - -- id: 'Push Container Image to Artifact Registry' - name: 'gcr.io/cloud-builders/docker:latest' - args: ['push', '${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest'] - -substitutions: - _IMAGE: job - _LOCATION: us - _REPO: container - _CLOUDSDK_VERSION: latest - -images: - - 'gcr.io/${PROJECT_ID}/${_IMAGE}:latest' - - '${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest' \ No newline at end of file diff --git a/testing/triggers/jobs.merge.yaml b/testing/triggers/jobs.merge.yaml deleted file mode 100644 index 77e7548..0000000 --- a/testing/triggers/jobs.merge.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: jobs-merge -filename: testing/jobs.merge.cloudbuild.yaml -github: - name: cloud-run-hello - owner: GoogleCloudPlatform - push: - branch: ^master$ -includedFiles: -- jobs/** diff --git a/testing/triggers/jobs.nightly.yaml b/testing/triggers/jobs.nightly.yaml index 0eb171c..d11ac5e 100644 --- a/testing/triggers/jobs.nightly.yaml +++ b/testing/triggers/jobs.nightly.yaml @@ -1,10 +1,17 @@ -name: jobs-nightly +createTime: '2022-04-15T19:44:48.397816366Z' +description: 'Job: End-to-end test of the latest build on a schedule' gitFileSource: path: testing/jobs.nightly.cloudbuild.yaml repoType: GITHUB revision: refs/heads/master uri: https://github.com/GoogleCloudPlatform/cloud-run-hello +id: 2b0a42a5-60ea-4758-af7e-4511228bf68f +name: jobs-nightly +resourceName: projects/cloudrun/locations/global/triggers/2b0a42a5-60ea-4758-af7e-4511228bf68f sourceToBuild: ref: refs/heads/master repoType: GITHUB uri: https://github.com/GoogleCloudPlatform/cloud-run-hello +tags: +- image:job +- type:testing diff --git a/testing/triggers/jobs.pr.yaml b/testing/triggers/jobs.pr.yaml index 2f335de..e79708f 100644 --- a/testing/triggers/jobs.pr.yaml +++ b/testing/triggers/jobs.pr.yaml @@ -1,11 +1,18 @@ -name: jobs-pr -description: "Build and deploy a test job" +createTime: '2022-04-15T00:03:19.350111928Z' +description: 'Job: Build, Unit Test, and E2E Test on Pull Request' filename: testing/jobs.pr.cloudbuild.yaml github: name: cloud-run-hello owner: GoogleCloudPlatform pullRequest: - branch: ^master$ + branch: master commentControl: COMMENTS_ENABLED_FOR_EXTERNAL_CONTRIBUTORS_ONLY +id: 8a2892ff-c44d-4178-85a4-4248d97f1d71 includedFiles: - jobs/** +- testing/jobs.pr.cloudbuild.yaml +name: jobs-pr +resourceName: projects/cloudrun/locations/global/triggers/8a2892ff-c44d-4178-85a4-4248d97f1d71 +tags: +- image:job +- type:testing diff --git a/testing/triggers/jobs.publish.yaml b/testing/triggers/jobs.publish.yaml new file mode 100644 index 0000000..8d86f70 --- /dev/null +++ b/testing/triggers/jobs.publish.yaml @@ -0,0 +1,17 @@ +createTime: '2024-03-18T19:58:54.437111051Z' +description: 'Job: Build and push container image to GCR and GAR' +gitFileSource: + path: testing/jobs.publish.cloudbuild.yaml + repoType: GITHUB + revision: refs/heads/master + uri: https://github.com/GoogleCloudPlatform/cloud-run-hello +id: 234c41f5-9714-4617-b513-2db8686b71d2 +name: jobs-publish +resourceName: projects/cloudrun/locations/global/triggers/234c41f5-9714-4617-b513-2db8686b71d2 +sourceToBuild: + ref: refs/heads/master + repoType: GITHUB + uri: https://github.com/GoogleCloudPlatform/cloud-run-hello +tags: +- image:job +- type:publish From a6d66eed2e3b951d8c6030af4fb35ef956bfd691 Mon Sep 17 00:00:00 2001 From: Adam Ross Date: Fri, 19 Apr 2024 15:08:51 -0700 Subject: [PATCH 6/9] docs: update README structure and include hello-job (#88) * docs: update README struct and include hello-job * Update README.md: Clarify source code not containers in repo --- README.md | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a1e1a41..0f4724b 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,28 @@ -# Cloud Run "Hello" container +# Cloud Run "Hello" container source code -This repository contains the source code of a sample Go application that is -distributed as the public container image (`us-docker.pkg.dev/cloudrun/container/hello`) used in the -[Cloud Run quickstart](https://cloud.google.com/run/docs/quickstarts/deploy-container) and as -the suggested container image in the Cloud Run UI on Cloud Console. +This repository contains the source code of multiple sample applications. -It also contains the source code of a placeholder public container -(`us-docker.pkg.dev/cloudrun/container/placeholder`) used to create a placeholder revision when setting up -[Continuous Deployment](https://cloud.google.com/run/docs/continuous-deployment-with-cloud-build). +## Hello service -Set a `COLOR` environment variable to a valid CSS color to change the background color. +A sample service implemented in Go and distributed as a public container image. It is used in the [Cloud Run quickstart](https://cloud.google.com/run/docs/quickstarts/deploy-container) and is a suggested container image in the Cloud Run UI on Cloud Console. -[![Run on Google Cloud](https://deploy.cloud.run/button.svg)](https://deploy.cloud.run) +* **Container Image:** `us-docker.pkg.dev/cloudrun/container/hello` + +### Configuration Options + +Set the `COLOR` environment variable to a valid CSS color to change the background color. + +Run on Google Cloud + +## Hello job + +A sample job implemented in Go and distributed as a public container image. It is used in the [Cloud Run quickstart](https://cloud.google.com/run/docs/quickstarts/jobs/create-execute) and is a suggested container image in the Cloud Run UI on Cloud Console. + +* **Container Image:** `us-docker.pkg.dev/cloudrun/container/hello-job` +* **Source Code:** [job/](job/) + +## Placeholder service + +A sample service implemented in Go and distributed as a public container image. It is used to create a placeholder revision when setting up [Continuous Deployment](https://cloud.google.com/run/docs/continuous-deployment-with-cloud-build). + +* **Container Image:** `us-docker.pkg.dev/cloudrun/container/placeholder` From 87000d923047332df1b5d8abda112654f85ffa60 Mon Sep 17 00:00:00 2001 From: Adam Ross Date: Fri, 19 Apr 2024 15:45:02 -0700 Subject: [PATCH 7/9] feat(ci): Add image build and publish configs for sample services (#89) --- testing/jobs.publish.cloudbuild.yaml | 4 +- testing/placeholder.publish.cloudbuild.yaml | 47 +++++++++++++++++++++ testing/service.publish.cloudbuild.yaml | 45 ++++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 testing/placeholder.publish.cloudbuild.yaml create mode 100644 testing/service.publish.cloudbuild.yaml diff --git a/testing/jobs.publish.cloudbuild.yaml b/testing/jobs.publish.cloudbuild.yaml index dd192e9..7069c2c 100644 --- a/testing/jobs.publish.cloudbuild.yaml +++ b/testing/jobs.publish.cloudbuild.yaml @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Publishes the hello-job sample image to Artifact Registry. +# Publishes the Hello job sample image to Artifact Registry. steps: # Build the image once. @@ -20,12 +20,14 @@ steps: name: 'gcr.io/k8s-skaffold/pack:latest' dir: 'job/' script: | + set -x pack build --builder "gcr.io/buildpacks/builder:google-22" "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest" # Support commonly used variants of the image tag. - id: 'Tag Container Image Aliases' name: 'gcr.io/cloud-builders/docker:latest' script: | + set -x docker tag "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest" "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE_ALIAS}:latest" docker tag "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest" "gcr.io/${PROJECT_ID}/${_IMAGE_ALIAS}:latest" diff --git a/testing/placeholder.publish.cloudbuild.yaml b/testing/placeholder.publish.cloudbuild.yaml new file mode 100644 index 0000000..d0baaa4 --- /dev/null +++ b/testing/placeholder.publish.cloudbuild.yaml @@ -0,0 +1,47 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Publishes the Placeholder service sample image to Artifact Registry. +steps: + +# Build the image once. +- id: 'Build Container Image' + name: 'gcr.io/cloud-builders/docker:latest' + script: | + set -x + docker build . \ + -t "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest" \ + -f placeholder.Dockerfile + +# Support commonly used variants of the image tag. +- id: 'Tag Container Image Aliases' + name: 'gcr.io/cloud-builders/docker:latest' + script: | + set -x + docker tag "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest" "gcr.io/${PROJECT_ID}/${_IMAGE}:latest" + +images: + # Push image with Cloud Build context. + - "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest" + - "gcr.io/${PROJECT_ID}/${_IMAGE}:latest" + +substitutions: + _IMAGE: placeholder + _LOCATION: us + _REPO: container + +options: + # Automatically make substitutions available as environment variables to scripts. + # https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values#mapping_substitutions_to_environment_variables + automapSubstitutions: true diff --git a/testing/service.publish.cloudbuild.yaml b/testing/service.publish.cloudbuild.yaml new file mode 100644 index 0000000..d369feb --- /dev/null +++ b/testing/service.publish.cloudbuild.yaml @@ -0,0 +1,45 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Publishes the Hello service sample image to Artifact Registry. +steps: + +# Build the image once. +- id: 'Build Container Image' + name: 'gcr.io/cloud-builders/docker:latest' + script: | + set -x + docker build . -t "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest" + +# Support commonly used variants of the image tag. +- id: 'Tag Container Image Aliases' + name: 'gcr.io/cloud-builders/docker:latest' + script: | + set -x + docker tag "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest" "gcr.io/${PROJECT_ID}/${_IMAGE}:latest" + +images: + # Push image with Cloud Build context. + - "${_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_REPO}/${_IMAGE}:latest" + - "gcr.io/${PROJECT_ID}/${_IMAGE}:latest" + +substitutions: + _IMAGE: hello + _LOCATION: us + _REPO: container + +options: + # Automatically make substitutions available as environment variables to scripts. + # https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values#mapping_substitutions_to_environment_variables + automapSubstitutions: true From 2d3801975a6c83ad2c98ebab0e96dcd3415ffca2 Mon Sep 17 00:00:00 2001 From: Steren Date: Wed, 15 May 2024 22:04:09 -0700 Subject: [PATCH 8/9] Update Placeholder container text. The Continuous Deployment flow now allows to click the URL right away, so we can't assume the build has failed. --- placeholder.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/placeholder.html b/placeholder.html index dd5c1a5..276097b 100644 --- a/placeholder.html +++ b/placeholder.html @@ -3,7 +3,7 @@ -Oops, something went wrong... | Cloud Run +Placeholder | Cloud Run
-

Oops, something went wrong…

-

Continuous deployment has been set up, but your repository has failed to build and deploy.

+

Sorry, this is just a placeholder…

+

Continuous deployment has been set up, but your code is not yet deployed.

@@ -139,7 +139,9 @@

Continuous deployment has been set up, but your repository has failed to bui

What's next?

    -
  1. From the Cloud Run service page, click "Build History".
  2. +
  3. Open the Cloud Run service page.
  4. +
  5. Check the status of your deployment.
  6. +
  7. If the build has failed, click "Build History".
  8. Examine your build logs to understand why it failed.
  9. Fix the issue in your code or Dockerfile (if any).
  10. Commit and push the change to your repository.
  11. From 2210f2e2cb3cb829c55c78fb15f74ad737435b55 Mon Sep 17 00:00:00 2001 From: Daniel Strebel Date: Tue, 2 Jul 2024 19:32:52 +0000 Subject: [PATCH 9/9] fix: use compact json output in /info endpoint --- hello.go | 1 - 1 file changed, 1 deletion(-) diff --git a/hello.go b/hello.go index 56874f8..304d5f8 100644 --- a/hello.go +++ b/hello.go @@ -176,7 +176,6 @@ func main() { http.HandleFunc("/info", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") encoder := json.NewEncoder(w) - encoder.SetIndent("", " ") encoder.Encode(data) })