Skip to content

Commit

Permalink
Use githubgen tool from go-build-tools (#37412)
Browse files Browse the repository at this point in the history
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
- This PR
- switches over all usages of the githubgen tool to the new tool
location by adjusting make targets and the check-code-owners pipeline
  - introduces the new githubgen tool at its latest v0.17.0 version 
- adds `make gengithub` to the commands to run in the contribution guide
- re-generates the codeowners and allowlist files using the new
githubgen tool (only cosmetic changes)

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Part of
#37294


<!--Please delete paragraphs that you did not use before submitting.-->

---------

Signed-off-by: Moritz Wiesinger <[email protected]>
  • Loading branch information
mowies authored Jan 23, 2025
1 parent 4542bbf commit b731208
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 43 deletions.
27 changes: 27 additions & 0 deletions .chloggen/mowies-deprecate-githubgen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: githubgen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Switch over all usages of githubgen to the new tool location, since the old tool was deprecated

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [37412, 37294]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
6 changes: 1 addition & 5 deletions .github/ALLOWLIST
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# Code generated by githubgen. DO NOT EDIT.
#####################################################
#
# List of components in OpenTelemetry Collector Contrib
# List of components
# waiting on owners to be assigned
#
#####################################################
#
# Learn about membership in OpenTelemetry community:
# https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md
#
#
# Learn about CODEOWNERS file format:
# https://help.github.com/en/articles/about-code-owners
#
Expand Down
14 changes: 6 additions & 8 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Code generated by githubgen. DO NOT EDIT.
#####################################################
#
# List of codeowners for OpenTelemetry Collector Contrib
# List of codeowners
#
#####################################################
#
# Learn about membership in OpenTelemetry community:
# https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md
#
#
# Learn about CODEOWNERS file format:
# https://help.github.com/en/articles/about-code-owners
#
Expand Down Expand Up @@ -317,16 +313,18 @@ testbed/mockdatasenders/mockdatadogagentexporter/ @open-telemetry

#####################################################
#
# List of distribution maintainers for OpenTelemetry Collector Contrib
# List of distribution maintainers
#
#####################################################

reports/distributions/core.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/contrib.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/k8s.yaml @open-telemetry/collector-contrib-approvers

#####################################################
#
## UNMAINTAINED components

#
#####################################################
exporter/kineticaexporter/ @open-telemetry/collector-contrib-approvers
exporter/opensearchexporter/ @open-telemetry/collector-contrib-approvers
extension/observer/ecstaskobserver/ @open-telemetry/collector-contrib-approvers
Expand Down
28 changes: 13 additions & 15 deletions .github/workflows/check-codeowners.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,40 @@ concurrency:
cancel-in-progress: true

jobs:
setup-environment:
check-codeowners:
timeout-minutes: 30
runs-on: ubuntu-24.04
if: ${{ github.actor != 'dependabot[bot]' && github.repository == 'open-telemetry/opentelemetry-collector-contrib' }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: "1.22.8"
cache: false
- name: Cache Go
id: go-cache

- name: Cache Go Tools
id: go-tools-cache
timeout-minutes: 5
uses: actions/cache@v4
with:
path: |
~/go/bin
~/go/pkg/mod
./.tools
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
check-codeowners:
runs-on: ubuntu-24.04
needs: [setup-environment]
steps:
- uses: actions/checkout@v4
- name: Gen githubgen tool
key: go-tools-${{ runner.os }}-${{ hashFiles('internal/tools/go.sum') }}

- name: Install tools
if: github.repository == 'open-telemetry/opentelemetry-collector-contrib' && steps.go-tools-cache.outputs.cache-hit != 'true'
run: |
make githubgen-install
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
make install-tools
- uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
path: pr

- name: Gen CODEOWNERS
run: |
cd pr
GITHUB_TOKEN=${{ secrets.READ_ORG_AND_USER_TOKEN }} githubgen
GITHUB_TOKEN=${{ secrets.READ_ORG_AND_USER_TOKEN }} ./.tools/githubgen codeowners
git diff -s --exit-code || (echo 'Generated code is out of date, please apply this diff and commit the changes in this PR.' && git diff && exit 1)
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ When submitting a component to the community, consider breaking it down into sep
* `make generate`
* `make multimod-verify`
* `make generate-gh-issue-templates`
* `make gengithub`
* `make addlicense`
* **Second PR** should include the concrete implementation of the component. If the
size of this PR is larger than the recommended size consider splitting it in
Expand Down
17 changes: 6 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -310,20 +310,16 @@ generate: install-tools
PATH="$$PWD/.tools:$$PATH" $(MAKE) for-all CMD="$(GOCMD) generate ./..."
$(MAKE) gofmt

.PHONY: githubgen-install
githubgen-install:
cd cmd/githubgen && $(GOCMD) install .

.PHONY: gengithub
gengithub: githubgen-install
githubgen
gengithub: $(GITHUBGEN)
$(GITHUBGEN)

.PHONY: gendistributions
gendistributions: githubgen-install
githubgen distributions
gendistributions: $(GITHUBGEN)
$(GITHUBGEN) distributions

.PHONY: update-codeowners
update-codeowners: gengithub generate
update-codeowners: generate gengithub

FILENAME?=$(shell git branch --show-current)
.PHONY: chlog-new
Expand Down Expand Up @@ -559,8 +555,7 @@ clean:

.PHONY: generate-gh-issue-templates
generate-gh-issue-templates:
cd cmd/githubgen && $(GOCMD) install .
githubgen issue-templates
$(GITHUBGEN) issue-templates

.PHONY: checks
checks:
Expand Down
1 change: 1 addition & 0 deletions Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ MISSPELL_CORRECTION := $(TOOLS_BIN_DIR)/misspell -w
LINT := $(TOOLS_BIN_DIR)/golangci-lint
MULTIMOD := $(TOOLS_BIN_DIR)/multimod
CHLOGGEN := $(TOOLS_BIN_DIR)/chloggen
GITHUBGEN := $(TOOLS_BIN_DIR)/githubgen
GOIMPORTS := $(TOOLS_BIN_DIR)/goimports
PORTO := $(TOOLS_BIN_DIR)/porto
CHECKFILE := $(TOOLS_BIN_DIR)/checkfile
Expand Down
4 changes: 3 additions & 1 deletion cmd/githubgen/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
type: githubgen

status:
stability:
deprecated: []
class: cmd
codeowners:
active: [atoulme]
active: [atoulme]
4 changes: 3 additions & 1 deletion internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
go.opentelemetry.io/build-tools/checkfile v0.16.0
go.opentelemetry.io/build-tools/chloggen v0.16.0
go.opentelemetry.io/build-tools/crosslink v0.16.0
go.opentelemetry.io/build-tools/githubgen v0.17.0
go.opentelemetry.io/build-tools/issuegenerator v0.16.0
go.opentelemetry.io/build-tools/multimod v0.16.0
go.opentelemetry.io/collector/cmd/builder v0.118.1-0.20250121185328-fbefb22cc2b3
Expand Down Expand Up @@ -107,7 +108,8 @@ require (
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/go-github/v66 v66.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gordonklaus/ineffassign v0.1.0 // indirect
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
Expand Down
8 changes: 6 additions & 2 deletions internal/tools/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
_ "go.opentelemetry.io/build-tools/checkfile"
_ "go.opentelemetry.io/build-tools/chloggen"
_ "go.opentelemetry.io/build-tools/crosslink"
_ "go.opentelemetry.io/build-tools/githubgen"
_ "go.opentelemetry.io/build-tools/issuegenerator"
_ "go.opentelemetry.io/build-tools/multimod"
_ "go.opentelemetry.io/collector/cmd/builder"
Expand Down

0 comments on commit b731208

Please sign in to comment.