From a7fb14326ae9aef6cf1d853f1527f244d4eea3a5 Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Wed, 6 Mar 2024 15:29:53 +0100 Subject: [PATCH 01/30] Re-generate pipeline from latest template --- ci/pipeline.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ci/pipeline.yml b/ci/pipeline.yml index c9191192..43694fb3 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -60,8 +60,8 @@ meta: fail_moji: ":airplane_arriving:" upset_moji: ":sadpanda:" pipeline_url: (( concat meta.url "/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}" )) - fail_link: (( concat "<" meta.slack.pipeline_url "/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}| Concourse Failure! " meta.slack.upset_moji ">" )) - fail_text: '(( concat meta.slack.fail_link " " meta.pipeline ": `${BUILD_JOB_NAME}` job failed" ))' + fail_link: (( concat "<" meta.slack.pipeline_url "/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}| Let's go fix it!>" )) + fail_text: '(( concat meta.pipeline ": `${BUILD_JOB_NAME}` job has failed " meta.slack.upset_moji " " meta.slack.fail_link " :hammer_and_wrench:" ))' groups: - name: (( grab meta.name )) @@ -102,6 +102,7 @@ jobs: on_failure: put: notify + no_get: true params: channel: (( grab meta.slack.channel )) username: (( grab meta.slack.username )) @@ -170,6 +171,7 @@ jobs: on_success: put: notify + no_get: true params: channel: (( grab meta.slack.channel )) username: (( grab meta.slack.username )) @@ -213,6 +215,7 @@ jobs: params: { file: version/number } on_failure: put: notify + no_get: true params: channel: (( grab meta.slack.channel )) username: (( grab meta.slack.username )) @@ -227,6 +230,7 @@ jobs: - { put: version, params: { file: version/number } } on_failure: put: notify + no_get: true params: channel: (( grab meta.slack.channel )) username: (( grab meta.slack.username )) @@ -241,6 +245,7 @@ jobs: - { put: version, params: { file: version/number } } on_failure: put: notify + no_get: true params: channel: (( grab meta.slack.channel )) username: (( grab meta.slack.username )) @@ -317,6 +322,7 @@ jobs: body: gh/notes.md on_failure: put: notify + no_get: true params: channel: (( grab meta.slack.channel )) username: (( grab meta.slack.username )) From 0232747d035d4af31f4fa8866f3b2a6b01c58c35 Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Fri, 10 May 2024 17:17:14 +0200 Subject: [PATCH 02/30] Slack resource doesn't implement any 'get' step --- ci/settings.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/settings.yml b/ci/settings.yml index 119a0baa..bce4e2a1 100644 --- a/ci/settings.yml +++ b/ci/settings.yml @@ -245,6 +245,7 @@ jobs: on_failure: put: notify + no_get: true params: channel: (( grab meta.slack.channel )) username: (( grab meta.slack.username )) @@ -252,6 +253,7 @@ jobs: text: (( grab meta.slack.fail_text )) on_success: put: notify + no_get: true params: channel: (( grab meta.slack.channel )) username: (( grab meta.slack.username )) From b9795cf4a72c5c29f9207376b31defaa54c7a76d Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Fri, 10 May 2024 18:37:00 +0200 Subject: [PATCH 03/30] Add missing env var for building statically-linked binaries --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 675d27c0..56fad148 100644 --- a/Makefile +++ b/Makefile @@ -16,10 +16,13 @@ e2e: test go test -race -v ./... -tags=e2e check: cmd/check/main.go + CGO_ENABLED=0 \ go build -o "build/check" -ldflags="-s -w" -v "cmd/check/main.go" in: cmd/in/main.go + CGO_ENABLED=0 \ go build -o "build/in" -ldflags="-s -w" -v "cmd/in/main.go" out: cmd/out/main.go + CGO_ENABLED=0 \ go build -o "build/out" -ldflags="-s -w" -v "cmd/out/main.go" From bb3c3c5b5232daa4660a5e28e53b808bcb656805 Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Fri, 10 May 2024 18:40:35 +0200 Subject: [PATCH 04/30] Fix base image pinning from Concourse resources Properly using build args as advised in the docs. --- Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3d99a234..94d054ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,13 @@ -FROM golang AS builder +ARG golang +ARG alpine + +FROM ${golang} AS builder ADD . /go/src/github.com/telia-oss/github-pr-resource WORKDIR /go/src/github.com/telia-oss/github-pr-resource RUN curl -sL https://taskfile.dev/install.sh | sh /dev/stdin v3.33.1 RUN ./bin/task build -FROM alpine AS resource +FROM ${alpine} AS resource COPY --from=builder /go/src/github.com/telia-oss/github-pr-resource/build /opt/resource RUN apk add --update --no-cache \ git \ From 99e91d241cf5ef02353039ca86495bacc54a7fcf Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Fri, 10 May 2024 18:44:45 +0200 Subject: [PATCH 05/30] Re-order Dockerfile statements to properly benefit from cache --- Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 94d054ff..bc27eb87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,23 @@ ARG golang ARG alpine + + FROM ${golang} AS builder +RUN curl -sL https://taskfile.dev/install.sh | sh /dev/stdin v3.33.1 ADD . /go/src/github.com/telia-oss/github-pr-resource WORKDIR /go/src/github.com/telia-oss/github-pr-resource -RUN curl -sL https://taskfile.dev/install.sh | sh /dev/stdin v3.33.1 RUN ./bin/task build FROM ${alpine} AS resource -COPY --from=builder /go/src/github.com/telia-oss/github-pr-resource/build /opt/resource RUN apk add --update --no-cache \ git \ git-lfs \ openssh \ - git-crypt \ - && chmod +x /opt/resource/* + git-crypt COPY scripts/askpass.sh /usr/local/bin/askpass.sh +COPY --from=builder /go/src/github.com/telia-oss/github-pr-resource/build /opt/resource +RUN chmod +x /opt/resource/* FROM resource LABEL MAINTAINER=telia-oss From e22e4e44e274fe955893e5ec2d346d1ab73ec486 Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Fri, 10 May 2024 18:49:44 +0200 Subject: [PATCH 06/30] Remove Taskfile alltogether --- .gitignore | 6 ----- .travis.yml | 13 ----------- Dockerfile | 16 ++++++++++--- Taskfile.yml | 66 ---------------------------------------------------- 4 files changed, 13 insertions(+), 88 deletions(-) delete mode 100644 .travis.yml delete mode 100644 Taskfile.yml diff --git a/.gitignore b/.gitignore index 947c90cd..45803faa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,5 @@ # Binaries build/* -# Taskfile -.task - -# Task installation in Travis -bin/task - # Editor .idea/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d9698cfd..00000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: go -sudo: false -matrix: - include: - - os: osx - go: 1.14.x - - os: linux - go: 1.14.x -notifications: - email: false -script: -- curl -sL https://taskfile.dev/install.sh | sh -- ./bin/task ci diff --git a/Dockerfile b/Dockerfile index bc27eb87..96035cba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,10 +4,18 @@ ARG alpine FROM ${golang} AS builder -RUN curl -sL https://taskfile.dev/install.sh | sh /dev/stdin v3.33.1 + +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get -y -qq update \ + && apt-get -y -qq install "make" + ADD . /go/src/github.com/telia-oss/github-pr-resource WORKDIR /go/src/github.com/telia-oss/github-pr-resource -RUN ./bin/task build + +RUN go version \ + && make all + + FROM ${alpine} AS resource RUN apk add --update --no-cache \ @@ -19,5 +27,7 @@ COPY scripts/askpass.sh /usr/local/bin/askpass.sh COPY --from=builder /go/src/github.com/telia-oss/github-pr-resource/build /opt/resource RUN chmod +x /opt/resource/* + + FROM resource -LABEL MAINTAINER=telia-oss +LABEL MAINTAINER=cloudfoundry-community diff --git a/Taskfile.yml b/Taskfile.yml deleted file mode 100644 index 6197a975..00000000 --- a/Taskfile.yml +++ /dev/null @@ -1,66 +0,0 @@ -version: '2' - -vars: - BUILD_DIR: build - DOCKER_REPO: loggregatorbot/github-pr-resource - -tasks: - default: - cmds: - - task: test - - generate: - desc: Generate test fakes - cmds: - - go generate ./... - sources: - - github.go - - git.go - generates: - - fakes/*.go - method: checksum - - test: - desc: Run test suite - deps: [generate] - cmds: - - gofmt -s -l -w . - - go vet -v ./... - - go test -race -v ./... - - e2e: - desc: Run E2E test suite - cmds: - - task: test - - go test -race -v ./... -tags=e2e - - docker: - desc: Build docker image under dev tag. - cmds: - - docker build -t {{.DOCKER_REPO}}:dev . - - build: - desc: Build check/in/out artifacts - cmds: - - task: test - - task: go-build - vars: {BINARY: check} - - task: go-build - vars: {BINARY: in} - - task: go-build - vars: {BINARY: out} - - go-build: - cmds: - - go build -o {{.BUILD_DIR}}/{{.BINARY}}{{exeExt}} -ldflags="-s -w" -v cmd/{{.BINARY}}/main.go - env: - CGO_ENABLED: '0' - GOOS: '{{OS}}' - GOARCH: '{{ARCH}}' - - ci: - desc: CI build and tests - cmds: - - task: build - - if [ -n "$(git status --porcelain)" ];then echo "Diff in generated files and/or formatting" && exit 1; fi - silent: true From 5c2972cbe8a4d5735755813894094ab11261a5ba Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Fri, 10 May 2024 18:53:36 +0200 Subject: [PATCH 07/30] Remove non-applicable workflow files --- .github/workflows/docker.yml | 30 ----------------------------- .github/workflows/go.yml | 37 ------------------------------------ 2 files changed, 67 deletions(-) delete mode 100644 .github/workflows/docker.yml delete mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index c77978b5..00000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: ci - -on: - push: - branches: - - 'main' - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v4 - with: - push: true - tags: loggregatorbot/github-pr-resource:latest - diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index 67fda7b2..00000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Go - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 - with: - go-version-file: "go.mod" - - run: go test --race ./... - - vet: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 - with: - go-version-file: "go.mod" - - run: go vet ./... - - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 - with: - go-version-file: "go.mod" - - uses: golangci/golangci-lint-action@v3.6.0 From c9578817459621caa24642fec6273ed7247e2fba Mon Sep 17 00:00:00 2001 From: Gstack Concourse Ninja Date: Fri, 10 May 2024 17:10:45 +0000 Subject: [PATCH 08/30] Update Golang 1.21 dependencies --- go.mod | 9 +++------ go.sum | 38 ++++++++------------------------------ 2 files changed, 11 insertions(+), 36 deletions(-) diff --git a/go.mod b/go.mod index 9ece34d9..9a280827 100644 --- a/go.mod +++ b/go.mod @@ -4,14 +4,13 @@ require ( github.com/google/go-github/v42 v42.0.0 github.com/google/go-github/v58 v58.0.0 github.com/maxbrunsfeld/counterfeiter/v6 v6.4.1 - github.com/shurcooL/githubv4 v0.0.0-20240120211514-18a1ae0e79dc - github.com/stretchr/testify v1.8.4 - golang.org/x/oauth2 v0.16.0 + github.com/shurcooL/githubv4 v0.0.0-20240429030203-be2daab69064 + github.com/stretchr/testify v1.9.0 + golang.org/x/oauth2 v0.20.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect @@ -19,8 +18,6 @@ require ( golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/sys v0.16.0 // indirect golang.org/x/tools v0.1.12 // indirect - google.golang.org/appengine v1.6.8 // indirect - google.golang.org/protobuf v1.32.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index bde97900..5a8bb24b 100644 --- a/go.sum +++ b/go.sum @@ -8,15 +8,10 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/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.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 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/go-github/v42 v42.0.0 h1:YNT0FwjPrEysRkLIiKuEfSvBPCGKphW5aS5PxwaoLec= @@ -43,18 +38,16 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM= -github.com/shurcooL/githubv4 v0.0.0-20240120211514-18a1ae0e79dc h1:vH0NQbIDk+mJLvBliNGfcQgUmhlniWBDXC79oRxfZA0= -github.com/shurcooL/githubv4 v0.0.0-20240120211514-18a1ae0e79dc/go.mod h1:zqMwyHmnN/eDOZOdiTohqIUKUrTFX62PNlu7IJdu0q8= +github.com/shurcooL/githubv4 v0.0.0-20240429030203-be2daab69064 h1:RCQBSFx5JrsbHltqTtJ+kN3U0Y3a/N/GlVdmRSoxzyE= +github.com/shurcooL/githubv4 v0.0.0-20240429030203-be2daab69064/go.mod h1:zqMwyHmnN/eDOZOdiTohqIUKUrTFX62PNlu7IJdu0q8= github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 h1:17JxqqJY66GmZVHkmAsGEkcIu0oCe3AM420QDgGwZx0= github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466/go.mod h1:9dIRpgIY7hVhoqfe0/FcYp0bpInZaT7dc3BYOprrIUE= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +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/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -65,17 +58,14 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210331212208-0fccb6fa2b5c/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= +golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -85,18 +75,12 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -108,18 +92,12 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From b374ea8e6ec642df694f24898dba5cb921409946 Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Fri, 10 May 2024 19:14:27 +0200 Subject: [PATCH 09/30] Mention new maintainers --- CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/CODEOWNERS b/CODEOWNERS index 3d6b4d64..5276aa95 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,2 +1,3 @@ # Default. Unless we have a more specific match. * @telia-oss/golang +* @gstackio/staff From 9b7f2e50ca798e732316c427968f55795d6bbc7a Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Fri, 10 May 2024 19:15:29 +0200 Subject: [PATCH 10/30] Consistently bump 'go-github' everywhere --- e2e/e2e_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index 0cb7beb8..36602fe3 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -17,7 +17,7 @@ import ( resource "github.com/telia-oss/github-pr-resource" - "github.com/google/go-github/v42/github" + "github.com/google/go-github/v58/github" "github.com/shurcooL/githubv4" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" From a13fbaa5a4fc325b464d6976f1a8867c2088163c Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Fri, 10 May 2024 19:15:46 +0200 Subject: [PATCH 11/30] Update release notes --- ci/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release_notes.md b/ci/release_notes.md index 5bc7e4ff..47b0c47d 100644 --- a/ci/release_notes.md +++ b/ci/release_notes.md @@ -2,3 +2,4 @@ - Bumped the [go-github](https://github.com/google/go-github) API to v58, the latest available. - Bumped other Go dependencies to latest versions. +- Built with latest go 1.21 patch version (i.e. v1.21.10) From f83cae176cd4d6f0784fd1444e7c9acc0b449bf7 Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Fri, 10 May 2024 19:16:30 +0200 Subject: [PATCH 12/30] Activate debug in image build when bumping version, as that's where it primarily breaks --- ci/settings.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/settings.yml b/ci/settings.yml index bce4e2a1..098623b9 100644 --- a/ci/settings.yml +++ b/ci/settings.yml @@ -188,6 +188,7 @@ jobs: caches: [ path: cache ] run: { path: build } params: + DEBUG: true IMAGE_ARG_golang: golang-latest/image.tar IMAGE_ARG_alpine: alpine-latest/image.tar output_mapping: From 219443eca8496ea0934725f00fa4e01f652a80c2 Mon Sep 17 00:00:00 2001 From: Gstack Concourse Ninja Date: Fri, 10 May 2024 17:20:19 +0000 Subject: [PATCH 13/30] Update Golang 1.21 dependencies --- go.mod | 8 ++++---- go.sum | 14 ++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 9a280827..1e1ffe9e 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,6 @@ module github.com/telia-oss/github-pr-resource require ( - github.com/google/go-github/v42 v42.0.0 github.com/google/go-github/v58 v58.0.0 github.com/maxbrunsfeld/counterfeiter/v6 v6.4.1 github.com/shurcooL/githubv4 v0.0.0-20240429030203-be2daab69064 @@ -14,10 +13,11 @@ require ( github.com/google/go-querystring v1.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect - golang.org/x/crypto v0.18.0 // indirect - golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect + golang.org/x/mod v0.8.0 // indirect + golang.org/x/net v0.10.0 // indirect golang.org/x/sys v0.16.0 // indirect - golang.org/x/tools v0.1.12 // indirect + golang.org/x/text v0.14.0 // indirect + golang.org/x/tools v0.6.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 5a8bb24b..0a60057d 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,6 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 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/go-github/v42 v42.0.0 h1:YNT0FwjPrEysRkLIiKuEfSvBPCGKphW5aS5PxwaoLec= -github.com/google/go-github/v42 v42.0.0/go.mod h1:jgg/jvyI0YlDOM1/ps6XYh04HNQ3vKf0CVko62/EhRg= github.com/google/go-github/v58 v58.0.0 h1:Una7GGERlF/37XfkPwpzYJe0Vp4dt2k1kCjlxwjIvzw= github.com/google/go-github/v58 v58.0.0/go.mod h1:k4hxDKEfoWpSqFlc8LTpGd9fu2KrV1YAa6Hi6FmDNY4= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= @@ -48,11 +46,9 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -66,6 +62,8 @@ golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbht golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -86,8 +84,8 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 457a8815bfed7d5b9448d51f92970d48c3f56a34 Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Fri, 10 May 2024 19:44:59 +0200 Subject: [PATCH 14/30] Adopt point releases in go.mod, and specify toolchain version --- ci/settings.yml | 11 +++++++---- go.mod | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ci/settings.yml b/ci/settings.yml index 098623b9..d6fb8217 100644 --- a/ci/settings.yml +++ b/ci/settings.yml @@ -164,15 +164,18 @@ jobs: awk '/^go /{print $2}' go.mod > ../golang-info/previous-version ( set -x + toolchain_version=$(go version | awk '{print $3}') go_version=$( - go version \ - | awk '{sub(/go/,"",$3); sub(/\.[[:digit:]]+$/,"",$3); print $3}' + go version | awk '{sub(/go/,"",$3); print $3}' ) - sed -i -Ee "s/^go [[:digit:].]+\$/go ${go_version}/" go.mod + inferred_go_min_version="${go_version%.*}.0" + sed -i -Ee "s/^go [[:digit:].]+\$/go ${inferred_go_min_version}/" go.mod go get -t -u ./... go mod tidy - echo "${go_version}" > ../golang-info/version + echo "${toolchain_version}" > ../golang-info/toolchain-version + echo "${go_version}" > ../golang-info/version + echo "${inferred_go_min_version}" > ../golang-info/min-version ) - task: build-docker-image diff --git a/go.mod b/go.mod index 1e1ffe9e..652758d9 100644 --- a/go.mod +++ b/go.mod @@ -21,4 +21,5 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -go 1.21 +go 1.21.0 +toolchain go1.21.10 From 39a67ebd3a1ea0d68b5f054e31273235c0f19c19 Mon Sep 17 00:00:00 2001 From: Gstack Concourse Ninja Date: Fri, 10 May 2024 17:49:02 +0000 Subject: [PATCH 15/30] Update Golang from 1.21.0 to 1.21.10 and its dependencies --- go.mod | 1 + 1 file changed, 1 insertion(+) diff --git a/go.mod b/go.mod index 652758d9..e8daa445 100644 --- a/go.mod +++ b/go.mod @@ -22,4 +22,5 @@ require ( ) go 1.21.0 + toolchain go1.21.10 From 3bae0a6d6ee7641b7ab35b4584666b06216fbd35 Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Fri, 10 May 2024 19:58:55 +0200 Subject: [PATCH 16/30] Fix commit message when bumping golang version --- ci/settings.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ci/settings.yml b/ci/settings.yml index d6fb8217..5662ec98 100644 --- a/ci/settings.yml +++ b/ci/settings.yml @@ -161,15 +161,16 @@ jobs: | xargs -0 -I{} cp -a {} "repo-bumped" cd "repo-bumped" || exit 115 - awk '/^go /{print $2}' go.mod > ../golang-info/previous-version + awk '/^toolchain /{sub(/go/,"",$2); print $2}' go.mod \ + > ../golang-info/previous-version + ( set -x toolchain_version=$(go version | awk '{print $3}') - go_version=$( - go version | awk '{sub(/go/,"",$3); print $3}' - ) + go_version=${toolchain_version#"go"} inferred_go_min_version="${go_version%.*}.0" sed -i -Ee "s/^go [[:digit:].]+\$/go ${inferred_go_min_version}/" go.mod + sed -i -Ee "s/^toolchain go[[:digit:].]+\$/toolchain ${toolchain_version}/" go.mod go get -t -u ./... go mod tidy From 271e10118d8ad560f3f3c6f5b6f6f088b926c72e Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Fri, 10 May 2024 20:06:17 +0200 Subject: [PATCH 17/30] Bump the 'go-github' library to v61 --- e2e/e2e_test.go | 2 +- github.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index 36602fe3..15fbe71b 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -17,7 +17,7 @@ import ( resource "github.com/telia-oss/github-pr-resource" - "github.com/google/go-github/v58/github" + "github.com/google/go-github/v61/github" "github.com/shurcooL/githubv4" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/github.go b/github.go index e73df8a5..967d5555 100644 --- a/github.go +++ b/github.go @@ -12,7 +12,7 @@ import ( "strconv" "strings" - "github.com/google/go-github/v58/github" + "github.com/google/go-github/v61/github" "github.com/shurcooL/githubv4" "golang.org/x/oauth2" ) From ffd3d7be72d2e8d944fe285e538540529c366e5c Mon Sep 17 00:00:00 2001 From: Gstack Concourse Ninja Date: Fri, 10 May 2024 18:10:34 +0000 Subject: [PATCH 18/30] Update Golang 1.21.10 dependencies --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e8daa445..19c7075f 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,7 @@ module github.com/telia-oss/github-pr-resource require ( - github.com/google/go-github/v58 v58.0.0 + github.com/google/go-github/v61 v61.0.0 github.com/maxbrunsfeld/counterfeiter/v6 v6.4.1 github.com/shurcooL/githubv4 v0.0.0-20240429030203-be2daab69064 github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index 0a60057d..83d07a69 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 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/go-github/v58 v58.0.0 h1:Una7GGERlF/37XfkPwpzYJe0Vp4dt2k1kCjlxwjIvzw= -github.com/google/go-github/v58 v58.0.0/go.mod h1:k4hxDKEfoWpSqFlc8LTpGd9fu2KrV1YAa6Hi6FmDNY4= +github.com/google/go-github/v61 v61.0.0 h1:VwQCBwhyE9JclCI+22/7mLB1PuU9eowCXKY5pNlu1go= +github.com/google/go-github/v61 v61.0.0/go.mod h1:0WR+KmsWX75G2EbpyGsGmradjo3IiciuI4BmdVCobQY= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= From 07712012b71b5e30977760795a36efb77b5956ec Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Fri, 10 May 2024 20:11:40 +0200 Subject: [PATCH 19/30] Update release notes --- ci/release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/release_notes.md b/ci/release_notes.md index 47b0c47d..8e992ac6 100644 --- a/ci/release_notes.md +++ b/ci/release_notes.md @@ -1,5 +1,5 @@ ### Improvements -- Bumped the [go-github](https://github.com/google/go-github) API to v58, the latest available. +- Bumped the [go-github](https://github.com/google/go-github) API to v61, the latest available. - Bumped other Go dependencies to latest versions. - Built with latest go 1.21 patch version (i.e. v1.21.10) From 9968707b1e07148a43caaad31978ec5fcfb08d7a Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Sat, 11 May 2024 01:03:36 +0200 Subject: [PATCH 20/30] Add project notice --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 8994e9d0..d3ec671b 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,24 @@ Inspired by [the original][original-resource], with some important differences: Make sure to check out [#migrating](#migrating) to learn more. + +### Maintainance notice + +This project is a fork of [telia-oss/github-pr-resource][telia_repo], which +hasn't received any maintenance for years, as telia-oss/github-pr-resource#246 +can testify and explain. + +As exmplained in [this comment][maintainance_takeover_comment], the project +here is to take over the maintenance, merge [pending contributions][pending_contributions] +that have been submitted as PRs to the original repo and bring significant +features, and at some point build a solution for a growing code base of +automated tests. + +[telia_repo]: https://github.com/telia-oss/github-pr-resource +[maintainance_takeover_comment]: https://github.com/telia-oss/github-pr-resource/issues/246#issuecomment-2105230468 +[pending_contributions]: https://github.com/telia-oss/github-pr-resource/pulls + + ## Source Configuration | Parameter | Required | Example | Description | From 401521b228f2be269ec25f7ba547c3fb7ac0bb5d Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Sat, 11 May 2024 01:24:51 +0200 Subject: [PATCH 21/30] Add new 'metadata-map.json' that can be loaded by 'load_var' + Add related unit tests (fixes telia-oss/github-pr-resource#248) --- in.go | 11 +++++++++ in_test.go | 68 +++++++++++++++++++++++++++++++----------------------- 2 files changed, 50 insertions(+), 29 deletions(-) diff --git a/in.go b/in.go index fa0eb242..10a79325 100644 --- a/in.go +++ b/in.go @@ -81,6 +81,17 @@ func Get(request GetRequest, github Github, git Git, outputDir string) (*GetResp } } + metadataMap := make(map[string]string) + for _, d := range metadata { + metadataMap[d.Name] = d.Value + } + if b, err = json.Marshal(metadataMap); err != nil { + return nil, fmt.Errorf("failed to marshal map of metadata: %s", err) + } + if err := ioutil.WriteFile(filepath.Join(path, "metadata-map.json"), b, 0644); err != nil { + return nil, fmt.Errorf("failed to write metadata map file: %s", err) + } + switch tool := request.Params.IntegrationTool; tool { case "rebase": if err := git.Rebase(pull.BaseRefName, pull.Tip.OID, request.Params.Submodules); err != nil { diff --git a/in_test.go b/in_test.go index ce0b0b34..0f41787d 100644 --- a/in_test.go +++ b/in_test.go @@ -17,15 +17,16 @@ import ( func TestGet(t *testing.T) { tests := []struct { - description string - source resource.Source - version resource.Version - parameters resource.GetParameters - pullRequest *resource.PullRequest - versionString string - metadataString string - files []resource.ChangedFileObject - filesString string + description string + source resource.Source + version resource.Version + parameters resource.GetParameters + pullRequest *resource.PullRequest + versionString string + metadataString string + metadataMapString string + files []resource.ChangedFileObject + filesString string }{ { description: "get works", @@ -39,10 +40,11 @@ func TestGet(t *testing.T) { CommittedDate: time.Time{}, State: githubv4.PullRequestStateOpen, }, - parameters: resource.GetParameters{}, - pullRequest: createTestPR(1, "master", "anonymous", false, false, 0, nil, false, githubv4.PullRequestStateOpen), - versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + parameters: resource.GetParameters{}, + pullRequest: createTestPR(1, "master", "anonymous", false, false, 0, nil, false, githubv4.PullRequestStateOpen), + versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, + metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, }, { description: "get supports unlocking with git crypt", @@ -57,10 +59,11 @@ func TestGet(t *testing.T) { CommittedDate: time.Time{}, State: githubv4.PullRequestStateOpen, }, - parameters: resource.GetParameters{}, - pullRequest: createTestPR(1, "master", "anonymous", false, false, 0, nil, false, githubv4.PullRequestStateOpen), - versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + parameters: resource.GetParameters{}, + pullRequest: createTestPR(1, "master", "anonymous", false, false, 0, nil, false, githubv4.PullRequestStateOpen), + versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, + metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, }, { description: "get supports rebasing", @@ -77,9 +80,10 @@ func TestGet(t *testing.T) { parameters: resource.GetParameters{ IntegrationTool: "rebase", }, - pullRequest: createTestPR(1, "master", "anonymous", false, false, 0, nil, false, githubv4.PullRequestStateOpen), - versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + pullRequest: createTestPR(1, "master", "anonymous", false, false, 0, nil, false, githubv4.PullRequestStateOpen), + versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, + metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, }, { description: "get supports checkout", @@ -96,9 +100,10 @@ func TestGet(t *testing.T) { parameters: resource.GetParameters{ IntegrationTool: "checkout", }, - pullRequest: createTestPR(1, "master", "anonymous", false, false, 0, nil, false, githubv4.PullRequestStateOpen), - versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + pullRequest: createTestPR(1, "master", "anonymous", false, false, 0, nil, false, githubv4.PullRequestStateOpen), + versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, + metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, }, { description: "get supports git_depth", @@ -115,9 +120,10 @@ func TestGet(t *testing.T) { parameters: resource.GetParameters{ GitDepth: 2, }, - pullRequest: createTestPR(1, "master", "anonymous", false, false, 0, nil, false, githubv4.PullRequestStateOpen), - versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + pullRequest: createTestPR(1, "master", "anonymous", false, false, 0, nil, false, githubv4.PullRequestStateOpen), + versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, + metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, }, { description: "get supports list_changed_files", @@ -143,9 +149,10 @@ func TestGet(t *testing.T) { Path: "Other.md", }, }, - versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, - filesString: "README.md\nOther.md\n", + versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, + metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, + filesString: "README.md\nOther.md\n", }, } @@ -178,6 +185,9 @@ func TestGet(t *testing.T) { metadata := readTestFile(t, filepath.Join(dir, ".git", "resource", "metadata.json")) assert.Equal(t, tc.metadataString, metadata) + metadataMap := readTestFile(t, filepath.Join(dir, ".git", "resource", "metadata-map.json")) + assert.Equal(t, tc.metadataMapString, metadataMap) + // Verify individual files files := map[string]string{ "pr": "1", From 0a6bde47711669a7d9d989eca032898ed7c6e35b Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Sat, 11 May 2024 01:25:01 +0200 Subject: [PATCH 22/30] Document the new 'metadata-map.json' file --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index d3ec671b..f1e13561 100644 --- a/README.md +++ b/README.md @@ -102,8 +102,16 @@ input. Because the base of the PR is not locked to a specific commit in versions requested version and the metadata emitted by `get` are available to your tasks as JSON: - `.git/resource/version.json` - `.git/resource/metadata.json` +- `.git/resource/metadata-map.json` - `.git/resource/changed_files` (if enabled by `list_changed_files`) +The `metadata.json` file contains an array of objects, one for each key-value +pair, with a `name` key and a `value` key. In order to support the +[`load_var` step][load_var_step], another `metadata-map.json` provides the +same informtion with a plain key-value format. + +[load_var_step]: https://concourse-ci.org/load-var-step.html + The information in `metadata.json` is also available as individual files in the `.git/resource` directory, e.g. the `base_sha` is available as `.git/resource/base_sha`. For a complete list of available (individual) metadata files, please check the code [here](https://github.com/telia-oss/github-pr-resource/blob/master/in.go#L66). From a58f6c201adcc90a70960dcf965ef26fdd65d02d Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Sat, 11 May 2024 01:42:41 +0200 Subject: [PATCH 23/30] Update release notes --- ci/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release_notes.md b/ci/release_notes.md index 8e992ac6..a988fb24 100644 --- a/ci/release_notes.md +++ b/ci/release_notes.md @@ -1,5 +1,6 @@ ### Improvements +- New metadata file that supports the new `load_var` Concourse statement (PR #7 by @bgandon, initially submitted as PR telia-oss/github-pr-resource#276) - Bumped the [go-github](https://github.com/google/go-github) API to v61, the latest available. - Bumped other Go dependencies to latest versions. - Built with latest go 1.21 patch version (i.e. v1.21.10) From f50647b8723f84bbeb165c94d0398ffc22afb034 Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Sat, 11 May 2024 02:03:12 +0200 Subject: [PATCH 24/30] Add PR body in the metadata provided by 'get' steps --- in.go | 1 + in_test.go | 26 ++++++++++++++------------ models.go | 1 + 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/in.go b/in.go index 10a79325..7fae4400 100644 --- a/in.go +++ b/in.go @@ -43,6 +43,7 @@ func Get(request GetRequest, github Github, git Git, outputDir string) (*GetResp var metadata Metadata metadata.Add("pr", strconv.Itoa(pull.Number)) metadata.Add("title", pull.Title) + metadata.Add("body", pull.Body) metadata.Add("url", pull.URL) metadata.Add("head_name", pull.HeadRefName) metadata.Add("head_sha", pull.Tip.OID) diff --git a/in_test.go b/in_test.go index 0f41787d..f4a6089a 100644 --- a/in_test.go +++ b/in_test.go @@ -43,8 +43,8 @@ func TestGet(t *testing.T) { parameters: resource.GetParameters{}, pullRequest: createTestPR(1, "master", "anonymous", false, false, 0, nil, false, githubv4.PullRequestStateOpen), versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, - metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, + metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"body","value":"pr1 body"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","body":"pr1 body","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, }, { description: "get supports unlocking with git crypt", @@ -62,8 +62,8 @@ func TestGet(t *testing.T) { parameters: resource.GetParameters{}, pullRequest: createTestPR(1, "master", "anonymous", false, false, 0, nil, false, githubv4.PullRequestStateOpen), versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, - metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, + metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"body","value":"pr1 body"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","body":"pr1 body","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, }, { description: "get supports rebasing", @@ -82,8 +82,8 @@ func TestGet(t *testing.T) { }, pullRequest: createTestPR(1, "master", "anonymous", false, false, 0, nil, false, githubv4.PullRequestStateOpen), versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, - metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, + metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"body","value":"pr1 body"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","body":"pr1 body","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, }, { description: "get supports checkout", @@ -102,8 +102,8 @@ func TestGet(t *testing.T) { }, pullRequest: createTestPR(1, "master", "anonymous", false, false, 0, nil, false, githubv4.PullRequestStateOpen), versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, - metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, + metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"body","value":"pr1 body"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","body":"pr1 body","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, }, { description: "get supports git_depth", @@ -122,8 +122,8 @@ func TestGet(t *testing.T) { }, pullRequest: createTestPR(1, "master", "anonymous", false, false, 0, nil, false, githubv4.PullRequestStateOpen), versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, - metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, + metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"body","value":"pr1 body"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","body":"pr1 body","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, }, { description: "get supports list_changed_files", @@ -150,8 +150,8 @@ func TestGet(t *testing.T) { }, }, versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","state":"OPEN"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, - metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, + metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"body","value":"pr1 body"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"state","value":"OPEN"}]`, + metadataMapString: `{"author":"login1","author_email":"user@example.com","base_name":"master","base_sha":"sha","body":"pr1 body","head_name":"pr1","head_sha":"oid1","message":"commit message1","pr":"1","state":"OPEN","title":"pr1 title","url":"pr1 url"}`, filesString: "README.md\nOther.md\n", }, } @@ -200,6 +200,7 @@ func TestGet(t *testing.T) { "author": "login1", "author_email": "user@example.com", "title": "pr1 title", + "body": "pr1 body", } for filename, expected := range files { @@ -353,6 +354,7 @@ func createTestPR( ID: fmt.Sprintf("pr%s", n), Number: count, Title: fmt.Sprintf("pr%s title", n), + Body: fmt.Sprintf("pr%s body", n), URL: fmt.Sprintf("pr%s url", n), BaseRefName: baseName, HeadRefName: fmt.Sprintf("pr%s", n), diff --git a/models.go b/models.go index 8372fcfe..6695308f 100644 --- a/models.go +++ b/models.go @@ -103,6 +103,7 @@ type PullRequestObject struct { ID string Number int Title string + Body string URL string BaseRefName string HeadRefName string From df17544a1e7509224367866e089ef623a7c29208 Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Sat, 11 May 2024 02:27:07 +0200 Subject: [PATCH 25/30] Update the documentation regarding metadata now that 'body' is provided --- README.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f1e13561..52346031 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ is available as `.git/resource/base_sha`. For a complete list of available (indi - `author_email`: the e-mail address of the pull request author - `base_name`: the base branch of the pull request - `base_sha`: the commit of the base branch of the pull request +- `body`: the description of the pull request - `head_name`: the branch associated with the pull request - `head_sha`: the latest commit hash of the branch associated with the pull request - `message`: the message of the last commit of the pull request, as designated by `head_sha` @@ -291,13 +292,16 @@ If you are coming from [jtarchie/github-pullrequest-resource][original-resource] #### Metadata stored in the `.git` directory The original resource stores [a bunch of metadata][metadata] related to the -pull request as `git config`, or plain files in the `.git` directory. This -resource provide most metadata with possibly different names, and the files -are to be found in the `.git/reource` directory. +pull request as entries in `.git/config`, or plain files in the `.git/` +directory. -If you were using the metadata stored in Git config, you need to update your -code. For example `git config --get pullrequest.url` in some Bash code can be -replaced by `echo $(< .git/resource/url)`. +This resource provide all these metadata, but with possibly different names, +and only as files to be found in the `.git/resource` directory. + +With this resource, no entry is added to the `.git/config` file. If you were +using the metadata stored in Git config, you need to update your code. For +example `git config --get pullrequest.url` in some Bash code can be replaced +by `echo $(< .git/resource/url)`. Here is the list of changes: @@ -308,7 +312,7 @@ Here is the list of changes: - `.git/branch` -> `.git/resource/head_name` - `.git/head_sha` -> `.git/resource/head_sha` - `.git/userlogin` -> `.git/resource/author` -- `.git/body` -> _no equivalent_ +- `.git/body` -> `.git/resource/body` [metadata]: https://github.com/jtarchie/github-pullrequest-resource#in-clone-the-repository-at-the-given-pull-request-ref From 829f5580dc327b8a49a413d4d16621668f4b5693 Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Sat, 11 May 2024 02:38:56 +0200 Subject: [PATCH 26/30] Update release notes --- ci/release_notes.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/release_notes.md b/ci/release_notes.md index a988fb24..6097af60 100644 --- a/ci/release_notes.md +++ b/ci/release_notes.md @@ -1,6 +1,7 @@ ### Improvements -- New metadata file that supports the new `load_var` Concourse statement (PR #7 by @bgandon, initially submitted as PR telia-oss/github-pr-resource#276) +- New metadata file that supports the new `load_var` Concourse statement (PR #7 by @bgandon, initially submitted as PR telia-oss/github-pr-resource#276, fixing issue telia-oss/github-pr-resource#248) +- Add PR body in the metadata provided by 'get' steps (PR #8 by @bgandon, initially submitted as PR telia-oss/github-pr-resource#277, fixing issue telia-oss/github-pr-resource#194) - Bumped the [go-github](https://github.com/google/go-github) API to v61, the latest available. - Bumped other Go dependencies to latest versions. - Built with latest go 1.21 patch version (i.e. v1.21.10) From f0c8ca205b51a3547865f3c64c7d19bfc30a2de1 Mon Sep 17 00:00:00 2001 From: Bee Date: Thu, 15 Apr 2021 12:35:30 +0100 Subject: [PATCH 27/30] Fix defect with bot users when 'delete_previous_comments' is enabled Indeed, in order to delete the correct comments, the golang code makes sure that comment's `Author.Login` is the same as current `Viewer.Login`. But with bot users, viewer's login is "githubApp[bot]" and author login is "githubApp". As a consequence, for the comparison to succeed, we need to remove any trailing "[bot]" suffix from both parties, and compare the resulting prefixes. This isue was originally submitted as telia-oss/github-pr-resource#245 and fixed later in monzo/github-pr-resource#4. --- github.go | 9 ++++++++- github_test.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/github.go b/github.go index 967d5555..c1410aa9 100644 --- a/github.go +++ b/github.go @@ -435,7 +435,7 @@ func (m *GithubClient) DeletePreviousComments(prNumber string) error { } for _, e := range getComments.Repository.PullRequest.Comments.Edges { - if e.Node.Author.Login == getComments.Viewer.Login { + if cleanBotUserName(e.Node.Author.Login) == cleanBotUserName(getComments.Viewer.Login) { _, err := m.V3.Issues.DeleteComment(context.TODO(), m.Owner, m.Repository, e.Node.DatabaseId) if err != nil { return err @@ -453,3 +453,10 @@ func parseRepository(s string) (string, string, error) { } return parts[0], parts[1], nil } + +func cleanBotUserName(username string) string { + if strings.HasSuffix(username, "[bot]") { + return strings.TrimSuffix(username, "[bot]") + } + return username +} diff --git a/github_test.go b/github_test.go index 58a419d2..84e22d07 100644 --- a/github_test.go +++ b/github_test.go @@ -25,3 +25,50 @@ func TestListTeamMembers(t *testing.T) { require.Contains(t, val, "thelinuxfoundation") } + +func Test_cleanBotUserName(t *testing.T) { + type args struct { + username string + } + tests := []struct { + name string + args args + want string + }{ + { + name: "Main Test Case", + args: args{ + username: "infratest[bot]", + }, + want: "infratest", + }, + { + name: "Without suffix bot", + args: args{ + username: "infratest", + }, + want: "infratest", + }, + { + name: "Bot only", + args: args{ + username: "[bot]", + }, + want: "", + }, + { + name: "Bot at start", + args: args{ + username: "[bot]infratest", + }, + want: "[bot]infratest", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := cleanBotUserName(tt.args.username); got != tt.want { + t.Errorf("cleanBotUserName() = %v, want %v", got, tt.want) + } + }) + } +} From b71c41b53797959fba93b45db64fef8798704177 Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Sat, 11 May 2024 03:09:04 +0200 Subject: [PATCH 28/30] Update release notes --- ci/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release_notes.md b/ci/release_notes.md index 6097af60..5080c63d 100644 --- a/ci/release_notes.md +++ b/ci/release_notes.md @@ -2,6 +2,7 @@ - New metadata file that supports the new `load_var` Concourse statement (PR #7 by @bgandon, initially submitted as PR telia-oss/github-pr-resource#276, fixing issue telia-oss/github-pr-resource#248) - Add PR body in the metadata provided by 'get' steps (PR #8 by @bgandon, initially submitted as PR telia-oss/github-pr-resource#277, fixing issue telia-oss/github-pr-resource#194) +- Fix defect with bot users when `delete_previous_comments` is enabled (originally submitted as telia-oss/github-pr-resource#245 and fixed later in monzo/github-pr-resource#4, thanks @bee-san) - Bumped the [go-github](https://github.com/google/go-github) API to v61, the latest available. - Bumped other Go dependencies to latest versions. - Built with latest go 1.21 patch version (i.e. v1.21.10) From 1c90cc99fd622a59d189bf215e39db4f2af412f3 Mon Sep 17 00:00:00 2001 From: Gstack Concourse Ninja Date: Sat, 11 May 2024 10:47:50 +0000 Subject: [PATCH 29/30] release v0.25.0 [skip ci] --- ci/release_notes.md | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 ci/release_notes.md diff --git a/ci/release_notes.md b/ci/release_notes.md deleted file mode 100644 index 5080c63d..00000000 --- a/ci/release_notes.md +++ /dev/null @@ -1,8 +0,0 @@ -### Improvements - -- New metadata file that supports the new `load_var` Concourse statement (PR #7 by @bgandon, initially submitted as PR telia-oss/github-pr-resource#276, fixing issue telia-oss/github-pr-resource#248) -- Add PR body in the metadata provided by 'get' steps (PR #8 by @bgandon, initially submitted as PR telia-oss/github-pr-resource#277, fixing issue telia-oss/github-pr-resource#194) -- Fix defect with bot users when `delete_previous_comments` is enabled (originally submitted as telia-oss/github-pr-resource#245 and fixed later in monzo/github-pr-resource#4, thanks @bee-san) -- Bumped the [go-github](https://github.com/google/go-github) API to v61, the latest available. -- Bumped other Go dependencies to latest versions. -- Built with latest go 1.21 patch version (i.e. v1.21.10) From 556f25f08b877264dc8792d88928cda9f8e34c6b Mon Sep 17 00:00:00 2001 From: Olivier ORAND Date: Mon, 13 May 2024 15:21:50 +0000 Subject: [PATCH 30/30] orange-custo: set default values for used docker images --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 96035cba..1a7a91ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -ARG golang -ARG alpine +ARG golang="golang:1.21.6" +ARG alpine="alpine:3.19.1"