This repository has been archived by the owner on Dec 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
context improvements #17
Open
christophermancini
wants to merge
9
commits into
dpb587:develop
Choose a base branch
from
christophermancini:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
679927c
context improvements
3db3b69
Temporarily bump the limit to 100 to avoid following cursors
denniskpw e4e29b9
Merge pull request #1 from denniskpw/develop
0efae2c
Add multi-page status results support
23bf372
Identity function from jq should not change the output
denniskpw 320683e
Alternative method for combining statuses array across multiple queries
denniskpw 507e2b1
Save inital response so there is an array to append to in future iter…
denniskpw 277f128
Merge pull request #4 from denniskpw/multi_page_status_improvements
mstansberry 39d0cd7
Merge pull request #2 from christophermancini/multi_page_status
mstansberry 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
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM alpine | ||
RUN apk --no-cache add curl ca-certificates gettext \ | ||
&& curl -Ls https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 > /usr/bin/jq && chmod +x /usr/bin/jq | ||
&& curl -Ls https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 > /usr/bin/jq && chmod +x /usr/bin/jq | ||
ADD bin /opt/resource |
This file contains 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,18 @@ | ||
SHELL=/bin/bash | ||
|
||
root_mkfile := $(abspath $(lastword $(MAKEFILE_LIST))) | ||
root_dir := $(dir $(root_mkfile)) | ||
|
||
.PHONY: resource-dev | ||
resource-dev: | ||
@docker run \ | ||
-v $(root_dir):/resource \ | ||
--rm -i -t dpb587/github-status-resource:master \ | ||
/bin/ash | ||
|
||
.PHONY: test | ||
test: | ||
@docker run \ | ||
-v $(root_dir):/resource \ | ||
--rm -i -t dpb587/github-status-resource:master \ | ||
/resource/test/all.sh |
This file contains 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 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 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 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 |
---|---|---|
|
@@ -8,6 +8,7 @@ load_source | |
eval $( jq -r '{ | ||
"params_commit": .params.commit, | ||
"params_state": .params.state, | ||
"params_context": ( .params.context // "" ), | ||
"params_description": ( .params.description // "" ), | ||
"params_description_path": ( .params.description_path // "" ), | ||
"params_target_url": ( .params.target_url // ""), | ||
|
@@ -73,11 +74,16 @@ fi | |
# execute | ||
# | ||
|
||
cntxt="$source_context" | ||
if [[ -n "$params_context" ]] ; then | ||
cntxt="$params_context" | ||
fi | ||
|
||
jq -c -n \ | ||
--arg state "$params_state" \ | ||
--arg target_url "$( echo "$target_url" | buildtpl )" \ | ||
--arg description "$( cat $description_path )" \ | ||
--arg context "$source_context" \ | ||
--arg context "$(echo "$source_base_context/$cntxt" | buildtpl)" \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will help fix #8, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. It should not break status lookups via |
||
'{ | ||
"context": $context, | ||
"description": $description, | ||
|
This file contains 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 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 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 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,89 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
DIR=$( dirname "$0" )/../.. | ||
|
||
echo 'a1b2c3d4e5' > $TMPDIR/commit | ||
|
||
cat <<EOF | nc -l -s 127.0.0.1 -p 9192 > $TMPDIR/http.req-$$ & | ||
HTTP/1.0 200 OK | ||
|
||
{ | ||
"created_at": "2012-07-20T01:19:13Z", | ||
"updated_at": "2012-07-20T02:19:13Z", | ||
"state": "success", | ||
"target_url": "https://ci.example.com/1000/output", | ||
"description": "Build has completed successfully", | ||
"id": 1, | ||
"url": "https://api.github.com/repos/octocat/Hello-World/statuses/1", | ||
"context": "continuous-integration/jenkins", | ||
"creator": { | ||
"login": "octocat", | ||
"id": 1, | ||
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/octocat", | ||
"html_url": "https://github.com/octocat", | ||
"followers_url": "https://api.github.com/users/octocat/followers", | ||
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | ||
"organizations_url": "https://api.github.com/users/octocat/orgs", | ||
"repos_url": "https://api.github.com/users/octocat/repos", | ||
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/octocat/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
} | ||
} | ||
EOF | ||
|
||
BUILD_ID=123 BUILD_JOB_NAME=myjob $DIR/bin/out > $TMPDIR/resource-$$ <<EOF | ||
{ | ||
"params": { | ||
"description": "test-description", | ||
"commit": "$TMPDIR/commit", | ||
"context": "override-context/\$BUILD_JOB_NAME", | ||
"state": "success", | ||
"target_url": "https://ci.example.com/\$BUILD_ID/output" | ||
}, | ||
"source": { | ||
"access_token": "test-token", | ||
"context": "test-context", | ||
"endpoint": "http://127.0.0.1:9192", | ||
"repository": "dpb587/test-repo" | ||
} | ||
} | ||
EOF | ||
|
||
if ! grep -q '^POST /repos/dpb587/test-repo/statuses/a1b2c3d4e5 ' $TMPDIR/http.req-$$ ; then | ||
echo "FAILURE: Invalid HTTP method or URI" | ||
cat $TMPDIR/http.req-$$ | ||
exit 1 | ||
fi | ||
|
||
if ! grep -q '^{"context":"concourse-ci/override-context/myjob","description":"test-description","state":"success","target_url":"https://ci.example.com/123/output"}$' $TMPDIR/http.req-$$ ; then | ||
echo "FAILURE: Unexpected request body" | ||
cat $TMPDIR/http.req-$$ | ||
exit 1 | ||
fi | ||
|
||
if ! grep -q '"version":{"commit":"a1b2c3d4e5","status":"1"}' $TMPDIR/resource-$$ ; then | ||
echo "FAILURE: Unexpected version output" | ||
cat $TMPDIR/resource-$$ | ||
exit 1 | ||
fi | ||
|
||
if ! grep -q '{"name":"created_at","value":"2012-07-20T01:19:13Z"}' $TMPDIR/resource-$$ ; then | ||
echo "FAILURE: Unexpected created_at output" | ||
cat $TMPDIR/resource-$$ | ||
exit 1 | ||
fi | ||
|
||
if ! grep -q '{"name":"created_by","value":"octocat"}' $TMPDIR/resource-$$ ; then | ||
echo "FAILURE: Unexpected creator output" | ||
cat $TMPDIR/resource-$$ | ||
exit 1 | ||
fi |
This file contains 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 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 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
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.
Can you describe the use case for this a bit more?
Assuming it makes sense, I don't think it should be defaulted (since it'd be a large, breaking change). So I think this should be adjusted to actually be the full prefix (where the user sets it to
concourse-ci/
if they want this behavior) and then remove the slashes deeper in code.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.
There are a few reasons for this change:
concourse-staging-ci
concourse-ci/dev
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.
W.r.t. breaking change, we could just generate a new
2.2.0
tag for the current version, then merge and generate a3.0.0
tag. By not having theconcourse-ci
be the default, then it would deviate from thegithub-pr-resource
. 🤔