1- name : Run Integration Tests
1+ name : Reusable Integration Test Workflow
22
33permissions :
44 contents : read
1616 - master
1717 schedule :
1818 - cron : " 0 4 * * *"
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
52+ SLEEP_AFTER_REQUEST :
53+ required : false
1954
2055concurrency :
2156 group : integration-${{ github.head_ref }}
@@ -48,17 +83,20 @@ jobs:
4883 with :
4984 app-id : ${{ secrets.PIPELINE_GITHUB_APP_ID }}
5085 private-key : ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
51- repositories : datadog-api-spec
86+ repositories : ${{ inputs.target-repo || ' datadog-api-spec' }}
5287 - name : Checkout code
5388 uses : actions/checkout@v3
89+ with :
90+ repository : DataDog/datadog-api-client-typescript
91+ ref : ${{ inputs.target-branch || github.ref }}
5492 - name : Post pending status check
55- if : github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')
93+ 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')
5694 uses : DataDog/github-actions/post-status-check@v2
5795 with :
5896 github-token : ${{ steps.get_token.outputs.token }}
59- repo : datadog-api-spec
97+ repo : ${{ inputs.target-repo || ' datadog-api-spec' }}
6098 status : pending
61- context : integration
99+ context : ${{ inputs.status-context || ' integration' }}
62100 - name : Set up Node 16
63101 uses : actions/setup-node@v3
64102 with :
@@ -77,20 +115,20 @@ jobs:
77115 DD_TEST_CLIENT_API_KEY : ${{ secrets.DD_CLIENT_API_KEY }}
78116 DD_TEST_CLIENT_APP_KEY : ${{ secrets.DD_CLIENT_APP_KEY }}
79117 RECORD : " none"
80- SLEEP_AFTER_REQUEST : " ${{ vars.SLEEP_AFTER_REQUEST }}"
118+ SLEEP_AFTER_REQUEST : ${{ secrets.SLEEP_AFTER_REQUEST || vars.SLEEP_AFTER_REQUEST }}
81119 - name : Post failure status check
82- if : failure() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')
120+ 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')
83121 uses : DataDog/github-actions/post-status-check@v2
84122 with :
85123 github-token : ${{ steps.get_token.outputs.token }}
86- repo : datadog-api-spec
124+ repo : ${{ inputs.target-repo || ' datadog-api-spec' }}
87125 status : failure
88- context : integration
126+ context : ${{ inputs.status-context || ' integration' }}
89127 - name : Post success status check
90- if : " !failure() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')"
128+ 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') "
91129 uses : DataDog/github-actions/post-status-check@v2
92130 with :
93131 github-token : ${{ steps.get_token.outputs.token }}
94- repo : datadog-api-spec
132+ repo : ${{ inputs.target-repo || ' datadog-api-spec' }}
95133 status : success
96- context : integration
134+ context : ${{ inputs.status-context || ' integration' }}
0 commit comments