From cc70e9618bf8b9eae7b4b8d4b28a7a50b9773e28 Mon Sep 17 00:00:00 2001 From: Vitali Zaidman Date: Thu, 8 Aug 2024 13:53:06 +0100 Subject: [PATCH] add a nightly node compatibility validation testing the app on a set of node versions --- .github/actions/yarn-install/action.yml | 1 + .github/workflows/build-test-and-deploy.yml | 14 ++---- .../nightly-node-compatibility-validation.yml | 48 +++++++++++++++++++ .github/workflows/test.yml | 24 ++++++++++ 4 files changed, 78 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/nightly-node-compatibility-validation.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/actions/yarn-install/action.yml b/.github/actions/yarn-install/action.yml index ee40ab441..059f7650f 100644 --- a/.github/actions/yarn-install/action.yml +++ b/.github/actions/yarn-install/action.yml @@ -1,6 +1,7 @@ name: Install Dependencies inputs: node-version: + type: string required: false default: '20.x' diff --git a/.github/workflows/build-test-and-deploy.yml b/.github/workflows/build-test-and-deploy.yml index 50f6555e4..a09868055 100644 --- a/.github/workflows/build-test-and-deploy.yml +++ b/.github/workflows/build-test-and-deploy.yml @@ -44,18 +44,14 @@ jobs: test: strategy: + fail-fast: false matrix: runs-on: ['ubuntu-latest'] node-version: ['18.0', '18.x', '20.x'] - name: "Tests [Node.js ${{ matrix.node-version }}, ${{ matrix.runs-on }}]" - runs-on: ${{ matrix.runs-on }} - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/yarn-install - with: - node-version: ${{ matrix.node-version }} - - name: Run Jest Tests - run: yarn jest --ci --maxWorkers 4 --reporters=default --reporters=jest-junit --rootdir='./' + uses: ./.github/workflows/test.yml + with: + node-version: ${{ matrix.node-version }} + runs-on: ${{ matrix.runs-on }} deploy: # runs only on tag pushes diff --git a/.github/workflows/nightly-node-compatibility-validation.yml b/.github/workflows/nightly-node-compatibility-validation.yml new file mode 100644 index 000000000..ce2ed07e4 --- /dev/null +++ b/.github/workflows/nightly-node-compatibility-validation.yml @@ -0,0 +1,48 @@ +# In order to be updated when nightlies fail, please subscribe for updates on PR: +# ---> https://github.com/facebook/metro/pull/1314 <--- +# where comments will be published on fail. + +# This is a bit of a workaround tackling the lack of an organic way +# to notify certain people when a Github workflow fails: +# https://github.com/orgs/community/discussions/18039 + +name: facebook/metro/nightly-node-compatibility-validation +on: + schedule: + # Everyday at at 5:00 UTC (22:00 USA West Coast, 06:00 London) + - cron: '0 5 * * *' + push: + +jobs: + test: + strategy: + max-parallel: 1 # reduces the flakiness of these tests + fail-fast: false + matrix: + runs-on: ['ubuntu-latest'] + node-version: [ # https://github.com/nodejs/release#release-schedule + '18.0', # minimum supported + 'lts/-1', # pre-latest lts + 'lts/*', # latest lts + 'current' # newest + ] + uses: ./.github/workflows/test.yml + with: + node-version: ${{ matrix.node-version }} + runs-on: ${{ matrix.runs-on }} + + comment-on-pr-for-failures: + runs-on: ubuntu-latest + needs: [test] + if: ${{ always() && needs.test.result == 'failure' }} + steps: + - uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + // see https://github.com/facebook/metro/pull/1314 + issue_number: 1314, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'A nightly test failed in `${{ github.workflow }}` in [run ${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})!', + }); diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..12e643349 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,24 @@ +name: test +on: + workflow_call: + inputs: + node-version: + type: string + required: false + default: 'ubuntu-latest' + runs-on: + type: string + required: false + default: '20.x' + +jobs: + test: + name: "Tests [Node.js ${{ inputs.node-version }}, ${{ inputs.runs-on }}]" + runs-on: ${{ inputs.runs-on }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/yarn-install + with: + node-version: ${{ inputs.node-version }} + - name: Run Jest Tests + run: yarn jest --ci --maxWorkers 4 --reporters=default --reporters=jest-junit --rootdir='./'