44 pull_request :
55 branches :
66 - main
7- - 8.x
87 - ' [0-9]+.[0-9]+'
8+ push :
9+ branches :
10+ - main
11+ - ' [0-9]+.[0-9]+'
12+
13+ permissions :
14+ pull-requests : write # To create/update PR comments
915
1016jobs :
11- validate-pr :
17+ validate-apis :
1218 name : build
1319 runs-on : ubuntu-latest
1420
1521 steps :
1622 - name : Check pull request was opened from branch
17- if : github.event.pull_request.head.repo.full_name != 'elastic/elasticsearch-specification'
23+ if : github.event_name == 'pull_request' && github. event.pull_request.head.repo.full_name != 'elastic/elasticsearch-specification'
1824 run : echo "Validation is not supported from forks"; exit 1
1925
2026 - uses : actions/checkout@v4
2127 with :
2228 path : ./elasticsearch-specification
29+ persist-credentials : false
2330
2431 - uses : actions/checkout@v4
2532 with :
2633 repository : elastic/clients-flight-recorder
2734 path : ./clients-flight-recorder
2835 token : ${{ secrets.PAT }}
2936 ref : ${{ github.base_ref }}
37+ persist-credentials : false
3038
3139 - name : Use Node.js 22
3240 uses : actions/setup-node@v4
3341 with :
3442 node-version : 22
3543
44+ - name : Cache JSON report
45+ id : cache-json-report
46+ uses : actions/cache@v4
47+ with :
48+ path : ./clients-flight-recorder/recordings/types-validation/types-validation.json
49+ key : types-validation-json-${{ github.event_name == 'pull_request' && format('{0}-{1}', github.base_ref, github.event.pull_request.base.sha) || format('{0}-{1}', github.ref_name, github.sha) }}
50+ restore-keys : |
51+ types-validation-json-${{ github.event_name == 'pull_request' && github.base_ref || github.ref_name }}-
52+
3653 - name : Install deps 1/2
3754 working-directory : ./clients-flight-recorder
3855 run : |
@@ -54,20 +71,30 @@ jobs:
5471 - name : Download artifacts
5572 working-directory : ./clients-flight-recorder
5673 run : |
57- if [[ -n "${GITHUB_BASE_REF+x }" ]]; then
74+ if [[ -n "${GITHUB_BASE_REF:- }" ]]; then
5875 branch=$GITHUB_BASE_REF
5976 else
6077 branch=$GITHUB_REF_NAME
6178 fi
79+ echo "Using branch: $branch"
6280 node scripts/upload-recording/download.js --branch $branch --git
6381 node scripts/clone-elasticsearch/index.js --branch $branch
6482
65- - name : Run validation
83+ - name : Run validation (Push)
84+ if : github.event_name == 'push'
85+ working-directory : ./clients-flight-recorder/scripts/types-validator
86+ env :
87+ BRANCH : ${{ github.ref_name }}
88+ run : node index.js --generate-report --ci --branch $BRANCH
89+
90+ - name : Run validation (PR)
91+ if : github.event_name == 'pull_request'
6692 id : validation
6793 working-directory : ./elasticsearch-specification
6894 run : node .github/validate-pr --token ${{ secrets.GITHUB_TOKEN }}
6995
7096 - name : Find existing comment
97+ if : github.event_name == 'pull_request'
7198 uses : peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
7299 id : find-comment
73100 with :
76103 body-includes : ' Following you can find the validation changes'
77104
78105 - name : Create or update comment
106+ if : github.event_name == 'pull_request'
79107 uses : peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
80108 with :
81109 token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments