|
5 | 5 | branches: |
6 | 6 | - main |
7 | 7 | - '[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 |
8 | 15 |
|
9 | 16 | jobs: |
10 | | - validate-pr: |
| 17 | + validate-apis: |
11 | 18 | name: build |
12 | 19 | runs-on: ubuntu-latest |
13 | 20 |
|
14 | 21 | steps: |
15 | 22 | - name: Check pull request was opened from branch |
16 | | - 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' |
17 | 24 | run: echo "Validation is not supported from forks"; exit 1 |
18 | 25 |
|
19 | 26 | - uses: actions/checkout@v4 |
20 | 27 | with: |
21 | 28 | path: ./elasticsearch-specification |
| 29 | + persist-credentials: false |
22 | 30 |
|
23 | 31 | - uses: actions/checkout@v4 |
24 | 32 | with: |
25 | 33 | repository: elastic/clients-flight-recorder |
26 | 34 | path: ./clients-flight-recorder |
27 | 35 | token: ${{ secrets.PAT }} |
28 | 36 | ref: ${{ github.base_ref }} |
| 37 | + persist-credentials: false |
29 | 38 |
|
30 | 39 | - name: Use Node.js 22 |
31 | 40 | uses: actions/setup-node@v4 |
32 | 41 | with: |
33 | 42 | node-version: 22 |
34 | 43 |
|
| 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.head_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.head_ref || github.ref_name }}- |
| 52 | +
|
35 | 53 | - name: Install deps 1/2 |
36 | 54 | working-directory: ./clients-flight-recorder |
37 | 55 | run: | |
@@ -61,12 +79,21 @@ jobs: |
61 | 79 | node scripts/upload-recording/download.js --branch $branch --git |
62 | 80 | node scripts/clone-elasticsearch/index.js --branch $branch |
63 | 81 |
|
64 | | - - name: Run validation |
| 82 | + - name: Run validation (Push) |
| 83 | + if: github.event_name == 'push' |
| 84 | + working-directory: ./clients-flight-recorder/scripts/types-validator |
| 85 | + env: |
| 86 | + BRANCH: ${{ github.ref_name }} |
| 87 | + run: node index.js --generate-report --ci --branch $BRANCH |
| 88 | + |
| 89 | + - name: Run validation (PR) |
| 90 | + if: github.event_name == 'pull_request' |
65 | 91 | id: validation |
66 | 92 | working-directory: ./elasticsearch-specification |
67 | 93 | run: node .github/validate-pr --token ${{ secrets.GITHUB_TOKEN }} |
68 | 94 |
|
69 | 95 | - name: Find existing comment |
| 96 | + if: github.event_name == 'pull_request' |
70 | 97 | uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0 |
71 | 98 | id: find-comment |
72 | 99 | with: |
|
75 | 102 | body-includes: 'Following you can find the validation changes' |
76 | 103 |
|
77 | 104 | - name: Create or update comment |
| 105 | + if: github.event_name == 'pull_request' |
78 | 106 | uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 |
79 | 107 | with: |
80 | 108 | token: ${{ secrets.GITHUB_TOKEN }} |
|
0 commit comments