1- name : Run Integration Tests
1+ name : Reusable Integration Test Workflow
22
33permissions :
44 contents : read
55
66on :
77 pull_request :
8+ branches :
9+ - master
810 types :
911 - opened
1012 - reopened
1113 - ready_for_review
1214 - synchronize
1315 - labeled
1416 - unlabeled
15- branches :
16- - master
1717 schedule :
1818 - cron : " 0 2 * * *"
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+ cache-version :
42+ description : ' Cache version for gem dependencies'
43+ required : false
44+ type : string
45+ default : ' '
46+ secrets :
47+ PIPELINE_GITHUB_APP_ID :
48+ required : false
49+ PIPELINE_GITHUB_APP_PRIVATE_KEY :
50+ required : false
51+ DD_API_KEY :
52+ required : true
53+ DD_CLIENT_API_KEY :
54+ required : true
55+ DD_CLIENT_APP_KEY :
56+ required : true
57+ SLEEP_AFTER_REQUEST :
58+ required : false
1959
2060concurrency :
2161 group : integration-${{ github.head_ref }}
2262 cancel-in-progress : true
2363
2464jobs :
25- test_integration :
65+ integration_tests :
2666 runs-on : ubuntu-latest
2767 if : >
2868 (github.event_name == 'pull_request' &&
@@ -48,17 +88,20 @@ jobs:
4888 with :
4989 app-id : ${{ secrets.PIPELINE_GITHUB_APP_ID }}
5090 private-key : ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
51- repositories : datadog-api-spec
91+ repositories : ${{ inputs.target-repo || ' datadog-api-spec' }}
5292 - name : Checkout code
5393 uses : actions/checkout@v3
94+ with :
95+ repository : DataDog/datadog-api-client-ruby
96+ ref : ${{ inputs.target-branch || github.ref }}
5497 - name : Post pending status check
55- if : github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')
98+ 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')
5699 uses : DataDog/github-actions/post-status-check@v2
57100 with :
58101 github-token : ${{ steps.get_token.outputs.token }}
59- repo : datadog-api-spec
102+ repo : ${{ inputs.target-repo || ' datadog-api-spec' }}
60103 status : pending
61- context : integration
104+ context : ${{ inputs.status-context || ' integration' }}
62105 - name : Install system zstd
63106 run : |
64107 sudo apt-get -y install zstd
68111 with :
69112 ruby-version : " 3.2"
70113 bundler-cache : true
71- cache-version : ${{ secrets.CACHE_VERSION }}
114+ cache-version : ${{ inputs.cache-version }}
72115 - name : Install deps
73116 run : bundle install
74117 - name : Run integration tests
@@ -84,20 +127,20 @@ jobs:
84127 DD_TEST_CLIENT_APP_KEY : ${{ secrets.DD_CLIENT_APP_KEY }}
85128 DD_TRACE_ANALYTICS_ENABLED : " true"
86129 RECORD : " none"
87- SLEEP_AFTER_REQUEST : " ${{ vars.SLEEP_AFTER_REQUEST }}"
130+ SLEEP_AFTER_REQUEST : ${{ secrets.SLEEP_AFTER_REQUEST || vars.SLEEP_AFTER_REQUEST }}
88131 - name : Post failure status check
89- if : failure() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')
132+ 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')
90133 uses : DataDog/github-actions/post-status-check@v2
91134 with :
92135 github-token : ${{ steps.get_token.outputs.token }}
93- repo : datadog-api-spec
136+ repo : ${{ inputs.target-repo || ' datadog-api-spec' }}
94137 status : failure
95- context : integration
138+ context : ${{ inputs.status-context || ' integration' }}
96139 - name : Post success status check
97- if : " !failure() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')"
140+ 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') "
98141 uses : DataDog/github-actions/post-status-check@v2
99142 with :
100143 github-token : ${{ steps.get_token.outputs.token }}
101- repo : datadog-api-spec
144+ repo : ${{ inputs.target-repo || ' datadog-api-spec' }}
102145 status : success
103- context : integration
146+ context : ${{ inputs.status-context || ' integration' }}
0 commit comments