From 184d79854f8aaf9e4cae6bc09767400ac961c1be Mon Sep 17 00:00:00 2001
From: Vitali Zaidman <vzaidman@gmail.com>
Date: Fri, 9 Aug 2024 10:21:47 +0100
Subject: [PATCH] add nightly-latest-packages-validation

---
 .github/actions/yarn-install/action.yml       | 18 +++++++++++++++++-
 ...tion.yml => nightly-nodejs-validation.yml} | 19 ++++++++++---------
 .github/workflows/test.yml                    | 12 +++++++++---
 3 files changed, 36 insertions(+), 13 deletions(-)
 rename .github/workflows/{nightly-node-compatibility-validation.yml => nightly-nodejs-validation.yml} (65%)

diff --git a/.github/actions/yarn-install/action.yml b/.github/actions/yarn-install/action.yml
index d42f20c80b..b3319dc92e 100644
--- a/.github/actions/yarn-install/action.yml
+++ b/.github/actions/yarn-install/action.yml
@@ -8,16 +8,32 @@ inputs:
     type: string
     required: false
     default: 'false'
+  no-yarn-lock:
+    type: string
+    required: false
+    default: 'false'
 
 runs:
   using: "composite"
   steps:
   - uses: actions/setup-node@v4
+    name: Setup Node With Yarn Cache
+    if: ${{ inputs.no-yarn-lock != 'true' }}
     with:
       node-version: ${{ inputs.node-version }}
+      check-latest: true
       cache: yarn
       cache-dependency-path: yarn.lock
+  - uses: actions/setup-node@v4
+    name: Setup Node With No Yarn Cache
+    if: ${{ inputs.no-yarn-lock == 'true' }}
+    with:
+      node-version: ${{ inputs.node-version }}
       check-latest: true
+  - name: Remove yarn.lock
+    if: ${{ inputs.no-yarn-lock == 'true' }}
+    run: rm yarn.lock
+    shell: bash
   - name: Install Dependencies
-    run: yarn install --frozen-lockfile --non-interactive --ignore-scripts ${{ inputs.ignore-engines == 'true' && '--ignore-engines' || ''}}
+    run: yarn install ${{ inputs.no-yarn-lock != 'true' && '--frozen-lockfile' || '' }} --non-interactive --ignore-scripts ${{ inputs.ignore-engines == 'true' && '--ignore-engines' || ''}}
     shell: bash
diff --git a/.github/workflows/nightly-node-compatibility-validation.yml b/.github/workflows/nightly-nodejs-validation.yml
similarity index 65%
rename from .github/workflows/nightly-node-compatibility-validation.yml
rename to .github/workflows/nightly-nodejs-validation.yml
index 6a4d7341b1..c9a274943d 100644
--- a/.github/workflows/nightly-node-compatibility-validation.yml
+++ b/.github/workflows/nightly-nodejs-validation.yml
@@ -6,11 +6,12 @@
 # to notify certain people when a Github workflow fails:
 # https://github.com/orgs/community/discussions/18039
 
-name: facebook/metro/nightly-node-compatibility-validation
+name: facebook/metro/nightly-nodejs-validation
 on:
   schedule:
-    # Everyday at at 5:00 UTC (22:00 USA West Coast, 06:00 London)
+    # Daily at at 5:00 UTC
     - cron:  '0 5 * * *'
+  push:
 
 jobs:
   test:
@@ -25,16 +26,16 @@ jobs:
           'lts/*',   # latest lts
           'current'  # newest
         ]
-        include:
-          - runs-on: ubuntu-latest
-            node-version: '18.0'
-            # @typescript-eslint/eslint-plugin requires node ^18.18
-            # but we allow yarn install to run regardless to test the package
-            ignore-engines: 'true'
+        no-yarn-lock: ['false', 'true']
+    name: "Tests [Node.js ${{ matrix.node-version }}, ${{ matrix.runs-on }}, ${{ matrix.no-yarn-lock && 'Ignoring yarn.lock' || 'Using yarn.lock'}}]"
     uses: ./.github/workflows/test.yml
     with:
       node-version: ${{ matrix.node-version }}
       runs-on: ${{ matrix.runs-on }}
+      no-yarn-lock: ${{ matrix.no-yarn-lock }}
+      # @typescript-eslint/eslint-plugin requires node ^18.18
+      # but we allow yarn install to run regardless to test the package
+      ignore-engines: ${{ matrix.node-version  == '18.0' && 'true' || 'false'}}
 
   comment-on-pr-for-failures:
     runs-on: ubuntu-latest
@@ -49,5 +50,5 @@ jobs:
               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 }})!',
+              body: 'The nightly workflow `${{ github.workflow }}` failed 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
index 05da26590a..771cdb86a2 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -5,18 +5,23 @@ on:
       node-version:
         type: string
         required: false
-        default: 'ubuntu-latest'
+        default: '20.x'
       runs-on:
         type: string
         required: false
-        default: '20.x'
+        default: 'ubuntu-latest'
       ignore-engines:
         type: string
         required: false
         default: 'false'
+      no-yarn-lock:
+        type: string
+        required: false
+        default: 'false'
+
 jobs:
   test:
-    name: "Tests [Node.js ${{ inputs.node-version }}, ${{ inputs.runs-on }}]"
+    name: "Tests [Node.js ${{ inputs.node-version }}, ${{ inputs.runs-on }}, ${{ inputs.no-yarn-lock && 'Ignoring yarn.lock' || 'Using yarn.lock'}}]"
     runs-on: ${{ inputs.runs-on }}
     steps:
       - uses: actions/checkout@v4
@@ -24,5 +29,6 @@ jobs:
         with:
           node-version: ${{ inputs.node-version }}
           ignore-engines: ${{ inputs.ignore-engines }}
+          no-yarn-lock: ${{ inputs.no-yarn-lock }}
       - name: Run Jest Tests
         run: yarn jest --ci --maxWorkers 4 --reporters=default --reporters=jest-junit --rootdir='./'