From f9939757d3f614cf3890d1beb568ba9ab255bea4 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Tue, 12 Sep 2023 13:23:52 +0200 Subject: [PATCH] build: skip simulated file system tests on Windows (#51738) The code for detecting a Windows CI run from #51701 didn't work, because Bazel isolates the environment variables. These changes work around the issue by passing in a custom variable with the `--test_env` flag. PR Close #51738 --- .github/workflows/ci.yml | 5 ++++- .../src/ngtsc/file_system/testing/src/test_helper.ts | 10 ++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd3052d0ef9..b45b0c49dfd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,7 +89,10 @@ jobs: - name: Install node modules run: yarn install --frozen-lockfile --network-timeout 100000 - name: Test all windows CI targets - run: bazel test --test_tag_filters="-browser:chromium-local" //packages/compiler-cli/... + # Skip the simulated file system tests on Windows, because they tend to be flaky. + # Note that we need to pass `NG_SKIP_SIMULATED_FS` using `--test_env`, because the + # environment variable doesn't get picked up in Bazel when specified through `env` in GHA. + run: bazel test --test_tag_filters="-browser:chromium-local" --test_env=NG_SKIP_SIMULATED_FS=true //packages/compiler-cli/... test: runs-on: ubuntu-latest-4core diff --git a/packages/compiler-cli/src/ngtsc/file_system/testing/src/test_helper.ts b/packages/compiler-cli/src/ngtsc/file_system/testing/src/test_helper.ts index bf56b8ebe83..8eb5b69061d 100644 --- a/packages/compiler-cli/src/ngtsc/file_system/testing/src/test_helper.ts +++ b/packages/compiler-cli/src/ngtsc/file_system/testing/src/test_helper.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ /// -import {platform} from 'os'; import ts from 'typescript'; import {absoluteFrom, setFileSystem} from '../../src/helpers'; @@ -39,13 +38,8 @@ const FS_WINDOWS = 'Windows'; const FS_ALL = [FS_OS_X, FS_WINDOWS, FS_UNIX, FS_NATIVE]; function runInEachFileSystemFn(callback: (os: string) => void) { - const isOnCi = !!(process.env['CI'] || process.env['CIRCLECI'] || process.env['GITHUB_ACTION']); - - // At the time of writing, running the compiler tests on the CI on Windows is flaky and it - // appears to be related to mocking out the file system. Since we're running the mocked file - // system on the other platforms, we don't have to do so on Windows as well. This logic - // disables the mocking to try and reduce the amount of flakes. - if (isOnCi && platform() === 'win32') { + // Some CI checks need to disable the simulated file system tests. + if (process.env['NG_SKIP_SIMULATED_FS']) { runInFileSystem(FS_NATIVE, callback, false); } else { FS_ALL.forEach(os => runInFileSystem(os, callback, false));