1- name : Run Integration Tests
1+ name : Reusable Integration Test Workflow
22
33permissions :
44 contents : read
1616 - unlabeled
1717 schedule :
1818 - cron : " 0 5 * * *"
19+ workflow_call :
20+ inputs :
21+ target-branch :
22+ description : ' Branch to checkout and test (defaults to the calling branch)'
23+ required : false
24+ type : string
25+ default : ' '
26+ enable-status-reporting :
27+ description : ' Whether to post status checks to datadog-api-spec repo'
28+ required : false
29+ type : boolean
30+ default : false
31+ status-context :
32+ description : ' Context for status checks'
33+ required : false
34+ type : string
35+ default : ' integration'
36+ target-repo :
37+ description : ' Repository to post status to'
38+ required : false
39+ type : string
40+ default : ' datadog-api-spec'
41+ secrets :
42+ PIPELINE_GITHUB_APP_ID :
43+ required : false
44+ PIPELINE_GITHUB_APP_PRIVATE_KEY :
45+ required : false
46+ DD_API_KEY :
47+ required : true
48+ DD_CLIENT_API_KEY :
49+ required : true
50+ DD_CLIENT_APP_KEY :
51+ required : true
1952
2053concurrency :
2154 group : integration-${{ github.head_ref }}
@@ -48,18 +81,19 @@ jobs:
4881 with :
4982 app-id : ${{ secrets.PIPELINE_GITHUB_APP_ID }}
5083 private-key : ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
51- installation_retrieval_mode : repository
52- installation_retrieval_payload : DataDog/datadog-api-spec
84+ repositories : ${{ inputs.target-repo || 'datadog-api-spec' }}
5385 - name : Checkout code
5486 uses : actions/checkout@v3
87+ with :
88+ ref : ${{ inputs.target-branch || github.ref }}
5589 - name : Post pending status check
56- if : github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')
90+ if : github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/') && (inputs.enable-status-reporting || github.event_name != 'workflow_call')
5791 uses : DataDog/github-actions/post-status-check@v2
5892 with :
5993 github-token : ${{ steps.get_token.outputs.token }}
60- repo : datadog-api-spec
94+ repo : ${{ inputs.target-repo || ' datadog-api-spec' }}
6195 status : pending
62- context : integration
96+ context : ${{ inputs.status-context || ' integration' }}
6397 - name : Install Rust
6498 uses : dtolnay/rust-toolchain@v1
6599 with :
@@ -78,18 +112,18 @@ jobs:
78112 DD_TEST_CLIENT_APP_KEY : ${{ secrets.DD_CLIENT_APP_KEY }}
79113 RECORD : " none"
80114 - name : Post failure status check
81- if : failure() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')
115+ if : failure() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/') && (inputs.enable-status-reporting || github.event_name != 'workflow_call')
82116 uses : DataDog/github-actions/post-status-check@v2
83117 with :
84118 github-token : ${{ steps.get_token.outputs.token }}
85- repo : datadog-api-spec
119+ repo : ${{ inputs.target-repo || ' datadog-api-spec' }}
86120 status : failure
87- context : integration
121+ context : ${{ inputs.status-context || ' integration' }}
88122 - name : Post success status check
89- if : " !failure() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')"
123+ if : " !failure() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/') && (inputs.enable-status-reporting || github.event_name != 'workflow_call') "
90124 uses : DataDog/github-actions/post-status-check@v2
91125 with :
92126 github-token : ${{ steps.get_token.outputs.token }}
93- repo : datadog-api-spec
127+ repo : ${{ inputs.target-repo || ' datadog-api-spec' }}
94128 status : success
95- context : integration
129+ context : ${{ inputs.status-context || ' integration' }}
0 commit comments