From b5d1148f0e733e6b12dc68d7078a825d8d561106 Mon Sep 17 00:00:00 2001 From: Fred Heinecke Date: Thu, 29 Feb 2024 13:04:09 -0600 Subject: [PATCH 1/5] Minor fixes to CI/CD --- .github/workflows/cd.yaml | 2 +- .github/workflows/ci.yaml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 2a0e4b8..557481d 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -29,7 +29,7 @@ jobs: with: # renovate: earthly-version version: v0.8.4 - - name: Cut a new release for ${{ env.SEMVER_TAG }} + - name: Cut a new release for ${{ github.ref_name }} env: GIT_TAG: ${{ github.ref_name }} working-directory: tools/ami-cleanup diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1656c9a..0ddf991 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,6 +3,10 @@ on: pull_request: branches: - main + paths-ignore: + - "*.md" + - ".earthlyignore" + - "LICENSE" concurrency: cancel-in-progress: true From cda3d2009a4d2acfb514ddf3e44d32db46f0575f Mon Sep 17 00:00:00 2001 From: Fred Heinecke Date: Thu, 29 Feb 2024 13:42:28 -0600 Subject: [PATCH 2/5] trigger ci From dd3ce5ea8b164b0c4fe7c740a3c9f97f6782647a Mon Sep 17 00:00:00 2001 From: Fred Heinecke Date: Thu, 29 Feb 2024 13:43:33 -0600 Subject: [PATCH 3/5] rm working dir --- .github/workflows/cd.yaml | 1 - .github/workflows/ci.yaml | 2 -- 2 files changed, 3 deletions(-) diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 557481d..e385451 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -32,5 +32,4 @@ jobs: - name: Cut a new release for ${{ github.ref_name }} env: GIT_TAG: ${{ github.ref_name }} - working-directory: tools/ami-cleanup run: earthly -ci +release --GIT_TAG="$GIT_TAG" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0ddf991..10dc396 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,8 +24,6 @@ jobs: # renovate: earthly-version version: v0.8.4 - name: Lint Go code - working-directory: tools/ami-cleanup run: earthly -ci +lint --OUTPUT_FORMAT=github-actions - name: Run Go tests - working-directory: tools/ami-cleanup run: earthly -ci +test --OUTPUT_FORMAT=github-actions From 76e3580c55932aab36ff1fbadf94dd300e4f646d Mon Sep 17 00:00:00 2001 From: Fred Heinecke Date: Wed, 6 Mar 2024 13:46:19 -0600 Subject: [PATCH 4/5] CI/CD fixes --- .earthlyignore | 3 + .github/workflows/cd.yaml | 8 ++- .gitignore | 2 + Earthfile | 120 +++++++++++++++++-------------- collector.go | 2 +- go.mod | 18 ++--- go.sum | 35 ++++----- hack-todo-remove/go-github.patch | 12 ++++ helm/Chart.yaml | 22 ++++++ main.go | 5 ++ 10 files changed, 146 insertions(+), 81 deletions(-) create mode 100644 .gitignore create mode 100644 hack-todo-remove/go-github.patch create mode 100644 helm/Chart.yaml diff --git a/.earthlyignore b/.earthlyignore index 791bb88..dd5d26a 100644 --- a/.earthlyignore +++ b/.earthlyignore @@ -1,2 +1,5 @@ Earthfile .earthlyignore +outputs/ +.gitignore +go-github diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index e385451..d112d56 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -29,7 +29,13 @@ jobs: with: # renovate: earthly-version version: v0.8.4 + - name: Login to GitHub Container Registry + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Cut a new release for ${{ github.ref_name }} env: GIT_TAG: ${{ github.ref_name }} - run: earthly -ci +release --GIT_TAG="$GIT_TAG" + run: earthly -ci --push +release --GIT_TAG="$GIT_TAG" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..960ea5a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +outputs +go-github diff --git a/Earthfile b/Earthfile index 6bd33c5..de784a8 100644 --- a/Earthfile +++ b/Earthfile @@ -3,40 +3,68 @@ VERSION 0.8 ARG --global GIT_TAG ARG --global BINARY_NAME="gha-exporter" ARG --global IMAGE_NAME="gha-exporter" +ARG --global USEROS +ARG --global USERARCH +ARG --global GOOS=$USEROS +ARG --global GOARCH=$USERARCH + +# TODO remove this, this is a temp workaround +download-go-github: + FROM alpine/git:2.43.0 + WORKDIR /src + RUN git clone --single-branch --depth 1 --branch v60.0.0 https://github.com/google/go-github.git . + SAVE ARTIFACT go.mod + SAVE ARTIFACT . AS LOCAL go-github + +# TODO remove this, this is a temp workaround +build-go-github-patch: + ARG NATIVEARCH + # Pull the Go version from the project + FROM alpine:3.19.0 + WORKDIR /gomod + COPY +download-go-github/go.mod . + LET GO_VERSION=$(sed -rn 's/^go (.*)$/\1/p' go.mod) + + FROM --platform "linux/$NATIVEARCH" "golang:$GO_VERSION" + WORKDIR /go/src/ + COPY +download-go-github/* . + + # Download the project's requirements + CACHE --sharing shared --id gomodcache $(go env GOMODCACHE) + RUN go mod download -x + + # Load and apply the patch + CACHE --sharing shared --id gocache $(go env GOCACHE) + COPY ./hack-todo-remove/go-github.patch go-github.patch + RUN git apply go-github.patch && GOOS=linux GOARCH=$NATIVEARCH go generate ./... + SAVE ARTIFACT . AS LOCAL go-github # This target is used to setup a common Go environment used for both builds and tests. go-environment: - # Environment variables - ARG --required TARGETOS - ARG --required TARGETARCH - # Native arch is required because otherewise images will default to TARGETARCH, - # which is overridden by `--platform`. - ARG --required NATIVEARCH - # This keeps the Go version set in a single place # A container is used to pin the `sed` dependency. `LOCALLY` could be used instead, but is # disallowed by the `--strict` Earthly flag which is used to help enfore reproducability. - FROM --platform="linux/$NATIVEARCH" alpine:3.19.0 + FROM alpine:3.19.0 WORKDIR /gomod COPY go.mod . LET GO_VERSION=$(sed -rn 's/^go (.*)$/\1/p' go.mod) - # Run on the native architecture, but setup for cross compilation. - FROM --platform="linux/$NATIVEARCH" "golang:$GO_VERSION" - ENV GOOS=$TARGETOS - ENV GOARCH=$TARGETARCH + # Setup Go. + FROM "golang:$GO_VERSION" WORKDIR /go/src - CACHE --sharing shared $(go env GOMODCACHE) + CACHE --sharing shared --id gomodcache $(go env GOMODCACHE) # Load the source and download modules COPY . . RUN go mod download -x + # TODO remove this, this is a temp workaround + COPY +build-go-github-patch/* ./go-github + RUN go mod edit -replace github.com/google/go-github/v60=./go-github + # Produces a single executable binary file for the target platform. -# This should generally be called as `earthly --platform= +binary`. binary: - ARG --required TARGETPLATFORM - FROM --platform "$TARGETPLATFORM" +go-environment + FROM +go-environment # Caches are specific to a given target, so the GOCACHE is declared here as it # is updated when builds run CACHE --sharing shared --id gocache $(go env GOCACHE) @@ -45,32 +73,24 @@ binary: LET LINKER_FLAGS="-s -w" IF [ -n "$GIT_TAG" ] ARG EARTHLY_GIT_SHORT_HASH - SET LINKER_FLAGS="$LINKER_FLAGS -X 'main.Version=$GIT_TAG+$EARTHLY_GIT_SHORT_HASH'" + SET LINKER_FLAGS="$LINKER_FLAGS -X 'main.Version=${GIT_TAG#v}+$EARTHLY_GIT_SHORT_HASH'" END LET BINARY_OUTPUT_PATH="../$BINARY_NAME" # Do the actual build - RUN go build -o "$BINARY_OUTPUT_PATH" -ldflags="$LINKER_FLAGS" cmd/main.go + RUN go build -o "$BINARY_OUTPUT_PATH" -ldflags="$LINKER_FLAGS" . # Process the outputs - SAVE ARTIFACT "$BINARY_OUTPUT_PATH" AS LOCAL "outputs/$TARGETPLATFORM/$BINARY_NAME" - -# Same as `binary`, except the platform defaults to the local host. -local-binary: - # This is a workaround for the default TARGETOS value being the buildkit OS (linux), - # which is wrong when running on MacOS. Unfortunately this is not fixed by specifying - # TARGETOS under LOCALLY, because then it cannot be overridden via the platform arg. - ARG --required USERPLATFORM - BUILD --platform="$USERPLATFORM" +binary + SAVE ARTIFACT "$BINARY_OUTPUT_PATH" AS LOCAL "outputs/$GOOS/$GOARCH/$BINARY_NAME" # Produces a container image and multiarch manifest. These are automatically loaded into the # local Docker image cache. If multiple platforms are specified, then they are all added # under the same image. container-image: # Build args - ARG --required TARGETARCH - ARG --required NATIVEARCH - ARG CONTAINER_REGISTRY="" + ARG TARGETARCH + ARG NATIVEARCH + ARG CONTAINER_REGISTRY # Setup for build # `IF` statements essentially run as shell `if` statements, so a build context must be declared @@ -78,13 +98,12 @@ container-image: FROM --platform="linux/$NATIVEARCH" alpine:3.19.0 LET IMAGE_TAG="latest" IF [ -n "$GIT_TAG" ] - SET IMAGE_TAG="$GIT_TAG" + SET IMAGE_TAG="${GIT_TAG#v}" END # Do the actual build - RUN echo "FULL IMAGE NAME: $CONTAINER_REGISTRY$IMAGE_NAME:$IMAGE_TAG" FROM --platform="linux/$TARGETARCH" scratch - COPY --platform="linux/$TARGETARCH" +binary/* / + COPY (+binary/* --GOOS="linux" --GOARCH="$TARGETARCH") / # Unfortunately arg expansion is not supported here, see https://github.com/earthly/earthly/issues/1846 ENTRYPOINT [ "/gha-exporter" ] @@ -93,42 +112,35 @@ container-image: # Same as `binary`, but wraps the output in a tarball. tarball: - ARG --required TARGETOS - ARG --required TARGETARCH - ARG --required NATIVEARCH - ARG TARBALL_NAME="$BINARY_NAME-$TARGETOS-$TARGETARCH.tar.gz" + ARG TARBALL_NAME="$BINARY_NAME-$GOOS-$GOARCH.tar.gz" - FROM --platform="linux/$NATIVEARCH" alpine:3.19.0 + FROM alpine:3.19.0 WORKDIR /tarball - COPY --platform="$TARGETOS/$TARGETARCH" +binary/* . + COPY +binary/* . RUN tar -czvf "$TARBALL_NAME" * - SAVE ARTIFACT $TARBALL_NAME AS LOCAL outputs/$TARGETOS/$TARGETARCH/$TARBALL_NAME - -local-tarball: - ARG --required USERPLATFORM - BUILD --platform="$USERPLATFORM" +tarball + SAVE ARTIFACT $TARBALL_NAME AS LOCAL "outputs/$GOOS/$GOARCH/$TARBALL_NAME" all: - BUILD +local-binary - BUILD +local-tarball + BUILD +binary + BUILD +tarball BUILD +container-image # Runs the project's Go tests. test: - # Probably not needed, but this supports running tests on different architectures. - ARG --required TARGETPLATFORM + ARG NATIVEARCH # For options, see # https://github.com/gotestyourself/gotestsum?tab=readme-ov-file#output-format ARG OUTPUT_FORMAT="pkgname-and-test-fails" - FROM --platform "$TARGETPLATFORM" +go-environment + FROM +go-environment WORKDIR /go/src - CACHE --sharing shared $(go env GOMODCACHE) + CACHE --sharing shared --id gomodcache $(go env GOMODCACHE) CACHE --sharing shared --id gocache $(go env GOCACHE) - RUN go install gotest.tools/gotestsum@latest + RUN GOOS="linux" GOARCH="$NATIVEARCH" go install gotest.tools/gotestsum@latest RUN gotestsum --format "$OUTPUT_FORMAT" ./... -- -shuffle on -timeout 2m -race lint: + ARG NATIVEARCH # For options, see https://golangci-lint.run/usage/configuration/#command-line-options ARG OUTPUT_FORMAT="colored-line-number" @@ -137,9 +149,9 @@ lint: WORKDIR /go/src ENV GOLANGCI_LINT_CACHE=/golangci-lint-cache CACHE $GOLANGCI_LINT_CACHE - CACHE --sharing shared $(go env GOMODCACHE) + CACHE --sharing shared --id gomodcache $(go env GOMODCACHE) CACHE --sharing shared --id gocache $(go env GOCACHE) - RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2 + RUN GOOS="linux" GOARCH="$NATIVEARCH" go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2 # Run the linter RUN golangci-lint run ./... --out-format "$OUTPUT_FORMAT" @@ -166,7 +178,7 @@ release: # Unfortunately GH does not release a container image for their CLI, see https://github.com/cli/cli/issues/2027 RUN apk add github-cli WORKDIR /release_artifacts - COPY --platform=linux/amd64 --platform=linux/arm64 --platform=darwin/arm64 +tarball/* . + COPY (+tarball/* --GOOS=linux --GOARCH=amd64) (+tarball/* --GOOS=linux --GOARCH=arm64) (+tarball/* --GOOS=darwin --GOARCH=arm64) . COPY CHANGELOG.md /CHANGELOG.md # Run commands with "--push" set will only run when the "--push" arg is provided via CLI RUN --push gh release create --draft --verify-tag --notes-file "/CHANGELOG.md" --prerelease "$GIT_TAG" "./*" diff --git a/collector.go b/collector.go index 98bd2ca..cf10e0c 100644 --- a/collector.go +++ b/collector.go @@ -9,7 +9,7 @@ import ( "time" "github.com/bradleyfalzon/ghinstallation/v2" - "github.com/google/go-github/v59/github" + "github.com/google/go-github/v60/github" "github.com/gravitational/trace" "github.com/hashicorp/go-retryablehttp" "github.com/prometheus/client_golang/prometheus" diff --git a/go.mod b/go.mod index a7a8798..694239f 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.0 require ( github.com/alecthomas/kong v0.8.1 github.com/bradleyfalzon/ghinstallation/v2 v2.9.0 - github.com/google/go-github/v59 v59.0.0 + github.com/google/go-github/v60 v60.0.0 github.com/gravitational/trace v1.3.1 github.com/hashicorp/go-retryablehttp v0.7.5 github.com/prometheus/client_golang v1.19.0 @@ -18,14 +18,14 @@ require ( github.com/google/go-github/v57 v57.0.0 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/jonboulle/clockwork v0.2.2 // indirect - github.com/prometheus/client_model v0.5.0 // indirect - github.com/prometheus/common v0.48.0 // indirect + github.com/jonboulle/clockwork v0.4.0 // indirect + github.com/prometheus/client_model v0.6.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect - github.com/sirupsen/logrus v1.8.1 // indirect - golang.org/x/crypto v0.18.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sys v0.16.0 // indirect - golang.org/x/term v0.16.0 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + golang.org/x/crypto v0.20.0 // indirect + golang.org/x/net v0.21.0 // indirect + golang.org/x/sys v0.17.0 // indirect + golang.org/x/term v0.17.0 // indirect google.golang.org/protobuf v1.32.0 // indirect ) diff --git a/go.sum b/go.sum index a06697a..5db12d6 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,8 @@ 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/v57 v57.0.0 h1:L+Y3UPTY8ALM8x+TV0lg+IEBI+upibemtBD8Q9u7zHs= github.com/google/go-github/v57 v57.0.0/go.mod h1:s0omdnye0hvK/ecLvpsGfJMiRt85PimQh4oygmLIxHw= -github.com/google/go-github/v59 v59.0.0 h1:7h6bgpF5as0YQLLkEiVqpgtJqjimMYhBkD4jT5aN3VA= -github.com/google/go-github/v59 v59.0.0/go.mod h1:rJU4R0rQHFVFDOkqGWxfLNo6vEk4dv40oDjhV/gH6wM= +github.com/google/go-github/v60 v60.0.0 h1:oLG98PsLauFvvu4D/YPxq374jhSxFYdzQGNCyONLfn8= +github.com/google/go-github/v60 v60.0.0/go.mod h1:ByhX2dP9XT9o/ll2yXAu2VD8l5eNVg8hD4Cr0S/LmQk= 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/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -74,22 +74,24 @@ github.com/hashicorp/go-retryablehttp v0.7.5 h1:bJj+Pj19UZMIweq/iie+1u5YCdGrnxCT github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= -github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= +github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4= +github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc= 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/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= -github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= -github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE= -github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= +github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= @@ -101,8 +103,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk 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.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -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/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= +golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= 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= @@ -121,8 +123,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -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/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -139,17 +141,18 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/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-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/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/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.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/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= +golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= 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.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= diff --git a/hack-todo-remove/go-github.patch b/hack-todo-remove/go-github.patch new file mode 100644 index 0000000..d10e530 --- /dev/null +++ b/hack-todo-remove/go-github.patch @@ -0,0 +1,12 @@ +diff --git a/github/actions_workflow_runs.go b/github/actions_workflow_runs.go +index bc7afe9..bba69e7 100644 +--- a/github/actions_workflow_runs.go ++++ b/github/actions_workflow_runs.go +@@ -19,6 +19,7 @@ type WorkflowRun struct { + NodeID *string `json:"node_id,omitempty"` + HeadBranch *string `json:"head_branch,omitempty"` + HeadSHA *string `json:"head_sha,omitempty"` ++ Path *string `json:"path",omitempty"` + RunNumber *int `json:"run_number,omitempty"` + RunAttempt *int `json:"run_attempt,omitempty"` + Event *string `json:"event,omitempty"` diff --git a/helm/Chart.yaml b/helm/Chart.yaml new file mode 100644 index 0000000..354f800 --- /dev/null +++ b/helm/Chart.yaml @@ -0,0 +1,22 @@ +--- +apiVersion: v2 +name: gha-exporter +description: GitHub Actions metrics exporter for Prometheus +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.0.0-dev +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "0.0.0-dev" diff --git a/main.go b/main.go index adb7173..60047ea 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,11 @@ import ( "github.com/alecthomas/kong" ) +var ( + // Not yet used + Version = "0.0.0-dev" +) + type CLI struct { AppID int64 `required:"" env:"GHA_APP_ID" help:"GitHub App ID of application to authenticate as"` AppKey string `required:"" env:"GHA_APP_KEY" help:"Private key of GitHub App for the App ID"` From 96a8d81b01f3f19d9d5d0480ab3decfc63a15f61 Mon Sep 17 00:00:00 2001 From: Fred Heinecke Date: Wed, 6 Mar 2024 13:51:00 -0600 Subject: [PATCH 5/5] Add CD push perms --- .github/workflows/cd.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index d112d56..8f1e58f 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -10,6 +10,9 @@ concurrency: jobs: cut-release: runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - name: Validate the release tag env: