You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
goal was to make version selection more robust, easier
to test and reduce the chance legitimate versions
are missed by concourse
* add support for schema previews
* add support to trigger pr via comment
* convert files to use graphql api
* logging
* use glob path filtering
* decouple internal PullRequest from GitHub PullRequestObject
* add env var support to context param
* add head short ref to metadata
|`repository`| Yes |`itsdalmo/test-repository`| The repository to target. |
25
-
|`access_token`| Yes || A Github Access Token with repository access (required for setting status on commits). N.B. If you want github-pr-resource to work with a private repository. Set `repo:full` permissions on the access token you create on GitHub. If it is a public repository, `repo:status` is enough. |
26
-
|`v3_endpoint`| No |`https://api.github.com`| Endpoint to use for the V3 Github API (Restful). |
27
-
|`v4_endpoint`| No |`https://api.github.com/graphql`| Endpoint to use for the V4 Github API (Graphql). |
28
-
|`paths`| No |`terraform/*/*.tf`| Only produce new versions if the PR includes changes to files that match one or more glob patterns or prefixes. |
29
-
|`ignore_paths`| No |`.ci/`| Inverse of the above. Pattern syntax is documented in [filepath.Match](https://golang.org/pkg/path/filepath/#Match), or a path prefix can be specified (e.g. `.ci/` will match everything in the `.ci` directory). |
30
-
|`disable_ci_skip`| No |`true`| Disable ability to skip builds with `[ci skip]` and `[skip ci]` in commit message or pull request title. |
31
-
|`skip_ssl_verification`| No |`true`| Disable SSL/TLS certificate validation on git and API clients. Use with care! |
32
-
|`disable_forks`| No |`true`| Disable triggering of the resource if the pull request's fork repository is different to the configured repository. |
33
-
|`git_crypt_key`| No |`AEdJVENSWVBUS0VZAAAAA...`| Base64 encoded git-crypt key. Setting this will unlock / decrypt the repository with git-crypt. To get the key simply execute `git-crypt export-key -- - | base64` in an encrypted repository. |
34
-
|`base_branch`| No |`master`| Name of a branch. The pipeline will only trigger on pull requests against the specified branch. |
|`repository`| Yes |`itsdalmo/test-repository`| The repository to target |
25
+
|`access_token`| Yes || A Github Access Token with repository access (required for setting status on commits). N.B. If you want github-pr-resource to work with a private repository. Set `repo:full` permissions on the access token you create on GitHub. If it is a public repository, `repo:status` is enough |
26
+
|`v3_endpoint`| NO |`https://api.github.com`| Endpoint to use for the V3 Github API (Restful) |
27
+
|`v4_endpoint`| NO |`https://api.github.com/graphql`| Endpoint to use for the V4 Github API (Graphql) |
28
+
|`paths`| No |`terraform/*/*.tf`| Only produce new versions if the PR includes changes to files that match one or more glob patterns or prefixes |
29
+
|`ignore_paths`| No |`.ci/`| Inverse of the above. Pattern syntax is documented in [filepath.Match](https://golang.org/pkg/path/filepath/#Match), or a path prefix can be specified (e.g. `.ci/` will match everything in the `.ci` directory) |
30
+
|`disable_ci_skip`| No |`true`| Disable ability to skip builds with `[ci skip]` and `[skip ci]` in commit message or pull request title |
31
+
|`skip_ssl_verification`| No |`true`| Disable SSL/TLS certificate validation on git and API clients. Use with care! |
32
+
|`disable_forks`| No |`true`| Disable triggering of the resource if the pull request's fork repository is different to the configured repository |
33
+
|`git_crypt_key`| No |`AEdJVENSWVBUS0VZAAAAA...`| Base64 encoded git-crypt key. Setting this will unlock / decrypt the repository with git-crypt. To get the key simply execute `git-crypt export-key -- - | base64` in an encrypted repository. |
34
+
|`base_branch`| No |`master`| Name of a branch. The pipeline will only trigger on pull requests against the specified branch |
35
+
|`preview_schema`| No |`true`| if enabled, an `Accept: application/vnd.github.starfire-preview+json` header will be appended to each request to enable preview schema's that are hidden behind a feature flag on GitHub |
35
36
36
37
Notes:
37
38
- If `v3_endpoint` is set, `v4_endpoint` must also be set (and the other way around).
@@ -45,13 +46,46 @@ Notes:
45
46
Produces new versions for all commits (after the last version) ordered by the committed date.
46
47
A version is represented as follows:
47
48
48
-
-`pr`: The pull request number.
49
-
-`commit`: The commit SHA.
50
-
-`committed`: Timestamp of when the commit was committed. Used to filter subsequent checks.
49
+
-`pr`: The pull request number
50
+
-`commit`: The commit SHA
51
+
-`updated`: Timestamp of when the pull request was last updated at the time of the check
51
52
52
-
If several commits are pushed to a given PR at the same time, the last commit will be the new version.
53
+
If several commits are pushed to a given PR at the same time, the PR with the latest updated at will be the newest version.
54
+
55
+
#### search
56
+
57
+
The GraphQL search for pull requests uses the `Search` endpoint and follows the following pattern:
Which means that we want to search for only OPEN PULL REQUESTS that have been UPDATED since the latest `updated` timestamp of the last check. To test this query, you can simply use the search box in the navigation of github.com.
62
+
63
+
Then, we use the [PullRequestTimelineItemsConnection](https://developer.github.com/v4/object/pullrequesttimelineitemsconnection/) to fetch all commits / events on the PRs timeline since the latest `updated` timestamp of the last check. This allows us to iterate over the pull requests and filter them as is covered in the next section.
64
+
65
+
#### filters
66
+
67
+
There are many ways by which this resource filters pull requests and each filter is a function in the `filter.go` file within the `pullrequest` package. This makes it very easy to test the functionality of each filter. There are two types:
68
+
69
+
* negative filters which when return true, the pull request should be excluded (skipped) from versions
70
+
* positive filters which when return true, the pull request should be included from versions
71
+
72
+
Current negative filters:
73
+
74
+
*`pullrequest.SkipCI` which will exclude PRs containing `[skip ci|ci skip]` in the PR Title / Message
75
+
*`pullrequest.BaseBranch` which will exclude PRs where the base branch (e.g. `master`) does not match the source configuration
76
+
*`pullrequest.Fork` which will exclude PRs from forks when `disable_forks` is configured true
77
+
78
+
Current positive filters:
79
+
*`pullrequest.Created` which will include PRs with `Created == Updated` OR `Created > HeadRef.Commited | Authored | Pushed`
80
+
*`pullrequest.BaseRefChanged` which will include PRs where a [BaseRefChanged](https://developer.github.com/v4/object/baserefchangedevent/) occurred
81
+
*`pullrequest.BaseRefForcePushed` which will include PRs where a [BaseRefForcePushed](https://developer.github.com/v4/object/baserefforcepushedevent) occurred
82
+
*`pullrequest.HeadRefForcePushed` which will include PRs where a [HeadRefForcePushed](https://developer.github.com/v4/object/headrefforcepushedevent) occurred
83
+
*`pullrequest.Reopened` which will include PRs where a [BaseRefChanged](https://developer.github.com/v4/object/reopenedevent) occurred
84
+
*`pullrequest.BuildCI` which will include PRs with a new comment containing `[build ci|ci build]`
85
+
*`pullrequest.NewCommits` which will include PRs with a new commit since the last `updated` timestamp of the last check
53
86
54
87
**Note on webhooks:**
88
+
55
89
This resource does not implement any caching, so it should work well with webhooks (should be subscribed to `push` and `pull_request` events).
56
90
One thing to keep in mind however, is that pull requests that are opened from a fork and commits to said fork will not
57
91
generate notifications over the webhook. So if you have a repository with little traffic and expect pull requests from forks,
@@ -77,7 +111,7 @@ requested version and the metadata emitted by `get` are available to your tasks
77
111
-`.git/resource/changed_files` (if enabled by `list_changed_files`)
78
112
79
113
The information in `metadata.json` is also available as individual files in the `.git/resource` directory, e.g. the `base_sha`
80
-
is available as `.git/resource/base_sha`. For a complete list of available (individual) metadata files, please check the code
114
+
is available as `.git/resource/base_sha`. For a complete list of available (individual) metadata files, please check the code
0 commit comments