From 79d808552ebc313daa75912ff109d38a9a05e067 Mon Sep 17 00:00:00 2001 From: felixshiftellecon Date: Wed, 24 Jul 2024 16:28:42 -0400 Subject: [PATCH] [ci] Add yarn_test_build job to gh actions ghstack-source-id: 5cff9778611acb747c05b9d353bd1af3b11e7d7a Pull Request resolved: https://github.com/facebook/react/pull/30072 --- .circleci/config.yml | 816 ++++++------------ .github/workflows/compiler_playground.yml | 9 +- .github/workflows/compiler_rust.yml | 1 + .github/workflows/compiler_typescript.yml | 17 +- .github/workflows/devtools_check_repro.yml | 3 + .github/workflows/runtime_build_and_test.yml | 609 +++++++++++++ .../workflows/runtime_commit_artifacts.yml | 3 + .github/workflows/runtime_fuzz_tests.yml | 4 + .github/workflows/shared_lint.yml | 19 +- .github/workflows/shared_stale.yml | 3 + 10 files changed, 931 insertions(+), 553 deletions(-) create mode 100644 .github/workflows/runtime_build_and_test.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index a4671f4f58a64..668de8c1a5a83 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,32 +7,6 @@ aliases: - &environment TZ: /usr/share/zoneinfo/America/Los_Angeles - - &restore_yarn_cache_fixtures_dom - restore_cache: - name: Restore yarn cache for fixtures/dom - keys: - - v2-yarn_cache-{{ arch }}-{{ checksum "yarn.lock" }}-fixtures/dom - - - &yarn_install_fixtures_dom - run: - name: Install dependencies in fixtures/dom - working_directory: fixtures/dom - command: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn - - - &yarn_install_fixtures_dom_retry - run: - name: Install dependencies in fixtures/dom (retry) - when: on_fail - working_directory: fixtures/dom - command: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn - - - &save_yarn_cache_fixtures_dom - save_cache: - name: Save yarn cache for fixtures/dom - key: v2-yarn_cache-{{ arch }}-{{ checksum "yarn.lock" }}-fixtures/dom - paths: - - ~/.cache/yarn - - &TEST_PARALLELISM 20 - &attach_workspace @@ -74,518 +48,290 @@ parameters: default: '' jobs: - scrape_warning_messages: - docker: *docker - environment: *environment - - steps: - - checkout - - setup_node_modules - - run: - command: | - mkdir -p ./build/__test_utils__ - node ./scripts/print-warnings/print-warnings.js > build/__test_utils__/ReactAllWarnings.js - - persist_to_workspace: - root: . - paths: - - build - - yarn_build: - docker: *docker - environment: *environment - parallelism: 40 - steps: - - checkout - - setup_node_modules - - run: yarn build --ci=circleci - - persist_to_workspace: - root: . - paths: - - build - - download_build: - docker: *docker - environment: *environment - parameters: - revision: - type: string - steps: - - checkout - - setup_node_modules - - run: - name: Download artifacts for revision - command: | - git fetch origin main - cd ./scripts/release && yarn && cd ../../ - scripts/release/download-experimental-build.js --commit=<< parameters.revision >> --allowBrokenCI - - persist_to_workspace: - root: . - paths: - - build - - download_base_build_for_sizebot: - docker: *docker - environment: *environment - steps: - - checkout - - setup_node_modules - - run: - name: Download artifacts for base revision - command: | - git fetch origin main - cd ./scripts/release && yarn && cd ../../ - scripts/release/download-experimental-build.js --commit=$(git merge-base HEAD origin/main) --allowBrokenCI - mv ./build ./base-build - - - run: - # TODO: The `download-experimental-build` script copies the npm - # packages into the `node_modules` directory. This is a historical - # quirk of how the release script works. Let's pretend they - # don't exist. - name: Delete extraneous files - command: rm -rf ./base-build/node_modules - - - persist_to_workspace: - root: . - paths: - - base-build - - process_artifacts_combined: - docker: *docker - environment: *environment - steps: - - checkout - - attach_workspace: - at: . - - setup_node_modules - - run: echo "<< pipeline.git.revision >>" >> build/COMMIT_SHA - # Compress build directory into a single tarball for easy download - - run: tar -zcvf ./build.tgz ./build - # TODO: Migrate scripts to use `build` directory instead of `build2` - - run: cp ./build.tgz ./build2.tgz - - store_artifacts: - path: ./build2.tgz - - store_artifacts: - path: ./build.tgz - - sizebot: - docker: *docker - environment: *environment - steps: - - checkout - - attach_workspace: - at: . - - run: echo "<< pipeline.git.revision >>" >> build/COMMIT_SHA - - setup_node_modules - - run: - command: node ./scripts/tasks/danger - - store_artifacts: - path: sizebot-message.md - - build_devtools_and_process_artifacts: - docker: *docker - environment: *environment - steps: - - checkout - - attach_workspace: - at: . - - setup_node_modules - - run: - environment: - RELEASE_CHANNEL: experimental - command: ./scripts/circleci/pack_and_store_devtools_artifacts.sh - - store_artifacts: - path: ./build/devtools.tgz - # Simplifies getting the extension for local testing - - store_artifacts: - path: ./build/devtools/chrome-extension.zip - destination: react-devtools-chrome-extension.zip - - store_artifacts: - path: ./build/devtools/firefox-extension.zip - destination: react-devtools-firefox-extension.zip - - run_devtools_e2e_tests: - docker: *docker - environment: *environment - steps: - - checkout - - attach_workspace: - at: . - - setup_node_modules - - run: - name: Playwright install deps - command: | - npx playwright install - sudo npx playwright install-deps - - run: - environment: - RELEASE_CHANNEL: experimental - command: ./scripts/circleci/run_devtools_e2e_tests.js - - run_fixtures_flight_tests: - docker: *docker - environment: *environment - steps: - - checkout - - attach_workspace: - at: . - # Fixture copies some built packages from the workroot after install. - # That means dependencies of the built packages are not installed. - # We need to install dependencies of the workroot to fulfill all dependency constraints - - setup_node_modules - - restore_cache: - name: Restore yarn cache of fixture - keys: - - v2-yarn_cache_fixtures_flight-{{ arch }}-{{ checksum "yarn.lock" }} - - run: - name: Install fixture dependencies - working_directory: fixtures/flight - command: | - yarn install --frozen-lockfile --cache-folder ~/.cache/yarn - if [ $? -ne 0 ]; then - yarn install --frozen-lockfile --cache-folder ~/.cache/yarn - fi - - save_cache: - name: Save yarn cache of fixture - key: v2-yarn_cache_fixtures_flight-{{ arch }}-{{ checksum "yarn.lock" }} - paths: - - ~/.cache/yarn - - run: - working_directory: fixtures/flight - name: Playwright install deps - command: | - npx playwright install - sudo npx playwright install-deps - - run: - name: Run tests - working_directory: fixtures/flight - command: yarn test - environment: - # Otherwise the webserver is a blackbox - DEBUG: pw:webserver - - store_artifacts: - path: fixtures/flight/playwright-report - - store_artifacts: - path: fixtures/flight/test-results - - run_devtools_tests_for_versions: - docker: *docker - environment: *environment - parallelism: *TEST_PARALLELISM - parameters: - version: - type: string - steps: - - checkout - - attach_workspace: - at: . - - setup_node_modules - - run: ./scripts/circleci/download_devtools_regression_build.js << parameters.version >> --replaceBuild - - run: node ./scripts/jest/jest-cli.js --build --project devtools --release-channel=experimental --reactVersion << parameters.version >> --ci=circleci - - run_devtools_e2e_tests_for_versions: - docker: *docker - environment: *environment - parallelism: *TEST_PARALLELISM - parameters: - version: - type: string + # yarn_build: + # docker: *docker + # environment: *environment + # parallelism: 40 + # steps: + # - checkout + # - setup_node_modules + # - run: yarn build --ci=circleci + # - persist_to_workspace: + # root: . + # paths: + # - build + + # download_build: + # docker: *docker + # environment: *environment + # parameters: + # revision: + # type: string + # steps: + # - checkout + # - setup_node_modules + # - run: + # name: Download artifacts for revision + # command: | + # git fetch origin main + # cd ./scripts/release && yarn && cd ../../ + # scripts/release/download-experimental-build.js --commit=<< parameters.revision >> --allowBrokenCI + # - persist_to_workspace: + # root: . + # paths: + # - build + + # process_artifacts_combined: + # docker: *docker + # environment: *environment + # steps: + # - checkout + # - attach_workspace: + # at: . + # - setup_node_modules + # - run: echo "<< pipeline.git.revision >>" >> build/COMMIT_SHA + # - run: | + # mkdir -p ./build/__test_utils__ + # node ./scripts/print-warnings/print-warnings.js > build/__test_utils__/ReactAllWarnings.js + # # Compress build directory into a single tarball for easy download + # - run: tar -zcvf ./build.tgz ./build + # # TODO: Migrate scripts to use `build` directory instead of `build2` + # - run: cp ./build.tgz ./build2.tgz + # - store_artifacts: + # path: ./build2.tgz + # - store_artifacts: + # path: ./build.tgz + + # build_devtools_and_process_artifacts: + # docker: *docker + # environment: *environment + # steps: + # - checkout + # - attach_workspace: + # at: . + # - setup_node_modules + # - run: + # environment: + # RELEASE_CHANNEL: experimental + # command: ./scripts/circleci/pack_and_store_devtools_artifacts.sh + # - store_artifacts: + # path: ./build/devtools.tgz + # # Simplifies getting the extension for local testing + # - store_artifacts: + # path: ./build/devtools/chrome-extension.zip + # destination: react-devtools-chrome-extension.zip + # - store_artifacts: + # path: ./build/devtools/firefox-extension.zip + # destination: react-devtools-firefox-extension.zip + + # run_devtools_e2e_tests: + # docker: *docker + # environment: *environment + # steps: + # - checkout + # - attach_workspace: + # at: . + # - setup_node_modules + # - run: + # name: Playwright install deps + # command: | + # npx playwright install + # sudo npx playwright install-deps + # - run: + # environment: + # RELEASE_CHANNEL: experimental + # command: ./scripts/circleci/run_devtools_e2e_tests.js + + # run_devtools_tests_for_versions: + # docker: *docker + # environment: *environment + # parallelism: *TEST_PARALLELISM + # parameters: + # version: + # type: string + # steps: + # - checkout + # - attach_workspace: + # at: . + # - setup_node_modules + # - run: ./scripts/circleci/download_devtools_regression_build.js << parameters.version >> --replaceBuild + # - run: node ./scripts/jest/jest-cli.js --build --project devtools --release-channel=experimental --reactVersion << parameters.version >> --ci=circleci + + # run_devtools_e2e_tests_for_versions: + # docker: *docker + # environment: *environment + # parallelism: *TEST_PARALLELISM + # parameters: + # version: + # type: string + # steps: + # - checkout + # - attach_workspace: + # at: . + # - setup_node_modules + # - run: + # name: Playwright install deps + # command: | + # npx playwright install + # sudo npx playwright install-deps + # - run: ./scripts/circleci/download_devtools_regression_build.js << parameters.version >> + # - run: + # environment: + # RELEASE_CHANNEL: experimental + # command: ./scripts/circleci/run_devtools_e2e_tests.js << parameters.version >> + # - run: + # name: Cleanup build regression folder + # command: rm -r ./build-regression + # - store_artifacts: + # path: ./tmp/screenshots + + # publish_prerelease: + # parameters: + # commit_sha: + # type: string + # release_channel: + # type: string + # dist_tag: + # type: string + # docker: *docker + # environment: *environment + # steps: + # - checkout + # - setup_node_modules + # - run: + # name: Run publish script + # command: | + # git fetch origin main + # cd ./scripts/release && yarn && cd ../../ + # scripts/release/prepare-release-from-ci.js --skipTests -r << parameters.release_channel >> --commit=<< parameters.commit_sha >> + # cp ./scripts/release/ci-npmrc ~/.npmrc + # scripts/release/publish.js --ci --tags << parameters.dist_tag >> + + test_job: + docker: + - image: cimg/base:stable + resource_class: small steps: - - checkout - - attach_workspace: - at: . - - setup_node_modules - run: - name: Playwright install deps + name: Where am I? command: | - npx playwright install - sudo npx playwright install-deps - - run: ./scripts/circleci/download_devtools_regression_build.js << parameters.version >> - - run: - environment: - RELEASE_CHANNEL: experimental - command: ./scripts/circleci/run_devtools_e2e_tests.js << parameters.version >> - - run: - name: Cleanup build regression folder - command: rm -r ./build-regression - - store_artifacts: - path: ./tmp/screenshots - - yarn_lint_build: - docker: *docker - environment: *environment - steps: - - checkout - - attach_workspace: - at: . - - setup_node_modules - - run: yarn lint-build - - yarn_check_release_dependencies: - docker: *docker - environment: *environment - steps: - - checkout - - attach_workspace: - at: . - - setup_node_modules - - run: yarn check-release-dependencies - - - check_error_codes: - docker: *docker - environment: *environment - steps: - - checkout - - attach_workspace: *attach_workspace - - setup_node_modules - - run: - name: Search build artifacts for unminified errors - command: | - yarn extract-errors - git diff --quiet || (echo "Found unminified errors. Either update the error codes map or disable error minification for the affected build, if appropriate." && false) - - yarn_test_build: - docker: *docker - environment: *environment - parallelism: *TEST_PARALLELISM - parameters: - args: - type: string - steps: - - checkout - - attach_workspace: - at: . - - setup_node_modules - - run: yarn test --build <> --ci=circleci - - RELEASE_CHANNEL_stable_yarn_test_dom_fixtures: - docker: *docker - environment: *environment - steps: - - checkout - - attach_workspace: - at: . - - setup_node_modules - - *restore_yarn_cache_fixtures_dom - - *yarn_install_fixtures_dom - - *yarn_install_fixtures_dom_retry - - *save_yarn_cache_fixtures_dom - - run: - name: Run DOM fixture tests - environment: - RELEASE_CHANNEL: stable - working_directory: fixtures/dom - command: | - yarn predev - yarn test --maxWorkers=2 - - publish_prerelease: - parameters: - commit_sha: - type: string - release_channel: - type: string - dist_tag: - type: string - docker: *docker - environment: *environment - steps: - - checkout - - setup_node_modules - - run: - name: Run publish script - command: | - git fetch origin main - cd ./scripts/release && yarn && cd ../../ - scripts/release/prepare-release-from-ci.js --skipTests -r << parameters.release_channel >> --commit=<< parameters.commit_sha >> - cp ./scripts/release/ci-npmrc ~/.npmrc - scripts/release/publish.js --ci --tags << parameters.dist_tag >> - + echo "Running on branch << pipeline.git.branch >> " + echo "" + echo "" + echo "Running on commit << pipeline.git.revision >>" workflows: - build_and_test: - unless: << pipeline.parameters.prerelease_commit_sha >> - jobs: - - yarn_build: - filters: - branches: - ignore: - - builds/facebook-www - - scrape_warning_messages: - filters: - branches: - ignore: - - builds/facebook-www - - process_artifacts_combined: - requires: - - scrape_warning_messages - - yarn_build - - yarn_test_build: - requires: - - yarn_build - matrix: - parameters: - args: - # Intentionally passing these as strings instead of creating a - # separate parameter per CLI argument, since it's easier to - # control/see which combinations we want to run. - - "-r=stable --env=development" - - "-r=stable --env=production" - - "-r=experimental --env=development" - - "-r=experimental --env=production" - - # Dev Tools - - "--project=devtools -r=experimental" - - # TODO: Update test config to support www build tests - # - "-r=www-classic --env=development --variant=false" - # - "-r=www-classic --env=production --variant=false" - # - "-r=www-classic --env=development --variant=true" - # - "-r=www-classic --env=production --variant=true" - # - "-r=www-modern --env=development --variant=false" - # - "-r=www-modern --env=production --variant=false" - # - "-r=www-modern --env=development --variant=true" - # - "-r=www-modern --env=production --variant=true" - - # TODO: Update test config to support xplat build tests - # - "-r=xplat --env=development --variant=false" - # - "-r=xplat --env=development --variant=true" - # - "-r=xplat --env=production --variant=false" - # - "-r=xplat --env=production --variant=true" - - # TODO: Test more persistent configurations? - - download_base_build_for_sizebot: - filters: - branches: - ignore: - - main - - builds/facebook-www - - sizebot: - filters: - branches: - ignore: - - main - requires: - - download_base_build_for_sizebot - - yarn_build - - yarn_lint_build: - requires: - - yarn_build - - yarn_check_release_dependencies: - requires: - - yarn_build - - check_error_codes: - requires: - - yarn_build - - RELEASE_CHANNEL_stable_yarn_test_dom_fixtures: - requires: - - yarn_build - - build_devtools_and_process_artifacts: - requires: - - yarn_build - - run_devtools_e2e_tests: - requires: - - build_devtools_and_process_artifacts - - run_fixtures_flight_tests: - requires: - - yarn_build - - devtools_regression_tests: - unless: << pipeline.parameters.prerelease_commit_sha >> - triggers: - - schedule: - # DevTools regression tests run once a day - cron: "0 0 * * *" - filters: - branches: - only: - - main - jobs: - - download_build: - revision: << pipeline.git.revision >> - - build_devtools_and_process_artifacts: - requires: - - download_build - - run_devtools_tests_for_versions: - requires: - - build_devtools_and_process_artifacts - matrix: - parameters: - version: - - "16.0" - - "16.5" # schedule package - - "16.8" # hooks - - "17.0" - - "18.0" - - run_devtools_e2e_tests_for_versions: - requires: - - build_devtools_and_process_artifacts - matrix: - parameters: - version: - - "16.0" - - "16.5" # schedule package - - "16.8" # hooks - - "17.0" - - "18.0" - - # Used to publish a prerelease manually via the command line - publish_preleases: - when: << pipeline.parameters.prerelease_commit_sha >> - jobs: - - publish_prerelease: - name: Publish to Canary channel - commit_sha: << pipeline.parameters.prerelease_commit_sha >> - release_channel: stable - # The tags to use when publishing canaries. The main one we should - # always include is "canary" but we can use multiple (e.g. alpha, - # beta, rc). To declare multiple, use a comma-separated string, like - # this: - # dist_tag: "canary,alpha,beta,rc" - # - # TODO: We currently tag canaries with "next" in addition to "canary" - # because this used to be called the "next" channel and some - # downstream consumers might still expect that tag. We can remove this - # after some time has elapsed and the change has been communicated. - dist_tag: "canary,next,rc" - - publish_prerelease: - name: Publish to Experimental channel - requires: - # NOTE: Intentionally running these jobs sequentially because npm - # will sometimes fail if you try to concurrently publish two - # different versions of the same package, even if they use different - # dist tags. - - Publish to Canary channel - commit_sha: << pipeline.parameters.prerelease_commit_sha >> - release_channel: experimental - dist_tag: experimental - - # Publishes on a cron schedule - publish_preleases_nightly: - unless: << pipeline.parameters.prerelease_commit_sha >> - triggers: - - schedule: - # At 10 minutes past 16:00 on Mon, Tue, Wed, Thu, and Fri - cron: "10 16 * * 1,2,3,4,5" - filters: - branches: - only: - - main + test_workflow: jobs: - - publish_prerelease: - name: Publish to Canary channel - commit_sha: << pipeline.git.revision >> - release_channel: stable - dist_tag: "canary,next,rc" - - publish_prerelease: - name: Publish to Experimental channel - requires: - # NOTE: Intentionally running these jobs sequentially because npm - # will sometimes fail if you try to concurrently publish two - # different versions of the same package, even if they use different - # dist tags. - - Publish to Canary channel - commit_sha: << pipeline.git.revision >> - release_channel: experimental - dist_tag: experimental + - test_job + + # # build_and_test: + # # unless: << pipeline.parameters.prerelease_commit_sha >> + # # jobs: + # # - yarn_build: + # # filters: + # # branches: + # # ignore: + # # - builds/facebook-www + # # - process_artifacts_combined: + # # requires: + # # - yarn_build + + # devtools_regression_tests: + # unless: << pipeline.parameters.prerelease_commit_sha >> + # triggers: + # - schedule: + # # DevTools regression tests run once a day + # cron: "0 0 * * *" + # filters: + # branches: + # only: + # - main + # jobs: + # - download_build: + # revision: << pipeline.git.revision >> + # - build_devtools_and_process_artifacts: + # requires: + # - download_build + # - run_devtools_tests_for_versions: + # requires: + # - build_devtools_and_process_artifacts + # matrix: + # parameters: + # version: + # - "16.0" + # - "16.5" # schedule package + # - "16.8" # hooks + # - "17.0" + # - "18.0" + # - run_devtools_e2e_tests_for_versions: + # requires: + # - build_devtools_and_process_artifacts + # matrix: + # parameters: + # version: + # - "16.0" + # - "16.5" # schedule package + # - "16.8" # hooks + # - "17.0" + # - "18.0" + + # # Used to publish a prerelease manually via the command line + # publish_preleases: + # when: << pipeline.parameters.prerelease_commit_sha >> + # jobs: + # - publish_prerelease: + # name: Publish to Canary channel + # commit_sha: << pipeline.parameters.prerelease_commit_sha >> + # release_channel: stable + # # The tags to use when publishing canaries. The main one we should + # # always include is "canary" but we can use multiple (e.g. alpha, + # # beta, rc). To declare multiple, use a comma-separated string, like + # # this: + # # dist_tag: "canary,alpha,beta,rc" + # # + # # TODO: We currently tag canaries with "next" in addition to "canary" + # # because this used to be called the "next" channel and some + # # downstream consumers might still expect that tag. We can remove this + # # after some time has elapsed and the change has been communicated. + # dist_tag: "canary,next,rc" + # - publish_prerelease: + # name: Publish to Experimental channel + # requires: + # # NOTE: Intentionally running these jobs sequentially because npm + # # will sometimes fail if you try to concurrently publish two + # # different versions of the same package, even if they use different + # # dist tags. + # - Publish to Canary channel + # commit_sha: << pipeline.parameters.prerelease_commit_sha >> + # release_channel: experimental + # dist_tag: experimental + + # # Publishes on a cron schedule + # publish_preleases_nightly: + # unless: << pipeline.parameters.prerelease_commit_sha >> + # triggers: + # - schedule: + # # At 10 minutes past 16:00 on Mon, Tue, Wed, Thu, and Fri + # cron: "10 16 * * 1,2,3,4,5" + # filters: + # branches: + # only: + # - main + # jobs: + # - publish_prerelease: + # name: Publish to Canary channel + # commit_sha: << pipeline.git.revision >> + # release_channel: stable + # dist_tag: "canary,next,rc" + # - publish_prerelease: + # name: Publish to Experimental channel + # requires: + # # NOTE: Intentionally running these jobs sequentially because npm + # # will sometimes fail if you try to concurrently publish two + # # different versions of the same package, even if they use different + # # dist tags. + # - Publish to Canary channel + # commit_sha: << pipeline.git.revision >> + # release_channel: experimental + # dist_tag: experimental diff --git a/.github/workflows/compiler_playground.yml b/.github/workflows/compiler_playground.yml index 7f2a75d324d77..eb48a9b210b22 100644 --- a/.github/workflows/compiler_playground.yml +++ b/.github/workflows/compiler_playground.yml @@ -5,9 +5,12 @@ on: branches: [main] pull_request: paths: - - "compiler/**" + - compiler/** - .github/workflows/compiler-playground.yml +env: + TZ: /usr/share/zoneinfo/America/Los_Angeles + defaults: run: working-directory: compiler @@ -20,8 +23,8 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 18.x - cache: "yarn" + node-version: 18.20.1 + cache: yarn cache-dependency-path: compiler/yarn.lock - name: Restore cached node_modules uses: actions/cache@v4 diff --git a/.github/workflows/compiler_rust.yml b/.github/workflows/compiler_rust.yml index cf911b9d476b3..3cda1325ca49e 100644 --- a/.github/workflows/compiler_rust.yml +++ b/.github/workflows/compiler_rust.yml @@ -18,6 +18,7 @@ on: env: CARGO_TERM_COLOR: always RUSTFLAGS: -Dwarnings + TZ: /usr/share/zoneinfo/America/Los_Angeles defaults: run: diff --git a/.github/workflows/compiler_typescript.yml b/.github/workflows/compiler_typescript.yml index 233e963bfad74..8576f66a10057 100644 --- a/.github/workflows/compiler_typescript.yml +++ b/.github/workflows/compiler_typescript.yml @@ -5,9 +5,12 @@ on: branches: [main] pull_request: paths: - - "compiler/**" + - compiler/** - .github/workflows/compiler-typescript.yml +env: + TZ: /usr/share/zoneinfo/America/Los_Angeles + defaults: run: working-directory: compiler @@ -31,8 +34,8 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 18.x - cache: "yarn" + node-version: 18.20.1 + cache: yarn cache-dependency-path: compiler/yarn.lock - name: Restore cached node_modules uses: actions/cache@v4 @@ -50,8 +53,8 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 18.x - cache: "yarn" + node-version: 18.20.1 + cache: yarn cache-dependency-path: compiler/yarn.lock - name: Restore cached node_modules uses: actions/cache@v4 @@ -74,8 +77,8 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 18.x - cache: "yarn" + node-version: 18.20.1 + cache: yarn cache-dependency-path: compiler/yarn.lock - name: Restore cached node_modules uses: actions/cache@v4 diff --git a/.github/workflows/devtools_check_repro.yml b/.github/workflows/devtools_check_repro.yml index adaef6ac32bd6..735371e3a8f7d 100644 --- a/.github/workflows/devtools_check_repro.yml +++ b/.github/workflows/devtools_check_repro.yml @@ -5,6 +5,9 @@ on: issue_comment: types: [created, edited] +env: + TZ: /usr/share/zoneinfo/America/Los_Angeles + jobs: check-repro: runs-on: ubuntu-latest diff --git a/.github/workflows/runtime_build_and_test.yml b/.github/workflows/runtime_build_and_test.yml new file mode 100644 index 0000000000000..2cf5011a0012a --- /dev/null +++ b/.github/workflows/runtime_build_and_test.yml @@ -0,0 +1,609 @@ +name: (Runtime) Build and Test + +on: + push: + branches: [main] + pull_request: + paths-ignore: + - compiler/** + +env: + TZ: /usr/share/zoneinfo/America/Los_Angeles + +jobs: + # ----- FLOW ----- + discover_flow_inline_configs: + name: Discover flow inline configs + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.result }} + steps: + - uses: actions/checkout@v4 + - uses: actions/github-script@v7 + id: set-matrix + with: + script: | + const inlinedHostConfigs = require('./scripts/shared/inlinedHostConfigs.js'); + return inlinedHostConfigs.map(config => config.shortName); + + flow: + name: Flow check ${{ matrix.flow_inline_config_shortname }} + needs: discover_flow_inline_configs + runs-on: ubuntu-latest + continue-on-error: true + strategy: + matrix: + flow_inline_config_shortname: ${{ fromJSON(needs.discover_flow_inline_configs.outputs.matrix) }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - run: node ./scripts/tasks/flow-ci ${{ matrix.flow_inline_config_shortname }} + + # ----- FIZZ ----- + check_generated_fizz_runtime: + name: Confirm generated inline Fizz runtime is up to date + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - run: | + yarn generate-inline-fizz-runtime + git diff --quiet || (echo "There was a change to the Fizz runtime. Run `yarn generate-inline-fizz-runtime` and check in the result." && false) + + # ----- FEATURE FLAGS ----- + flags: + name: Check flags + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - run: yarn flags + + # ----- TESTS ----- + test: + name: yarn test ${{ matrix.params }} (Shard ${{ matrix.shard }}) + runs-on: ubuntu-latest + strategy: + matrix: + params: + - "-r=stable --env=development" + - "-r=stable --env=production" + - "-r=experimental --env=development" + - "-r=experimental --env=production" + - "-r=www-classic --env=development --variant=false" + - "-r=www-classic --env=production --variant=false" + - "-r=www-classic --env=development --variant=true" + - "-r=www-classic --env=production --variant=true" + - "-r=www-modern --env=development --variant=false" + - "-r=www-modern --env=production --variant=false" + - "-r=www-modern --env=development --variant=true" + - "-r=www-modern --env=production --variant=true" + - "-r=xplat --env=development --variant=false" + - "-r=xplat --env=development --variant=true" + - "-r=xplat --env=production --variant=false" + - "-r=xplat --env=production --variant=true" + # TODO: Test more persistent configurations? + - "-r=stable --env=development --persistent" + - "-r=experimental --env=development --persistent" + shard: + - 1/5 + - 2/5 + - 3/5 + - 4/5 + - 5/5 + continue-on-error: true + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - run: yarn test ${{ matrix.params }} --ci=github --shard=${{ matrix.shard }} + + # ----- BUILD ----- + build_and_lint: + name: yarn build and lint + runs-on: ubuntu-latest + strategy: + matrix: + # yml is dumb. update the --total arg to yarn build if you change the number of workers + worker_id: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19] + release_channel: [stable, experimental] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 11.0.22 + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - run: yarn build --index=${{ matrix.worker_id }} --total=20 --r=${{ matrix.release_channel }} --ci=github + env: + CI: github + RELEASE_CHANNEL: ${{ matrix.release_channel }} + NODE_INDEX: ${{ matrix.worker_id }} + - name: Lint build + run: yarn lint-build + - name: Display structure of build + run: ls -R build + - name: Archive build + uses: actions/upload-artifact@v4 + with: + name: _build_${{ matrix.worker_id }}_${{ matrix.release_channel }} + path: build + + test_build: + name: yarn test-build + needs: build_and_lint + strategy: + matrix: + test_params: [ + # Intentionally passing these as strings instead of creating a + # separate parameter per CLI argument, since it's easier to + # control/see which combinations we want to run. + -r=stable --env=development, + -r=stable --env=production, + -r=experimental --env=development, + -r=experimental --env=production, + + # Dev Tools + --project=devtools -r=experimental, + + # TODO: Update test config to support www build tests + # - "-r=www-classic --env=development --variant=false" + # - "-r=www-classic --env=production --variant=false" + # - "-r=www-classic --env=development --variant=true" + # - "-r=www-classic --env=production --variant=true" + # - "-r=www-modern --env=development --variant=false" + # - "-r=www-modern --env=production --variant=false" + # - "-r=www-modern --env=development --variant=true" + # - "-r=www-modern --env=production --variant=true" + + # TODO: Update test config to support xplat build tests + # - "-r=xplat --env=development --variant=false" + # - "-r=xplat --env=development --variant=true" + # - "-r=xplat --env=production --variant=false" + # - "-r=xplat --env=production --variant=true" + + # TODO: Test more persistent configurations? + ] + shard: + - 1/3 + - 2/3 + - 3/3 + continue-on-error: true + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - name: Restore archived build + uses: actions/download-artifact@v4 + with: + pattern: _build_* + path: build + merge-multiple: true + - name: Display structure of build + run: ls -R build + - run: yarn test --build ${{ matrix.test_params }} --shard=${{ matrix.shard }} --ci=github + + process_artifacts_combined: + name: Process artifacts combined + needs: build_and_lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - name: Restore archived build + uses: actions/download-artifact@v4 + with: + pattern: _build_* + path: build + merge-multiple: true + - name: Display structure of build + run: ls -R build + - run: echo ${{ github.sha }} >> build/COMMIT_SHA + - name: Scrape warning messages + run: | + mkdir -p ./build/__test_utils__ + node ./scripts/print-warnings/print-warnings.js > build/__test_utils__/ReactAllWarnings.js + # Compress build directory into a single tarball for easy download + - run: tar -zcvf ./build.tgz ./build + # TODO: Migrate scripts to use `build` directory instead of `build2` + - run: cp ./build.tgz ./build2.tgz + - name: Archive build artifacts + uses: actions/upload-artifact@v4 + with: + name: artifacts_combined + path: | + ./build.tgz + ./build2.tgz + + check_error_codes: + name: Search build artifacts for unminified errors + needs: build_and_lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - name: Restore archived build + uses: actions/download-artifact@v4 + with: + pattern: _build_* + path: build + merge-multiple: true + - name: Display structure of build + run: ls -R build + - name: Search build artifacts for unminified errors + run: | + yarn extract-errors + git diff --quiet || (echo "Found unminified errors. Either update the error codes map or disable error minification for the affected build, if appropriate." && false) + + check_release_dependencies: + name: Check release dependencies + needs: build_and_lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - name: Restore archived build + uses: actions/download-artifact@v4 + with: + pattern: _build_* + path: build + merge-multiple: true + - name: Display structure of build + run: ls -R build + - run: yarn check-release-dependencies + + RELEASE_CHANNEL_stable_yarn_test_dom_fixtures: + name: Check fixtures DOM (stable) + needs: build_and_lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: v2-yarn_cache_fixtures_dom-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - run: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn + working-directory: fixtures/dom + - name: Restore archived build + uses: actions/download-artifact@v4 + with: + pattern: _build_* + path: build + merge-multiple: true + - name: Display structure of build + run: ls -R build + - name: Run DOM fixture tests + run: | + yarn predev + yarn test + working-directory: fixtures/dom + env: + RELEASE_CHANNEL: stable + + # ----- FLIGHT ----- + run_fixtures_flight_tests: + name: Run fixtures Flight tests + needs: build_and_lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + # Fixture copies some built packages from the workroot after install. + # That means dependencies of the built packages are not installed. + # We need to install dependencies of the workroot to fulfill all dependency constraints + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: v2-yarn_cache_fixtures_flight-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - name: Restore archived build + uses: actions/download-artifact@v4 + with: + pattern: _build_* + path: build + merge-multiple: true + - name: Display structure of build + run: ls -R build + - name: Install fixture dependencies + working-directory: fixtures/flight + run: | + yarn install --frozen-lockfile --cache-folder ~/.cache/yarn + if [ $? -ne 0 ]; then + yarn install --frozen-lockfile --cache-folder ~/.cache/yarn + fi + - name: Playwright install deps + working-directory: fixtures/flight + run: | + npx playwright install + sudo npx playwright install-deps + - name: Run tests + working-directory: fixtures/flight + run: yarn test + env: + # Otherwise the webserver is a blackbox + DEBUG: pw:webserver + - name: Archive Flight fixture artifacts + uses: actions/upload-artifact@v4 + with: + name: flight-playwright-report + path: fixtures/flight/playwright-report + - name: Archive Flight fixture artifacts + uses: actions/upload-artifact@v4 + with: + name: flight-test-results + path: fixtures/flight/test-results + + # ----- DEVTOOLS ----- + build_devtools_and_process_artifacts: + name: Build DevTools and process artifacts + needs: build_and_lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - name: Restore archived build + uses: actions/download-artifact@v4 + with: + pattern: _build_* + path: build + merge-multiple: true + - run: ./scripts/circleci/pack_and_store_devtools_artifacts.sh + env: + RELEASE_CHANNEL: experimental + - name: Display structure of build + run: ls -R build + - name: Archive devtools build + uses: actions/upload-artifact@v4 + with: + name: react-devtools + path: build/devtools.tgz + # Simplifies getting the extension for local testing + - name: Archive chrome extension + uses: actions/upload-artifact@v4 + with: + name: react-devtools-chrome-extension + path: build/devtools/chrome-extension.zip + - name: Archive firefox extension + uses: actions/upload-artifact@v4 + with: + name: react-devtools-firefox-extension + path: build/devtools/firefox-extension.zip + + run_devtools_e2e_tests: + name: Run DevTools e2e tests + needs: build_devtools_and_process_artifacts + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - name: Restore archived build + uses: actions/download-artifact@v4 + with: + pattern: _build_* + path: build + merge-multiple: true + - run: | + npx playwright install + sudo npx playwright install-deps + - run: ./scripts/circleci/run_devtools_e2e_tests.js + env: + RELEASE_CHANNEL: experimental + + # ----- SIZEBOT ----- + download_base_build_for_sizebot: + if: ${{ github.event_name == 'pull_request' && github.ref_name != 'main' }} + name: Download base build for sizebot + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock', 'scripts/release/yarn.lock') }} + - run: yarn install --frozen-lockfile + - run: yarn install --frozen-lockfile + working-directory: scripts/release + - name: Download artifacts for base revision + run: | + git fetch origin main + GH_TOKEN=${{ github.token }} scripts/release/download-experimental-build-ghaction.js --commit=$(git rev-parse origin/main) + mv ./build ./base-build + # TODO: The `download-experimental-build` script copies the npm + # packages into the `node_modules` directory. This is a historical + # quirk of how the release script works. Let's pretend they + # don't exist. + - name: Delete extraneous files + run: rm -rf ./base-build/node_modules + - name: Display structure of base-build + run: ls -R base-build + - name: Archive base-build + uses: actions/upload-artifact@v4 + with: + name: base-build + path: base-build + + sizebot: + name: Run sizebot + needs: [build_and_lint, download_base_build_for_sizebot] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18.20.1 + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - name: Restore archived build for PR + uses: actions/download-artifact@v4 + with: + pattern: _build_* + path: build + merge-multiple: true + - name: Scrape warning messages + run: | + mkdir -p ./build/__test_utils__ + node ./scripts/print-warnings/print-warnings.js > build/__test_utils__/ReactAllWarnings.js + - name: Display structure of build for PR + run: ls -R build + - name: Restore archived base-build from origin/main + uses: actions/download-artifact@v4 + with: + name: base-build + path: base-build + - name: Display structure of base-build from origin/main + run: ls -R base-build + - run: echo ${{ github.sha }} >> build/COMMIT_SHA + - run: node ./scripts/tasks/danger + - name: Archive sizebot results + uses: actions/upload-artifact@v4 + with: + name: sizebot-message + path: sizebot-message.md diff --git a/.github/workflows/runtime_commit_artifacts.yml b/.github/workflows/runtime_commit_artifacts.yml index 2c32281634c7c..c665f9b1bd40e 100644 --- a/.github/workflows/runtime_commit_artifacts.yml +++ b/.github/workflows/runtime_commit_artifacts.yml @@ -4,6 +4,9 @@ on: push: branches: [main, meta-www, meta-fbsource] +env: + TZ: /usr/share/zoneinfo/America/Los_Angeles + jobs: download_artifacts: runs-on: ubuntu-latest diff --git a/.github/workflows/runtime_fuzz_tests.yml b/.github/workflows/runtime_fuzz_tests.yml index 5b31d115dcd23..dac4dd095a8d4 100644 --- a/.github/workflows/runtime_fuzz_tests.yml +++ b/.github/workflows/runtime_fuzz_tests.yml @@ -9,6 +9,10 @@ on: inputs: prerelease_commit_sha: required: false + +env: + TZ: /usr/share/zoneinfo/America/Los_Angeles + jobs: test_fuzz: if: inputs.prerelease_commit_sha == '' diff --git a/.github/workflows/shared_lint.yml b/.github/workflows/shared_lint.yml index ca851ff2324bf..e06637b168bf9 100644 --- a/.github/workflows/shared_lint.yml +++ b/.github/workflows/shared_lint.yml @@ -5,6 +5,9 @@ on: branches: [main] pull_request: +env: + TZ: /usr/share/zoneinfo/America/Los_Angeles + jobs: prettier: name: Run prettier @@ -13,8 +16,8 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 18.x - cache: "yarn" + node-version: 18.20.1 + cache: yarn cache-dependency-path: yarn.lock - name: Restore cached node_modules uses: actions/cache@v4 @@ -31,8 +34,8 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 18.x - cache: "yarn" + node-version: 18.20.1 + cache: yarn cache-dependency-path: yarn.lock - name: Restore cached node_modules uses: actions/cache@v4 @@ -49,8 +52,8 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 18.x - cache: "yarn" + node-version: 18.20.1 + cache: yarn cache-dependency-path: yarn.lock - name: Restore cached node_modules uses: actions/cache@v4 @@ -67,8 +70,8 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 18.x - cache: "yarn" + node-version: 18.20.1 + cache: yarn cache-dependency-path: yarn.lock - name: Restore cached node_modules uses: actions/cache@v4 diff --git a/.github/workflows/shared_stale.yml b/.github/workflows/shared_stale.yml index df9854c270a28..9135b9afcaaeb 100644 --- a/.github/workflows/shared_stale.yml +++ b/.github/workflows/shared_stale.yml @@ -5,6 +5,9 @@ on: # Run hourly - cron: '0 * * * *' +env: + TZ: /usr/share/zoneinfo/America/Los_Angeles + jobs: stale: runs-on: ubuntu-latest