-
Notifications
You must be signed in to change notification settings - Fork 0
feat: support PGO file #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Changelog | ||
|
|
||
| ## 0.1.0 | ||
|
|
||
| * Init policy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| authors: | ||
| - Victor Martinez <[email protected]> | ||
|
|
||
| url: "https://github.com/elastic/oblt-updatecli-policies/" | ||
| changelog: "https://github.com/elastic/oblt-updatecli-policies/tree/main/updatecli/policies/apm-managed-service/pgo/CHANGELOG.md" | ||
| documentation: "https://github.com/elastic/oblt-updatecli-policies/tree/main/updatecli/policies/apm-managed-service/pgo/README.md" | ||
| source: "https://github.com/elastic/oblt-updatecli-policies/tree/main/updatecli/policies/apm-managed-service/pgo/" | ||
| version: 0.1.0 | ||
| vendor: Elastic Project | ||
|
|
||
| licenses: | ||
| - "Apache-2.0 license" | ||
|
|
||
| description: | | ||
| PGO build in MIS update policy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # README | ||
|
|
||
| This policy updates the PGO file defined in `elastic/apm-managed-service` |
12 changes: 12 additions & 0 deletions
12
updatecli/policies/apm-managed-service/pgo/testdata/values.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| scm: | ||
| enabled: true | ||
| owner: elastic | ||
| repository: oblt-updatecli-policies | ||
| username: obltmachine | ||
| branch: main | ||
| commitusingapi: true | ||
|
|
||
| # use one existing file until the pgo file is in the repository. | ||
| pgo_file: pgo.log | ||
| pgo_target_path: ./tests/apm-managed-service/pgo | ||
| pgo_source_repo: observability-robots-playground |
99 changes: 99 additions & 0 deletions
99
updatecli/policies/apm-managed-service/pgo/updatecli.d/default.tpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| --- | ||
| # Helpers | ||
| # {{ $GitHubRepositoryList := env "GITHUB_REPOSITORY" | split "/"}} | ||
| # {{ $GitHubPAT := env "GITHUB_TOKEN"}} | ||
| # {{ $GitHubUsername := env "GITHUB_ACTOR"}} | ||
|
|
||
| name: '{{ .name }}' | ||
| pipelineid: '{{ .pipelineid }}' | ||
|
|
||
| sources: | ||
| sha: | ||
| kind: shell | ||
| spec: | ||
| command: gh api /repos/{{ default $GitHubRepositoryList._0 .scm.owner }}/{{ .pgo_source_repo}}/commits/main --jq '.sha' | ||
| environments: | ||
| - name: GITHUB_TOKEN | ||
| - name: PATH | ||
| pull_request: | ||
| kind: shell | ||
| dependson: | ||
| - sha | ||
| spec: | ||
| command: gh api /repos/{{ default $GitHubRepositoryList._0 .scm.owner }}/{{ .pgo_source_repo}}/commits/{{ source "sha" }}/pulls --jq '.[].html_url' | ||
| environments: | ||
| - name: GITHUB_TOKEN | ||
| - name: PATH | ||
| pgo-file: | ||
| kind: shell | ||
| scmid: apm-managed-service | ||
| dependson: | ||
| - sha | ||
| spec: | ||
| command: tar cvzf {{ requiredEnv "GITHUB_WORKSPACE" }}/pgo.tgz {{ .pgo_file }} | ||
| environments: | ||
| - name: PATH | ||
| workdir: "{{ .pgo_source_path }}" | ||
|
|
||
| targets: | ||
| pgo: | ||
| name: PGO file {{ source "sha" }} | ||
| disablesourceinput: true | ||
| kind: shell | ||
| dependson: | ||
| - source#pgo-file | ||
| spec: | ||
| # git diff helps to print what it changed, If it is empty, then updatecli report a success with no changes applied. | ||
| # See https://www.updatecli.io/docs/plugins/resource/shell/#_shell_target | ||
| command: 'tar -xzf {{ requiredEnv "GITHUB_WORKSPACE" }}/pgo.tgz && git --no-pager diff' | ||
| workdir: "{{ .pgo_target_path }}" | ||
| #{{ if or (.scm.enabled) (env "GITHUB_REPOSITORY") }} | ||
| scmid: default | ||
| # {{ end }} | ||
|
|
||
| {{ if or (.scm.enabled) (env "GITHUB_REPOSITORY") }} | ||
| scms: | ||
| default: | ||
| kind: "github" | ||
| spec: | ||
| # Priority set to the environment variable | ||
| user: '{{ default $GitHubUsername .scm.username}}' | ||
| owner: '{{ default $GitHubRepositoryList._0 .scm.owner }}' | ||
| repository: '{{ default $GitHubRepositoryList._1 .scm.repository}}' | ||
| token: '{{ default $GitHubPAT .scm.token }}' | ||
| username: '{{ default $GitHubUsername .scm.username }}' | ||
| branch: '{{ .scm.branch }}' | ||
| #{{ if .scm.commitusingapi }} | ||
| commitusingapi: {{ .scm.commitusingapi }} | ||
| # {{ end }} | ||
|
|
||
| apm-managed-service: | ||
| kind: github | ||
| spec: | ||
| user: '{{ default $GitHubUsername .scm.username }}' | ||
| owner: '{{ default $GitHubRepositoryList._0 .scm.owner }}' | ||
| repository: '{{ .pgo_source_repo }}' | ||
| token: '{{ default $GitHubPAT .scm.token }}' | ||
| username: '{{ default $GitHubUsername .scm.username }}' | ||
| branch: 'main' | ||
|
|
||
| actions: | ||
| default: | ||
| title: '[Automation] Update default.pgo' | ||
| kind: "github/pullrequest" | ||
| scmid: default | ||
| sourceid: sha | ||
| spec: | ||
| automerge: {{ .automerge }} | ||
| labels: | ||
| - dependencies | ||
| description: |- | ||
| ### What | ||
| Update default.pgo automatic sync | ||
|
|
||
| ### Why | ||
| *Changeset* | ||
| * {{ source "pull_request" }} | ||
| * https://github.com/{{ default $GitHubRepositoryList._0 .scm.owner }}/{{ .pgo_source_repo }}/commit/{{ source "sha" }} | ||
|
|
||
| {{ end }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| name: 'automation: update PGO' | ||
| pipelineid: apm-managed-service/pgo | ||
| automerge: false | ||
|
|
||
| pgo_file: default.pgo | ||
| pgo_source_repo: apm-managed-service | ||
| pgo_source_path: ./ | ||
| pgo_target_path: ./ | ||
|
|
||
| scm: | ||
| enabled: false | ||
| # owner: v1v | ||
| # repository: updatecli-demo | ||
| # token: "xxx" | ||
| # username: "v1v-bot" | ||
| # branch: main | ||
| # commitusingapi: false |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For description we actually need something more fancy, we want to print a small diff summary between old version of the PGO file and the new version that is getting raised in the PR. So it's easy to quickly preview what has changed and sanity check the differences. Right now it's done with the
go tool pprofin https://github.com/elastic/apm-managed-service/pull/1365/files#diff-fc41f706e66d7e247dec9daa0e605237c1abcb49144cc0685892d82ab165279bR7, we will need to do something similar here as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use gh api to collect the PR reference, so the PRs in the MIS projects will contain a reference in the PR description. I was thinking we could use the git commit title, but IIUC,
go tool pprofneeds to run for each specific MIS project.Therefore, I need to figure out whether we can use something in the updatecli to run the diff, let me figure out if I can support that.
Do you happen to have two
pgofiles I can use to rungo tool pprofand test if my implementation with the diff works as expected?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here few PGO files from the apm-server
new.pgo.log
old.pgo.log