Skip to content

Commit

Permalink
FAI-12780 - Support --run data for TestExecution event (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
willmarks authored Aug 27, 2024
1 parent 8b977db commit 855b24a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ CLI for reporting events to Faros platform.
**Requirements**: `docker`

```sh
docker pull farosai/faros-events-cli:v0.6.10 && docker run farosai/faros-events-cli:v0.6.10 help
docker pull farosai/faros-events-cli:v0.6.11 && docker run farosai/faros-events-cli:v0.6.11 help
```

### Using Bash

**Requirements**: `curl`, `jq` (1.6+), `sed`, `awk` (we recommend `gawk`).

Either [download the script manually](https://raw.githubusercontent.com/faros-ai/faros-events-cli/v0.6.10/faros_event.sh) or invoke the script directly with curl:
Either [download the script manually](https://raw.githubusercontent.com/faros-ai/faros-events-cli/v0.6.11/faros_event.sh) or invoke the script directly with curl:

```sh
bash <(curl -s https://raw.githubusercontent.com/faros-ai/faros-events-cli/v0.6.10/faros_event.sh) help
bash <(curl -s https://raw.githubusercontent.com/faros-ai/faros-events-cli/v0.6.11/faros_event.sh) help
```


Expand All @@ -62,7 +62,7 @@ Example usage:
```sh
./faros_event.sh CI -k "<faros_api_key>" \
--commit "GitHub://faros-ai/faros-events-cli/4414ad2b3b13b17055171678437a92e5d788cad1" \
--artifact "Docker://farosai/faros-events-cli/v0.6.10" \
--artifact "Docker://farosai/faros-events-cli/v0.6.11" \
--run "Jenkins://faros-ai/faros-events-cli/168_1700016590" \
--run_status "Success" \
--run_start_time "2023-11-14T18:05:46.019Z" \
Expand Down Expand Up @@ -268,6 +268,11 @@ There are two ways that arguments can be passed into the script. The first, is v
| --defect_task | The unique identifier of the defect task within the TMS (Task Management System). | |
| --test_suite_task | The unique identifier of the test suite task within the TMS (Task Management System). | |
| --test_execution_task | The unique identifier of the test execution task within the TMS (Task Management System). | |
| --run | The URI of the job run executing the test. (`<source>://<organization>/<pipeline>/<run_id>` e.g. `Jenkins://faros-ai/my-pipeline/1234`) | |
| --run_status | The status of the job run executing the test. (Allowed values: `Success`, `Failed`, `Canceled`, `Queued`, `Running`, `Unknown`, `Custom`) | --run |
| --run_status_details | Any extra details about the status of the job run executing the test. | --run |
| --run_start_time | The start time of the job run in milliseconds since the epoch, ISO-8601, or `Now`. (e.g. `1626804346019`, `2021-07-20T18:05:46.019Z`) | --run |
| --run_end_time | The end time of the job run in milliseconds since the epoch, ISO-8601, or `Now`. (e.g. `1626804346019`, `2021-07-20T18:05:46.019Z`) | --run |

### URI arguments alternative

Expand Down
4 changes: 3 additions & 1 deletion faros_event.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test || __() { :; }

set -eo pipefail

version="0.6.10"
version="0.6.11"
canonical_model_version="0.15.9"
github_url="https://github.com/faros-ai/faros-events-cli"

Expand Down Expand Up @@ -372,6 +372,7 @@ function processEventTypes() {
resolveTestExecutionInput
addTestToData
addCommitToData
addRunToData
fi
}

Expand Down Expand Up @@ -708,6 +709,7 @@ function resolveCIInput() {
function resolveTestExecutionInput() {
resolveTestInput
resolveCommitInput
resolveRunInput
}

function resolveDeployInput() {
Expand Down
2 changes: 1 addition & 1 deletion test/spec/faros_event_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ Describe 'faros_event.sh'

Describe 'TaskExecution event'

TestExecutionAllFields='{"type":"TestExecution","version":"0.0.1","origin":"Faros_Script_Event","data":{"test":{"id":"<test_id>","source":"<test_source>","type":"<test_type>","typeDetails":"<test_type_details>","status":"<test_status>","statusDetails":"<test_status_details>","suite":"<test_suite>","tags":"<test_tags>","environments":"<environments>","deviceInfo":{"name":"<device_name>","os":"<device_os>","browser":"<device_browser>","type":"<device_type>"},"testTask":"<test_task>","defectTask":"<defect_task>","suiteTask":"<test_suite_task>","executionTask":"<test_execution_task>","taskSource":"<task_source>","stats":{"failure":1,"success":2,"skipped":3,"unknown":4,"custom":5,"total":15},"startTime":"1970-01-01T00:00:01Z","endTime":"1970-01-01T00:00:02Z"},"commit":{"uri":"<vcs_source>://<vcs_organization>/<vcs_repo>/<commit_sha>","sha":"<commit_sha>","repository":"<vcs_repo>","organization":"<vcs_organization>","source":"<vcs_source>","branch":"<branch>","pullRequestNumber":101}}}'
TestExecutionAllFields='{"type":"TestExecution","version":"0.0.1","origin":"Faros_Script_Event","data":{"test":{"id":"<test_id>","source":"<test_source>","type":"<test_type>","typeDetails":"<test_type_details>","status":"<test_status>","statusDetails":"<test_status_details>","suite":"<test_suite>","tags":"<test_tags>","environments":"<environments>","deviceInfo":{"name":"<device_name>","os":"<device_os>","browser":"<device_browser>","type":"<device_type>"},"testTask":"<test_task>","defectTask":"<defect_task>","suiteTask":"<test_suite_task>","executionTask":"<test_execution_task>","taskSource":"<task_source>","stats":{"failure":1,"success":2,"skipped":3,"unknown":4,"custom":5,"total":15},"startTime":"1970-01-01T00:00:01Z","endTime":"1970-01-01T00:00:02Z"},"commit":{"uri":"<vcs_source>://<vcs_organization>/<vcs_repo>/<commit_sha>","sha":"<commit_sha>","repository":"<vcs_repo>","organization":"<vcs_organization>","source":"<vcs_source>","branch":"<branch>","pullRequestNumber":101},"run":{"uri":"<cicd_source>://<cicd_organization>/<cicd_pipeline>/<build_uid>","id":"<build_uid>","pipeline":"<cicd_pipeline>","organization":"<cicd_organization>","source":"<cicd_source>"}}}'

It 'populates all fields using flags'
test_execution_event_test() {
Expand Down

0 comments on commit 855b24a

Please sign in to comment.