pix4d / cogito Goto Github PK
View Code? Open in Web Editor NEWConcourse resource for GitHub Commit Status and Google Chat notifications
License: MIT License
Concourse resource for GitHub Commit Status and Google Chat notifications
License: MIT License
Currently we send to the chat sink:
2023-07-24 09:04:37 UTC
pipeline foo-bar
job oo-bar-local-tests/1301
state ๐ด failure
commit 123456 (repo: example/repo)
It would be nice to send also the commit author and message (no matter the state):
2023-07-24 09:04:37 UTC
pipeline foo-bar
job oo-bar-local-tests/1301
state ๐ด failure
commit 123456 (repo: example/repo)
Same for the logging.
What we have:
[INFO] cogito: This is the Cogito GitHub status resource. Tag: 0.10.1, commit: 05c92db, build date: 2023-05-31
[INFO] cogito.put.ghCommitStatus: GitHub HTTP request: attempt=1 max=3
[INFO] cogito.put.ghCommitStatus: commit status posted successfully: state=pending git-ref=123456
What we could have
[INFO] cogito: This is the Cogito GitHub status resource. Tag: 0.10.1, commit: 05c92db, build date: 2023-05-31
[INFO] cogito.put.ghCommitStatus: Processing commit git-ref=123456 author=johnny.stecchino comment="foo: add bar"
[INFO] cogito.put.ghCommitStatus: GitHub HTTP request: attempt=1 max=3
[INFO] cogito.put.ghCommitStatus: commit status posted successfully: state=pending git-ref=123456
With the default log level, in case of retry, Cogito prints:
[INFO] cogito.put.ghCommitStatus: GitHub HTTP request: attempt=1 max=3
[INFO] cogito.put.ghCommitStatus: Sleeping for: time=4m47s
At line 2, the user can infer that the attempt at line 1 failed, but the reason (the HTTP status code) is not printed.
Instead, we should print the reason, because it would make easier to troubleshoot if needed.
Does this line mean that for Enterprise Github (not github.com) will now work?
Line 378 in 50a9d96
fetching pix4d/cogito@sha256:cef4adfe17e9ee5f7c16a4094e435d88857f663f080507dcb6b61e7390b52852
29291e31a76a [==========================================] 2.7MiB/2.7MiB
ff9cc595764e [======================================] 274.7KiB/274.7KiB
60eff1c2ce14 [==============================================] 116b/116b
507e2309724c [==========================================] 5.9MiB/5.9MiB
This is the Cogito GitHub status resource. Tag: 0.6.0, commit: 5d34381a18, build date: 2021-08-26
resource source configuration and git repository are incompatible.
Git remote: "https://notgithub.com/xxx/xxx.git"
Resource config: host: github.com, owner: "xxx", repo: "xxx". wrong git remote
While having configured cloned repo via git-multibranch-resource
I'm getting following error:
This is the Cogito GitHub status resource. Tag: <no value>, commit: 2c6159c, build date: 2019-11-14
.git/config: remote: url: ssh://[email protected]:22/projectname/reponame.git: invalid git URL
Dear Cogito maintainers,
Any chance you'd add a dry run configuration to your pipeline? The idea there is if a pipeline fails rather than alerting as it would do in the staging env, the pipeline step might no-op and alert the user that no request had gone out. We'd love such a feature for our staging concourse environment. I'd PR if you're open to it, or accept suggested implementations if there's something I'm not seeing in your readme.
Thanks!
Eli
We detect the situation correctly, we calculate the correct time to sleep, we log that we will sleep but actually we do NOT sleep, thus we consume the 3 attempts one after the other and finally fail:
[INFO] cogito: This is the Cogito GitHub status resource. Tag: 0.10.2, commit: d8221ad, build date: 2023-07-28
[INFO] cogito.put.gChat: not sending to chat: reason="feature not enabled"
[INFO] cogito.put.ghCommitStatus: GitHub HTTP request: attempt=1 max=3
[INFO] cogito.put.ghCommitStatus: Sleeping for: duration=7m42s reason="rate limited, should retry"
[INFO] cogito.put.ghCommitStatus: GitHub HTTP request: attempt=2 max=3
[INFO] cogito.put.ghCommitStatus: Sleeping for: duration=7m42s reason="rate limited, should retry"
[INFO] cogito.put.ghCommitStatus: GitHub HTTP request: attempt=3 max=3
[INFO] cogito.put.ghCommitStatus: Sleeping for: duration=7m42s reason="rate limited, should retry"
cogito: error: put: failed to add state "pending" for commit XXX: 403 Forbidden
Body: {"message":"API rate limit exceeded for user ID YYY.","documentation_url":"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"}
Hint: Rate limited but the wait time to reset would be longer than 15m0s (MaxSleepTime)
This has been introduced by #128
๐ฟ
GH App Installations have a much larger API quota compared with user PATs.
Would be nice if this supported natively authing as a GH app installation and using that access token.
Regular pipelines Url
https://concourse.example.net/teams/straw-man-github_status/pipelines/topic/jobs/initialize/builds/40
Instanced Pipeline URL
https://flying-pig-dev.aue1f.saasure.net/teams/starfall-straw-man-github_status/pipelines/topic/jobs/initialize/builds/40?vars.branch=%22added_hooks%22
Currently the details link does not allow for any info to be passed
Apologies in advance if this is not the right place to ask questions, but I know no other options.
Within the cogito image, I'm trying to run the /opt/resource/out
command by passing on a json data manually through STDIN for PUT
. What is the exact format of the data that is required? I keep encountering some argument error from the json data. The task file looks like so:
---
platform: linux
image_resource:
type: registry-image
source:
repository: ((redacted))/cogito-gh-status-resource
tag: ((redacted))
username: ((redacted))
password: ((redacted))
inputs:
- name: git-source
run:
path: sh
args:
- -exc
- |
/opt/resource/out . < git-source/instana-tasks-resource/ci/request-data/request-data-populated.json
Right now the resource requires that you put all tasks that affect the same job status together in the same job within a pipeline because of the choice to make github "context" === BUILD_JOB_NAME. For reference, I believe this is where we set it. https://github.com/Pix4D/cogito/blob/master/resource/resource.go#L213-L215
I'd like to propose allowing users to pass in an optional parameter "context" that overrides the job name as the CONTEXT arg if not equal to "". Any objections or "gotchas" you can think of? Any reason you'd rather not have this property be configurable?
I'm happy to PR this if you think the feature has a chance.
Hello!
Thanks for making this resource, I'm using it a ton and it's working great.
I'd love to be able to do something like
put: my-commit-status
params:
...
description: "my custom description"
That field would be optional, and if not set, would default to the current behavior of "Build " + buildN
.
I'm willing to try to PR that in, if there's interest.
Thanks!
We use Instanced Pipelines, and the build links we get for them in GitHub don't appear to work. Here is an example of a link from cogito:
https://concourse/teams/teamname/pipelines/pipeline_name/jobs/job_name/builds/5?vars=%7B%22DEPLOYMENTID%22%3A%222%22%2C%22DESC%22%3A%22Daily+tests+for+Preprod+2%22%2C%22TITLE%22%3A%22PREPROD+TESTS%22%7D
an example of a working link for the above build
https://concourse/teams/teamname/pipelines/pipeline_name/jobs/job_name/builds/5?vars.DEPLOYMENTID=%222%22&vars.DESC=%22Daily%20tests%20for%20Preprod%202%22&vars.TITLE=%22PREPROD%20TESTS%22
Hello,
As I was going through CONTRIBUTING.md to run the integration tests, and I modified the tasks.yml to input my own values from gopass into task test:env -- task test:all
. I was wondering if it would be possible to open a PR to merge these changes.
Ex:
+++ b/Taskfile.yml
@@ -48,13 +48,16 @@ tasks:
cmds:
- '{{ .CLI_ARGS }}'
env: &test-env
- COGITO_TEST_COMMIT_SHA: '{{default "32e4b4f91bb8de500f6a7aa2011f93c3f322381c" .COGITO_TEST_COMMIT_SHA}}'
+ COGITO_TEST_COMMIT_SHA:
+ sh: 'echo -n {{default "$(gopass show cogito/test_commit_sha)" .COGITO_TEST_COMMIT_SHA}}'
COGITO_TEST_OAUTH_TOKEN:
- sh: 'echo {{default "$(gopass show cogito/test_oauth_token)" .COGITO_TEST_OAUTH_TOKEN}}'
- COGITO_TEST_REPO_NAME: '{{default "cogito-test-read-write" .COGITO_TEST_REPO_NAME}}'
- COGITO_TEST_REPO_OWNER: '{{default "pix4d" .COGITO_TEST_REPO_OWNER}}'
+ sh: 'echo -n {{default "$(gopass show cogito/test_oauth_token)" .COGITO_TEST_OAUTH_TOKEN}}'
+ COGITO_TEST_REPO_NAME:
+ sh: 'echo -n {{default "$(gopass show cogito/test_repo_name)" .COGITO_TEST_REPO_NAME}}'
+ COGITO_TEST_REPO_OWNER:
+ sh: 'echo -n {{default "$(gopass show cogito/test_repo_owner)" .COGITO_TEST_REPO_OWNER}}'
COGITO_TEST_GCHAT_HOOK:
- sh: 'echo {{default "$(gopass show cogito/test_gchat_webhook)" .COGITO_TEST_GCHAT_HOOK}}'
+ sh: 'echo -n {{default "$(gopass show cogito/test_gchat_webhook)" .COGITO_TEST_GCHAT_HOOK}}'
--- a/github/commitstatus_test.go
+++ b/github/commitstatus_test.go
@@ -168,34 +168,34 @@ func TestGitHubStatusFailureIntegration(t *testing.T) {
{
name: "bad token: Unauthorized",
token: "bad-token",
- wantErr: `failed to add state "success" for commit 32e4b4f: 401 Unauthorized
+ wantErr: fmt.Sprintf(`failed to add state "success" for commit %s: 401 Unauthorized
Body: {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest"}
Hint: Either wrong credentials or PAT expired (check your email for expiration notice)
-Action: POST https://api.github.com/repos/pix4d/cogito-test-read-write/statuses/32e4b4f91bb8de500f6a7aa2011f93c3f322381c
-OAuth: X-Accepted-Oauth-Scopes: [], X-Oauth-Scopes: []`,
+Action: POST https://api.github.com/repos/%s/%s/statuses/%s
+OAuth: X-Accepted-Oauth-Scopes: [], X-Oauth-Scopes: []`, cfg.SHA[0:7], cfg.Owner, cfg.Repo, cfg.SHA),```
(If this was already possible to do, but I ran the commands incorrectly, please let me know, thanks!)
Just observed in our deployment:
[INFO] cogito: This is the Cogito GitHub status resource. Tag: 0.10.1, commit: 05c92db, build date: 2023-05-31
[INFO] cogito.put.ghCommitStatus: GitHub HTTP request: attempt=1 max=3
[INFO] cogito.put.ghCommitStatus: Sleeping for: time=4m47s
[INFO] cogito.put.ghCommitStatus: GitHub HTTP request: attempt=2 max=3
cogito: error: put: internal error: unexpected: negative sleep time: 0s
See also #123.
I'm trying out concourse and setting up for a monorepo/multi-project workflow, and it's easy to end up having test/validate/build jobs in multiple pipelines for the same repository, etc. I'm wondering what your stance is on prefixing the pipeline name to the context, if the information is available? As an example, instead of just test
for the test
job it'd be for example publish-docker-image/test
if this test is part of the publishing pipeline.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.