From a09e105c2391b3f9821ad5d422acd253eff1d811 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 20 Feb 2023 11:41:36 +0000 Subject: [PATCH] Make workflows reusable for downstream testing (#10174) --- .github/workflows/tests.yml | 15 +++++++++++++++ scripts/ci/install-deps.sh | 1 + scripts/ci/layered.sh | 1 + 3 files changed, 17 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index dab8438699..ebc17831a8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,6 +5,12 @@ on: branches: [develop, master] repository_dispatch: types: [upstream-sdk-notify] + workflow_call: + inputs: + matrix-js-sdk-sha: + type: string + required: false + description: "The matrix-js-sdk SHA to use" env: # These must be set for fetchdep.sh to get the right branch REPOSITORY: ${{ github.repository }} @@ -16,6 +22,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 + with: + repository: ${{ inputs.matrix-js-sdk-sha && 'matrix-org/matrix-react-sdk' || github.repository }} - name: Yarn cache uses: actions/setup-node@v3 @@ -24,6 +32,8 @@ jobs: - name: Install Deps run: "./scripts/ci/install-deps.sh --ignore-scripts" + env: + JS_SDK_GITHUB_BASE_REF: ${{ inputs.matrix-js-sdk-sha }} - name: Get number of CPU cores id: cpu-cores @@ -38,6 +48,7 @@ jobs: run: "yarn coverage --ci --reporters github-actions --max-workers ${{ steps.cpu-cores.outputs.count }}" - name: Upload Artifact + if: inputs.matrix-js-sdk-sha == '' uses: actions/upload-artifact@v3 with: name: coverage @@ -50,6 +61,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + repository: ${{ inputs.matrix-js-sdk-sha && 'matrix-org/matrix-react-sdk' || github.repository }} - uses: actions/setup-node@v3 with: @@ -57,3 +70,5 @@ jobs: - name: Run tests run: "./scripts/ci/app-tests.sh" + env: + JS_SDK_GITHUB_BASE_REF: ${{ inputs.matrix-js-sdk-sha }} diff --git a/scripts/ci/install-deps.sh b/scripts/ci/install-deps.sh index 7121e7a36c..544045c7ed 100755 --- a/scripts/ci/install-deps.sh +++ b/scripts/ci/install-deps.sh @@ -11,6 +11,7 @@ set -ex scripts/fetchdep.sh matrix-org matrix-js-sdk pushd matrix-js-sdk +[ -n "$JS_SDK_GITHUB_BASE_REF" ] && git fetch --depth 1 origin $JS_SDK_GITHUB_BASE_REF && git checkout $JS_SDK_GITHUB_BASE_REF yarn link yarn install --pure-lockfile $@ popd diff --git a/scripts/ci/layered.sh b/scripts/ci/layered.sh index bb002bd3ab..cd3dc7442c 100755 --- a/scripts/ci/layered.sh +++ b/scripts/ci/layered.sh @@ -16,6 +16,7 @@ set -ex # Set up the js-sdk first scripts/fetchdep.sh matrix-org matrix-js-sdk pushd matrix-js-sdk +[ -n "$JS_SDK_GITHUB_BASE_REF" ] && git fetch --depth 1 origin $JS_SDK_GITHUB_BASE_REF && git checkout $JS_SDK_GITHUB_BASE_REF yarn link yarn install --pure-lockfile popd