Skip to content

Commit

Permalink
Merge branch 'master' into add-git-lfs-support
Browse files Browse the repository at this point in the history
  • Loading branch information
rickardl authored Oct 20, 2020
2 parents c161a2d + e371a05 commit fae4c1d
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 30 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on: [push, pull_request]
name: Test
jobs:
test:
strategy:
matrix:
go-version: [1.14.x, 1.15.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Install Task
run: curl -sL https://taskfile.dev/install.sh | sh
- name: Run CI Task
run: ./bin/task ci

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ A version is represented as follows:
- `pr`: The pull request number.
- `commit`: The commit SHA.
- `committed`: Timestamp of when the commit was committed. Used to filter subsequent checks.
- `approved_review_count`: The number of reviews approving of the PR.

If several commits are pushed to a given PR at the same time, the last commit will be the new version.

Expand Down
54 changes: 30 additions & 24 deletions in_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ func TestGet(t *testing.T) {
AccessToken: "oauthtoken",
},
version: resource.Version{
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
ApprovedReviewCount: "0",
},
parameters: resource.GetParameters{},
pullRequest: createTestPR(1, "master", false, false, 0, nil),
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`,
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","approved_review_count":"0"}`,
metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"[email protected]"}]`,
},
{
Expand All @@ -52,13 +53,14 @@ func TestGet(t *testing.T) {
GitCryptKey: "gitcryptkey",
},
version: resource.Version{
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
ApprovedReviewCount: "0",
},
parameters: resource.GetParameters{},
pullRequest: createTestPR(1, "master", false, false, 0, nil),
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`,
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","approved_review_count":"0"}`,
metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"[email protected]"}]`,
},
{
Expand All @@ -68,15 +70,16 @@ func TestGet(t *testing.T) {
AccessToken: "oauthtoken",
},
version: resource.Version{
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
ApprovedReviewCount: "0",
},
parameters: resource.GetParameters{
IntegrationTool: "rebase",
},
pullRequest: createTestPR(1, "master", false, false, 0, nil),
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`,
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","approved_review_count":"0"}`,
metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"[email protected]"}]`,
},
{
Expand All @@ -86,15 +89,16 @@ func TestGet(t *testing.T) {
AccessToken: "oauthtoken",
},
version: resource.Version{
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
ApprovedReviewCount: "0",
},
parameters: resource.GetParameters{
IntegrationTool: "checkout",
},
pullRequest: createTestPR(1, "master", false, false, 0, nil),
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`,
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","approved_review_count":"0"}`,
metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"[email protected]"}]`,
},
{
Expand All @@ -104,15 +108,16 @@ func TestGet(t *testing.T) {
AccessToken: "oauthtoken",
},
version: resource.Version{
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
ApprovedReviewCount: "0",
},
parameters: resource.GetParameters{
GitDepth: 2,
},
pullRequest: createTestPR(1, "master", false, false, 0, nil),
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`,
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","approved_review_count":"0"}`,
metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"[email protected]"}]`,
},
{
Expand All @@ -122,9 +127,10 @@ func TestGet(t *testing.T) {
AccessToken: "oauthtoken",
},
version: resource.Version{
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
PR: "pr1",
Commit: "commit1",
CommittedDate: time.Time{},
ApprovedReviewCount: "0",
},
parameters: resource.GetParameters{
ListChangedFiles: true,
Expand All @@ -138,7 +144,7 @@ func TestGet(t *testing.T) {
Path: "Other.md",
},
},
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`,
versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z","approved_review_count":"0"}`,
metadataString: `[{"name":"pr","value":"1"},{"name":"title","value":"pr1 title"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"[email protected]"}]`,
filesString: "README.md\nOther.md\n",
},
Expand Down
14 changes: 8 additions & 6 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,19 @@ type MetadataField struct {

// Version communicated with Concourse.
type Version struct {
PR string `json:"pr"`
Commit string `json:"commit"`
CommittedDate time.Time `json:"committed,omitempty"`
PR string `json:"pr"`
Commit string `json:"commit"`
CommittedDate time.Time `json:"committed,omitempty"`
ApprovedReviewCount string `json:"approved_review_count"`
}

// NewVersion constructs a new Version.
func NewVersion(p *PullRequest) Version {
return Version{
PR: strconv.Itoa(p.Number),
Commit: p.Tip.OID,
CommittedDate: p.Tip.CommittedDate.Time,
PR: strconv.Itoa(p.Number),
Commit: p.Tip.OID,
CommittedDate: p.Tip.CommittedDate.Time,
ApprovedReviewCount: strconv.Itoa(p.ApprovedReviewCount),
}
}

Expand Down

0 comments on commit fae4c1d

Please sign in to comment.