Skip to content

Commit 7a35ba4

Browse files
committed
Use single workflow
Also use restore-keys
1 parent aeedbcc commit 7a35ba4

File tree

2 files changed

+24
-96
lines changed

2 files changed

+24
-96
lines changed

.github/workflows/generate.yml

Lines changed: 0 additions & 87 deletions
This file was deleted.

.github/workflows/validate-pr.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ on:
55
branches:
66
- main
77
- '[0-9]+.[0-9]+'
8+
push:
9+
branches:
10+
- main
11+
- '[0-9]+.[0-9]+'
812

913
jobs:
10-
validate-pr:
14+
validate-apis:
1115
name: build
1216
runs-on: ubuntu-latest
1317

1418
steps:
1519
- name: Check pull request was opened from branch
16-
if: github.event.pull_request.head.repo.full_name != 'elastic/elasticsearch-specification'
20+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != 'elastic/elasticsearch-specification'
1721
run: echo "Validation is not supported from forks"; exit 1
1822

1923
- uses: actions/checkout@v4
@@ -32,13 +36,14 @@ jobs:
3236
with:
3337
node-version: 22
3438

35-
- name: Restore JSON report
36-
id: restore-json-report
37-
uses: actions/cache/restore@v4
39+
- name: Cache JSON report
40+
id: cache-json-report
41+
uses: actions/cache@v4
3842
with:
39-
path: |
40-
./clients-flight-recorder/recordings/types-validation/types-validation.json
41-
key: types-validation-json-${{ github.event.pull_request.base.sha }}
43+
path: ./clients-flight-recorder/recordings/types-validation/types-validation.json
44+
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) }}
45+
restore-keys: |
46+
types-validation-json-${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}-
4247
4348
- name: Install deps 1/2
4449
working-directory: ./clients-flight-recorder
@@ -69,12 +74,21 @@ jobs:
6974
node scripts/upload-recording/download.js --branch $branch --git
7075
node scripts/clone-elasticsearch/index.js --branch $branch
7176
72-
- name: Run validation
77+
- name: Run validation (Push)
78+
if: github.event_name == 'push'
79+
working-directory: ./clients-flight-recorder/scripts/types-validator
80+
env:
81+
BRANCH: ${{ github.ref_name }}
82+
run: node index.js --generate-report --ci --branch $BRANCH
83+
84+
- name: Run validation (PR)
85+
if: github.event_name == 'pull_request'
7386
id: validation
7487
working-directory: ./elasticsearch-specification
7588
run: node .github/validate-pr --token ${{ secrets.GITHUB_TOKEN }}
7689

7790
- name: Find existing comment
91+
if: github.event_name == 'pull_request'
7892
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
7993
id: find-comment
8094
with:
@@ -83,6 +97,7 @@ jobs:
8397
body-includes: 'Following you can find the validation changes'
8498

8599
- name: Create or update comment
100+
if: github.event_name == 'pull_request'
86101
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
87102
with:
88103
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)