From c7654a3db0247684a3de422f43f412359c16bf34 Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Tue, 25 Feb 2025 13:08:18 +0000 Subject: [PATCH 1/4] chore: Testable build --- .github/workflows/create-data-model-pr.yaml | 36 ++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create-data-model-pr.yaml b/.github/workflows/create-data-model-pr.yaml index 2256051..f80f1df 100644 --- a/.github/workflows/create-data-model-pr.yaml +++ b/.github/workflows/create-data-model-pr.yaml @@ -4,6 +4,18 @@ on: workflow_dispatch: repository_dispatch: types: [data-models-update] + workflow_call: + inputs: + data-models_ref: + required: false + type: string + models-lib_ref: + required: false + type: string + models-ts_ref: + required: false + type: string + default: 'refs/heads/main' jobs: generate: @@ -13,14 +25,16 @@ jobs: - name: Checkout models-ts uses: actions/checkout@v2 with: - ref: main path: models-ts + # If this is being called from another workflow, then the models-ts_ref will be provided or defaulted; otherwise we can assume a different trigger + ref: ${{ inputs.models-ts_ref || github.ref }} - name: Checkout models-lib uses: actions/checkout@v2 with: repository: openactive/models-lib path: models-lib + ref: ${{ inputs.models-lib_ref || 'refs/heads/main' }} - name: Setup Node.js 14.x uses: actions/setup-node@v1 @@ -32,9 +46,14 @@ jobs: working-directory: ./models-lib/ - name: Update models-lib with latest data-models + if: ${{ !inputs.data-models_ref }} run: npm update @openactive/data-models working-directory: ./models-lib/ + - name: Install specific version of data-models ${{ inputs.data-models_ref }} + if: ${{ inputs.data-models_ref }} + run: npm install github:openactive/data-models#${{ inputs.data-models_ref }} + - name: Run TypeScript models generator run: npm start -- generate TypeScript --destination ../models-ts/src/ working-directory: ./models-lib/ @@ -46,10 +65,24 @@ jobs: - name: Build models-ts types run: npm run build working-directory: ./models-ts/ + + - name: Upload current state of branch + uses: actions/upload-artifact@v4 + if: ${{ inputs.data-models_ref || inputs.models-lib_ref || inputs.models-ts_ref }} + with: + name: models-ts + path: models-ts + + - name: Test current state of branch + uses: openactive/models-ts/.github/workflows/test.yml@${{ inputs.models-ts_ref || github.ref }} + if: ${{ inputs.data-models_ref || inputs.models-lib_ref || inputs.models-ts_ref }} + with: + repo_artifact: models-ts - name: Create Pull Request id: cpr uses: peter-evans/create-pull-request@v4 + if: ${{ !inputs.data-models_ref && !inputs.models-lib_ref && !inputs.models-ts_ref }} with: path: ./models-ts/ token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} @@ -67,6 +100,7 @@ jobs: draft: false - name: Check outputs + if: ${{ !inputs.data-models_ref && !inputs.models-lib_ref && !inputs.models-ts_ref }} run: | echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" From 45028d576ccbd7b4c995deda352e67733db71fac Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Tue, 25 Feb 2025 13:22:51 +0000 Subject: [PATCH 2/4] Update create-data-model-pr.yaml --- .github/workflows/create-data-model-pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-data-model-pr.yaml b/.github/workflows/create-data-model-pr.yaml index f80f1df..ec30561 100644 --- a/.github/workflows/create-data-model-pr.yaml +++ b/.github/workflows/create-data-model-pr.yaml @@ -74,7 +74,7 @@ jobs: path: models-ts - name: Test current state of branch - uses: openactive/models-ts/.github/workflows/test.yml@${{ inputs.models-ts_ref || github.ref }} + uses: openactive/models-ts/.github/workflows/tests.yaml@${{ inputs.models-ts_ref || github.ref }} if: ${{ inputs.data-models_ref || inputs.models-lib_ref || inputs.models-ts_ref }} with: repo_artifact: models-ts From fab8cdc6f41dd2f7a8059884820af9831f000ba3 Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Tue, 25 Feb 2025 13:23:43 +0000 Subject: [PATCH 3/4] Update tests.yaml --- .github/workflows/tests.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 96ce91c..314b70f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -3,6 +3,11 @@ name: Tests on: pull_request: branches: [ main ] + workflow_call: + inputs: + repo_artifact: + required: false + type: string jobs: test: @@ -14,7 +19,15 @@ jobs: steps: - name: Checkout + if: ${{ !inputs.repo_artifact }} uses: actions/checkout@v2 + + # If specified, download an artifact instead of checking out the repo + - name: Download Artifact + if: ${{ inputs.repo_artifact }} + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.repo_artifact }} - name: Use Node.js ${{ matrix.version }} uses: actions/setup-node@v1 From 50f1bf13072a56837472414303809194e5a54aea Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Tue, 25 Feb 2025 16:08:15 +0000 Subject: [PATCH 4/4] Update create-data-model-pr.yaml --- .github/workflows/create-data-model-pr.yaml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/create-data-model-pr.yaml b/.github/workflows/create-data-model-pr.yaml index ec30561..ac32ea3 100644 --- a/.github/workflows/create-data-model-pr.yaml +++ b/.github/workflows/create-data-model-pr.yaml @@ -73,12 +73,6 @@ jobs: name: models-ts path: models-ts - - name: Test current state of branch - uses: openactive/models-ts/.github/workflows/tests.yaml@${{ inputs.models-ts_ref || github.ref }} - if: ${{ inputs.data-models_ref || inputs.models-lib_ref || inputs.models-ts_ref }} - with: - repo_artifact: models-ts - - name: Create Pull Request id: cpr uses: peter-evans/create-pull-request@v4 @@ -104,3 +98,10 @@ jobs: run: | echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" + + test: + uses: openactive/models-ts/.github/workflows/tests.yaml@${{ inputs.models-ts_ref || github.ref }} + if: ${{ inputs.data-models_ref || inputs.models-lib_ref || inputs.models-ts_ref }} + with: + repo_artifact: models-ts +