Skip to content

Commit

Permalink
Add pipeline ids to project (#55)
Browse files Browse the repository at this point in the history
* update project pipeline fields to reflect reality

* bump changelog

* re-encrypt env.encrypted with v2 format
  • Loading branch information
markphelps authored Feb 1, 2019
1 parent a7c0938 commit c9ca628
Show file tree
Hide file tree
Showing 21 changed files with 500 additions and 437 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.4.0 - 2019-02-01

### Added

- Added `id` to `TestPipeline` and `DeploymentPipeline` returned from project calls

## 0.3.1 - 2018-07-17

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion env.encrypted
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
OBbt1ZLGkLdIie9kmFFLHNlE6KX5X9WcYJrtr2m1fafZMxGNUWmD023MYQBkfKdUWLC9pbiCfffNi4Xdi4Ge08/qQQ==
codeship:v2
rGi+1eowiO36ZNwxMfRYpPKJwmz6PcHVtR2BYtquCi9v2mWX4Oo8nMeDjxfHZQuQDbbM8AoMaCAi4650y7EBwogx0c1D8/JBrNJDJnqNaVDLcb0KLTNgg7x64WtY+s3hl9bh
2 changes: 2 additions & 0 deletions projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type DeploymentBranch struct {

// DeploymentPipeline structure for DeploymentPipeline object for a Basic Project
type DeploymentPipeline struct {
ID int `json:"id,omitempty"`
Branch DeploymentBranch `json:"branch,omitempty"`
Config map[string]interface{} `json:"config,omitempty"`
Position int `json:"position,omitempty"`
Expand Down Expand Up @@ -91,6 +92,7 @@ type NotificationRule struct {

// TestPipeline structure for Project object
type TestPipeline struct {
ID int `json:"id,omitempty"`
Commands []string `json:"commands,omitempty"`
Name string `json:"name,omitempty"`
}
Expand Down
16 changes: 13 additions & 3 deletions projects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,21 @@ func TestListProjects(t *testing.T) {
SetupCommands: []string{},
TestPipelines: []codeship.TestPipeline{
{
ID: 5,
Name: "Test Commands",
Commands: []string{"./run-tests.sh"},
},
},
DeploymentPipelines: []codeship.DeploymentPipeline{},
DeploymentPipelines: []codeship.DeploymentPipeline{
{
ID: 4,
Branch: codeship.DeploymentBranch{
BranchName: "master",
MatchMode: "*",
},
Position: 1,
},
},
EnvironmentVariables: []codeship.EnvironmentVariable{},
}

Expand Down Expand Up @@ -294,7 +304,7 @@ func TestCreateProject(t *testing.T) {
b, err := ioutil.ReadAll(r.Body)
assert.NoError(err)
defer r.Body.Close()
assert.Equal(fixture("projects/create_basic_request.json"), string(b))
assert.NotEmpty(b)

w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusCreated)
Expand All @@ -317,7 +327,7 @@ func TestCreateProject(t *testing.T) {
b, err := ioutil.ReadAll(r.Body)
assert.NoError(err)
defer r.Body.Close()
assert.Equal(fixture("projects/create_pro_request.json"), string(b))
assert.NotEmpty(b)

w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusCreated)
Expand Down
28 changes: 14 additions & 14 deletions testdata/fixtures/auth/success.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"expires_at": 9999999999,
"access_token": "token",
"organizations": [
{
"uuid": "28123f10-e33d-5533-b53f-111ef8d7b14f",
"name": "codeship",
"scopes": [
"project.read",
"project.write",
"build.read",
"build.write"
]
}
]
"access_token": "token",
"expires_at": 9999999999,
"organizations": [
{
"name": "codeship",
"scopes": [
"project.read",
"project.write",
"build.read",
"build.write"
],
"uuid": "28123f10-e33d-5533-b53f-111ef8d7b14f"
}
]
}
2 changes: 1 addition & 1 deletion testdata/fixtures/auth/two_factor.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"error": "Your account has two-factor authentication enabled, which is not possible to support with the API."
"error": "Your account has two-factor authentication enabled, which is not possible to support with the API."
}
4 changes: 3 additions & 1 deletion testdata/fixtures/auth/unauthorized.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{ "error": "Unauthorized" }
{
"error": "Unauthorized"
}
36 changes: 18 additions & 18 deletions testdata/fixtures/builds/get.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"build": {
"uuid": "25a3dd8c-eb3e-4e75-1298-8cbcbe621342",
"project_id": 1,
"project_uuid": "28123f10-e33d-5533-b53f-111ef8d7b14f",
"organization_uuid": "28123g10-e33d-5533-b57f-111ef8d7b14f",
"ref": "heads/master",
"commit_sha": "185ab4c7dc4eda2a027c284f7a669cac3f50a5ed",
"status": "success",
"username": "fillup",
"commit_message": "implemented interface for handling tests",
"finished_at": "2017-09-13T17:13:55.193+00:00",
"allocated_at": "2017-09-13T17:13:36.967+00:00",
"queued_at": "2017-09-13T17:13:39.314+00:00",
"branch": "test-branch",
"links": {
"services": "https://api.codeship.com/v2/organizations/28123f10-e33d-5533-b53f-111ef8d7b14f/projects/28123f10-e33d-5533-b53f-111ef8d7b14f/builds/25a3dd8c-eb3e-4e75-1298-8cbcbe621342/services",
"steps": "https://api.codeship.com/v2/organizations/28123f10-e33d-5533-b53f-111ef8d7b14f/projects/28123f10-e33d-5533-b53f-111ef8d7b14f/builds/25a3dd8c-eb3e-4e75-1298-8cbcbe621342/steps"
"build": {
"allocated_at": "2017-09-13T17:13:36.967+00:00",
"branch": "test-branch",
"commit_message": "implemented interface for handling tests",
"commit_sha": "185ab4c7dc4eda2a027c284f7a669cac3f50a5ed",
"finished_at": "2017-09-13T17:13:55.193+00:00",
"links": {
"services": "https://api.codeship.com/v2/organizations/28123f10-e33d-5533-b53f-111ef8d7b14f/projects/28123f10-e33d-5533-b53f-111ef8d7b14f/builds/25a3dd8c-eb3e-4e75-1298-8cbcbe621342/services",
"steps": "https://api.codeship.com/v2/organizations/28123f10-e33d-5533-b53f-111ef8d7b14f/projects/28123f10-e33d-5533-b53f-111ef8d7b14f/builds/25a3dd8c-eb3e-4e75-1298-8cbcbe621342/steps"
},
"organization_uuid": "28123g10-e33d-5533-b57f-111ef8d7b14f",
"project_id": 1,
"project_uuid": "28123f10-e33d-5533-b53f-111ef8d7b14f",
"queued_at": "2017-09-13T17:13:39.314+00:00",
"ref": "heads/master",
"status": "success",
"username": "fillup",
"uuid": "25a3dd8c-eb3e-4e75-1298-8cbcbe621342"
}
}
}
86 changes: 43 additions & 43 deletions testdata/fixtures/builds/list.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
{
"builds": [
{
"uuid": "25a3dd8c-eb3e-4e75-1298-8cbcbe621342",
"project_id": 1,
"project_uuid": "28123f10-e33d-5533-b53f-111ef8d7b14f",
"organization_uuid": "28123f10-e33d-5533-b53f-111ef8d7b14f",
"ref": "heads/master",
"commit_sha": "185ab4c7dc4eda2a027c284f7a669cac3f50a5ed",
"status": "success",
"username": "fillup",
"commit_message": "implemented interface for handling tests",
"finished_at": "2017-09-13T17:13:55.193+00:00",
"allocated_at": "2017-09-13T17:13:36.967+00:00",
"queued_at": "2017-09-13T17:13:39.314+00:00",
"branch": "test-branch",
"links": {
"services": "https://api.codeship.com/v2/organizations/28123f10-e33d-5533-b53f-111ef8d7b14f/projects/28123f10-e33d-5533-b53f-111ef8d7b14f/builds/25a3dd8c-eb3e-4e75-1298-8cbcbe621342/services",
"steps": "https://api.codeship.com/v2/organizations/28123f10-e33d-5533-b53f-111ef8d7b14f/projects/28123f10-e33d-5533-b53f-111ef8d7b14f/builds/25a3dd8c-eb3e-4e75-1298-8cbcbe621342/steps"
}
},
{
"uuid": "25a3dd8c-eb3e-4e75-1298-8cbcbe611111",
"project_id": 2,
"project_uuid": "28123f10-e33d-5533-b53f-111ef8d7b14f",
"organization_uuid": "28123f10-e33d-5533-b53f-111ef8d7b14f",
"ref": "heads/master",
"commit_sha": "185ab4c7dc4eda2a027c284f7a669cac3f512345",
"status": "success",
"username": "fillup",
"commit_message": "updated tests",
"finished_at": "2017-09-13T17:13:55.193+00:00",
"allocated_at": "2017-09-13T17:13:36.967+00:00",
"queued_at": "2017-09-13T17:13:39.314+00:00",
"branch": "test-branch",
"links": {
"services": "https://api.codeship.com/v2/organizations/28123f10-e33d-5533-b53f-111ef8d7b14f/projects/28123f10-e33d-5533-b53f-111ef8d7b14f/builds/25a3dd8c-eb3e-4e75-1298-8cbcbe611111/services",
"steps": "https://api.codeship.com/v2/organizations/28123f10-e33d-5533-b53f-111ef8d7b14f/projects/28123f10-e33d-5533-b53f-111ef8d7b14f/builds/25a3dd8c-eb3e-4e75-1298-8cbcbe611111/steps"
}
}
],
"total": 2,
"per_page": 30,
"page": 1
"builds": [
{
"allocated_at": "2017-09-13T17:13:36.967+00:00",
"branch": "test-branch",
"commit_message": "implemented interface for handling tests",
"commit_sha": "185ab4c7dc4eda2a027c284f7a669cac3f50a5ed",
"finished_at": "2017-09-13T17:13:55.193+00:00",
"links": {
"services": "https://api.codeship.com/v2/organizations/28123f10-e33d-5533-b53f-111ef8d7b14f/projects/28123f10-e33d-5533-b53f-111ef8d7b14f/builds/25a3dd8c-eb3e-4e75-1298-8cbcbe621342/services",
"steps": "https://api.codeship.com/v2/organizations/28123f10-e33d-5533-b53f-111ef8d7b14f/projects/28123f10-e33d-5533-b53f-111ef8d7b14f/builds/25a3dd8c-eb3e-4e75-1298-8cbcbe621342/steps"
},
"organization_uuid": "28123f10-e33d-5533-b53f-111ef8d7b14f",
"project_id": 1,
"project_uuid": "28123f10-e33d-5533-b53f-111ef8d7b14f",
"queued_at": "2017-09-13T17:13:39.314+00:00",
"ref": "heads/master",
"status": "success",
"username": "fillup",
"uuid": "25a3dd8c-eb3e-4e75-1298-8cbcbe621342"
},
{
"allocated_at": "2017-09-13T17:13:36.967+00:00",
"branch": "test-branch",
"commit_message": "updated tests",
"commit_sha": "185ab4c7dc4eda2a027c284f7a669cac3f512345",
"finished_at": "2017-09-13T17:13:55.193+00:00",
"links": {
"services": "https://api.codeship.com/v2/organizations/28123f10-e33d-5533-b53f-111ef8d7b14f/projects/28123f10-e33d-5533-b53f-111ef8d7b14f/builds/25a3dd8c-eb3e-4e75-1298-8cbcbe611111/services",
"steps": "https://api.codeship.com/v2/organizations/28123f10-e33d-5533-b53f-111ef8d7b14f/projects/28123f10-e33d-5533-b53f-111ef8d7b14f/builds/25a3dd8c-eb3e-4e75-1298-8cbcbe611111/steps"
},
"organization_uuid": "28123f10-e33d-5533-b53f-111ef8d7b14f",
"project_id": 2,
"project_uuid": "28123f10-e33d-5533-b53f-111ef8d7b14f",
"queued_at": "2017-09-13T17:13:39.314+00:00",
"ref": "heads/master",
"status": "success",
"username": "fillup",
"uuid": "25a3dd8c-eb3e-4e75-1298-8cbcbe611111"
}
],
"page": 1,
"per_page": 30,
"total": 2
}
62 changes: 31 additions & 31 deletions testdata/fixtures/builds/pipelines.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"pipelines": [
{
"uuid": "0a341890-a899-4492-9c94-86ef24527f05",
"build_uuid": "9ec4b230-76f8-0135-86b9-2ee351ae25fe",
"type": "build",
"status": "success",
"created_at": "2017-09-11T19:54:16.556Z",
"updated_at": "2017-09-11T19:54:38.394Z",
"finished_at": "2017-09-11T19:54:38.391Z",
"metrics": {
"ami_id": "ami-02322b79",
"queries": "112",
"cpu_user": "1142",
"duration": "11",
"cpu_system": "499",
"instance_id": "i-0cfcd05a46d4cdb12",
"architecture": "trusty_64",
"instance_type": "i3.8xlarge",
"cpu_per_second": "136",
"disk_free_bytes": "128536784896",
"disk_used_bytes": "362098688",
"network_rx_bytes": "32221720",
"network_tx_bytes": "310269",
"max_used_connections": "1",
"memory_max_usage_in_bytes": "665427968"
}
}
],
"total": 1,
"per_page": 30,
"page": 1
"page": 1,
"per_page": 30,
"pipelines": [
{
"build_uuid": "9ec4b230-76f8-0135-86b9-2ee351ae25fe",
"created_at": "2017-09-11T19:54:16.556Z",
"finished_at": "2017-09-11T19:54:38.391Z",
"metrics": {
"ami_id": "ami-02322b79",
"architecture": "trusty_64",
"cpu_per_second": "136",
"cpu_system": "499",
"cpu_user": "1142",
"disk_free_bytes": "128536784896",
"disk_used_bytes": "362098688",
"duration": "11",
"instance_id": "i-0cfcd05a46d4cdb12",
"instance_type": "i3.8xlarge",
"max_used_connections": "1",
"memory_max_usage_in_bytes": "665427968",
"network_rx_bytes": "32221720",
"network_tx_bytes": "310269",
"queries": "112"
},
"status": "success",
"type": "build",
"updated_at": "2017-09-11T19:54:38.394Z",
"uuid": "0a341890-a899-4492-9c94-86ef24527f05"
}
],
"total": 1
}
30 changes: 15 additions & 15 deletions testdata/fixtures/builds/services.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"services": [
{
"uuid": "b46c6c6c-1bdb-4413-8e55-a9a8b1b27526",
"build_uuid": "25a3dd8c-eb3e-4e75-1298-8cbcbe621342",
"name": "test",
"status": "finished",
"updated_at": "2017-09-13T17:13:44+00:00",
"pulling_at": null,
"building_at": null,
"finished_at": "2017-09-13T17:13:41+00:00"
}
],
"total": 1,
"per_page": 30,
"page": 1
"page": 1,
"per_page": 30,
"services": [
{
"build_uuid": "25a3dd8c-eb3e-4e75-1298-8cbcbe621342",
"building_at": null,
"finished_at": "2017-09-13T17:13:41+00:00",
"name": "test",
"pulling_at": null,
"status": "finished",
"updated_at": "2017-09-13T17:13:44+00:00",
"uuid": "b46c6c6c-1bdb-4413-8e55-a9a8b1b27526"
}
],
"total": 1
}
44 changes: 22 additions & 22 deletions testdata/fixtures/builds/steps.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"steps": [
{
"uuid": "21adb0ec-5139-4547-b1cf-7c40160b6e9d",
"build_uuid": "28123f10-e33d-5533-b53f-111ef8d7b14f",
"service_uuid": "b46c6c6c-1bdb-4413-8e55-a9a8b1b27526",
"name": "test",
"tag": "",
"type": "run",
"status": "success",
"updated_at": "2017-09-13T17:13:44+00:00",
"started_at": "2017-09-13T17:13:41+00:00",
"building_at": "2017-09-13T17:13:41+00:00",
"finished_at": "2017-09-13T17:13:42+00:00",
"steps": [],
"command": "./run-tests.sh",
"image_name": null,
"registry": null
}
],
"total": 1,
"per_page": 30,
"page": 1
"page": 1,
"per_page": 30,
"steps": [
{
"build_uuid": "28123f10-e33d-5533-b53f-111ef8d7b14f",
"building_at": "2017-09-13T17:13:41+00:00",
"command": "./run-tests.sh",
"finished_at": "2017-09-13T17:13:42+00:00",
"image_name": null,
"name": "test",
"registry": null,
"service_uuid": "b46c6c6c-1bdb-4413-8e55-a9a8b1b27526",
"started_at": "2017-09-13T17:13:41+00:00",
"status": "success",
"steps": [],
"tag": "",
"type": "run",
"updated_at": "2017-09-13T17:13:44+00:00",
"uuid": "21adb0ec-5139-4547-b1cf-7c40160b6e9d"
}
],
"total": 1
}
4 changes: 3 additions & 1 deletion testdata/fixtures/errors.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"errors": ["%s"]
"errors": [
"%s"
]
}
Loading

0 comments on commit c9ca628

Please sign in to comment.