Skip to content

Commit 0167821

Browse files
committed
fix: refine scheduled integration tests
1 parent e359bf6 commit 0167821

File tree

2 files changed

+82
-7
lines changed

2 files changed

+82
-7
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ workflows:
315315
when:
316316
and:
317317
- equal: [scheduled_pipeline, << pipeline.trigger_source >>]
318-
- equal: ["integration_tests", << pipeline.schedule.name >>]
318+
- equal: ["Integration Tests", << pipeline.schedule.name >>]
319319
jobs:
320320
- pull_docker_images_and_run_integration_tests:
321321
context:

docs/CircleCI-API.md

Lines changed: 81 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
# CircleCI API
22

33
* [CircleCI API Developer's Guide](https://circleci.com/docs/2.0/api-developers-guide/)
4+
* [CircleCI API (v2)](https://circleci.com/docs/api/v2/)
45

56
## Authentication
67

78
* generate [Personal API Token](https://app.circleci.com/settings/user/tokens) which is associated with a user
9+
10+
* save token in ```~/.circleci.creds``` formatted like
11+
12+
```ini
13+
# created 8 Jan '22 - personal access token for Dave
14+
PERSONAL_API_TOKEN=1234567890abcdef
15+
```
16+
17+
* extract using something like
18+
19+
```bash
20+
~> PERSONAL_API_TOKEN=$(grep PERSONAL_API_TOKEN ~/.circleci.creds | sed -e 's|^.*=||g')
21+
~>
22+
```
23+
824
* test the token works
925

1026
```bash
@@ -81,16 +97,17 @@
8197
* [Scheduled Pipelines](https://circleci.com/docs/2.0/scheduled-pipelines)
8298
* [7 Jan '22 - Getting started with scheduled pipelines](https://circleci.com/blog/using-scheduled-pipelines/)
8399
* can configure schedules under ```project settings / triggers``` (ex [https://app.circleci.com/settings/project/github/simonsdave/cloudfeaster/triggers](https://app.circleci.com/settings/project/github/simonsdave/cloudfeaster/triggers))
100+
* [Schedule CircleCI API (v2)](https://circleci.com/docs/api/v2/#tag/Schedule)
84101

85102
### Get All Schedules
86103

87104
```bash
88105
~> curl \
89106
-s \
90-
--verbose \
91107
--header "Circle-Token: ${PERSONAL_API_TOKEN}" \
92108
--header 'Accept: application/json' \
93109
https://circleci.com/api/v2/project/gh/simonsdave/cloudfeaster/schedule
110+
~>
94111
```
95112

96113
### Create Schedule
@@ -101,23 +118,81 @@
101118
```bash
102119
~> curl \
103120
-s \
104-
--verbose \
105121
--header "Circle-Token: ${PERSONAL_API_TOKEN}" \
106122
-X POST \
107123
--header 'Content-Type: application/json' \
108124
--data-raw '{
109-
"name": "Run Integration Tests",
110-
"description": "Run intergration tests every day",
125+
"name": "Integration Tests",
126+
"description": "Run Intergration Tests",
111127
"attribution-actor": "system",
112128
"parameters": {
113129
"branch": "master"
114130
},
115131
"timetable": {
116132
"per-hour": 1,
117-
"hours-of-day": [16],
133+
"hours-of-day": [21],
118134
"days-of-week": ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"]
119135
}
120136
}' \
121137
--header 'Accept: application/json' \
122-
https://circleci.com/api/v2/project/gh/simonsdave/cloudfeaster/schedule
138+
https://circleci.com/api/v2/project/gh/simonsdave/cloudfeaster/schedule | jq .
139+
{
140+
"description": "Run Intergration Tests",
141+
"updated-at": "2022-01-09T20:13:18.855Z",
142+
"name": "Integration Tests",
143+
"id": "00000000-1111-2222-3333-444444444444",
144+
"project-slug": "gh/simonsdave/cloudfeaster",
145+
"created-at": "2022-01-09T20:13:18.855Z",
146+
"parameters": {
147+
"branch": "master"
148+
},
149+
"actor": {
150+
"login": "system-actor",
151+
"name": "Scheduled",
152+
"id": "55555555-1111-2222-3333-444444444444",
153+
},
154+
"timetable": {
155+
"per-hour": 1,
156+
"hours-of-day": [
157+
21
158+
],
159+
"days-of-week": [
160+
"MON",
161+
"TUE",
162+
"WED",
163+
"THU",
164+
"FRI",
165+
"SAT",
166+
"SUN"
167+
]
168+
}
169+
}
170+
~>
171+
```
172+
173+
### Get A Schedule
174+
175+
* get a schedule after it's been created
176+
177+
```bash
178+
~> curl \
179+
-s \
180+
--header "Circle-Token: ${PERSONAL_API_TOKEN}" \
181+
--header 'Accept: application/json' \
182+
https://circleci.com/api/v2/project/gh/simonsdave/cloudfeaster/schedule/00000000-1111-2222-3333-444444444444
183+
~>
184+
```
185+
186+
## Delete Schedule
187+
188+
* delete a schedule after it's been created
189+
190+
```bash
191+
~> curl \
192+
-s \
193+
--header "Circle-Token: ${PERSONAL_API_TOKEN}" \
194+
-X DELETE \
195+
--header 'Accept: application/json' \
196+
https://circleci.com/api/v2/project/gh/simonsdave/cloudfeaster/schedule/00000000-1111-2222-3333-444444444444
197+
~>
123198
```

0 commit comments

Comments
 (0)