Skip to content

Commit 3b06c82

Browse files
authored
Update kaneai-ci-cd-automation.md
1 parent 6500c22 commit 3b06c82

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

docs/kaneai-ci-cd-automation.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,71 @@ Confirm that the job title is unique to avoid conflicts. Select a region if you
120120

121121
<img loading="lazy" src={require('../assets/images/kane-ai/test-manager/test-plan-ci-cd/image7.png').default} alt="Image" className="doc_img"/>
122122

123+
## GithubActions sample
124+
Here is a sample that you can use on how to integrate the API with GithubActions in your Github repository:
125+
126+
**Step 1: Create a GitHub Actions Workflow YAML File**
127+
In your Git repository, navigate to .github/workflows/ and create a file named sanity-test.yml.
128+
129+
**Step 2: Sample for yml file**
130+
In below sample, we are executing a test run using test_run_id and then verifying the result for it using HyperExecute job status API. You can find more details on HyperExecute APIs (here)[https://www.lambdatest.com/support/api-doc/?key=hyperexecute] and update the API in the .yml file based on your needs.
131+
132+
```yml
133+
name: Run Sanity Tests on LambdaTest
134+
135+
on:
136+
push:
137+
branches:
138+
- main
139+
pull_request:
140+
branches:
141+
- main
142+
143+
jobs:
144+
sanity-test:
145+
runs-on: ubuntu-latest
146+
147+
steps:
148+
- name: Trigger Sanity Test on LambdaTest
149+
id: trigger-test
150+
run: |
151+
echo "Triggering sanity tests on LambdaTest"
152+
response=$(curl --location 'https://test-manager-api.lambdatest.com/api/atm/v1/hyperexecute' \
153+
--header 'accept: application/json' \
154+
--header 'Content-Type: application/json' \
155+
--header 'Authorization: Basic <Base64Auth>' \
156+
--data '{
157+
"test_run_id" : "<test_run_id>",
158+
"concurrency" : 1,
159+
}')
160+
echo "Response: $response"
161+
job_id=$(echo $response | jq -r '.job_id')
162+
echo "Job ID: $job_id"
163+
echo "::set-output name=job_id::$job_id"
164+
165+
- name: Check Test Status
166+
run: |
167+
echo "Checking test status"
168+
job_id=${{ steps.trigger-test.outputs.job_id }}
169+
sleep 240 # Wait before checking the status
170+
response=$(curl --location "https://api.hyperexecute.cloud/v2.0/job/$job_id" \
171+
--header "accept: application/json" \
172+
--header "Authorization: Basic <Base64Auth>")
173+
174+
echo "Response: $response"
175+
status=$(echo $response | jq -r '.data.status')
176+
echo "Test status: $status"
177+
if [[ "$status" != "completed" ]]; then
178+
echo "Tests failed. Exiting with error."
179+
exit 1
180+
fi
181+
echo "Sanity tests passed successfully."
182+
```
183+
184+
**Step 3: Define Workflow Triggers**
185+
Set the workflow to trigger on push and pull_request events (you can modify the trigger based on your needs) under "on" section of the yaml above.
186+
187+
123188
## Video Explanation
124189
125190
:::tip

0 commit comments

Comments
 (0)