Repository: angular
Issue: Enable all Angular Bazel Tests on Windows
Labels: type: bug/fix,area: build & ci,freq2: medium,area: bazel,windows,P3

# 🐞 bug report

### Is this a regression?

Nope


### Description

Angular tests are only partially enabled on Windows:

https://github.com/angular/angular/blob/1102b02406ca9fac7cfc7059bc61b4d40d3dd378/.codefresh/codefresh.yml#L22-L24

To have better Windows support, we should be able to run all tests on Windows, that is:
```
bazel test //... --build_tag_filters=-ivy-only --test_tag_filters=-ivy-only
yarn test-ivy-aot //...
```
(IIUC, `yarn test-ivy-aot //...` is essentially `bazel test --define=compile=aot --build_tag_filters=-no-ivy-aot,-fixme-ivy-aot --test_tag_filters=-no-ivy-aot,-fixme-ivy-aot //...`)

I tried to run all tests without `ivy-only` with Bazel 0.24.1 and got 
```
Executed 102 out of 175 tests: 86 tests pass, 72 fail to build and 17 fail locally.
```
See full detail at [Angular test with Bazel 0.24.1](https://gist.github.com/meteorcloudy/e1d88b35ff1075e5e9c18f5a80f9aedd)

It turned out all broken tests are because `powershell.exe` is not available when using `--incompatible_strict_action_env`. So I sent a change in Bazel to fix this problem. https://github.com/bazelbuild/bazel/commit/6e752195f0b0c6d67822368b82c990dff168a258

With Bazel@6e75219, after working around some incompatibility issues, I'm able to build and run all Angular tests on Windows. The results are:

- [Angular tests with Bazel@6e75219, excluding `ivy-only`](https://gist.github.com/meteorcloudy/a213a349e88095ef7f9dfe96e1561393)
```
Executed 175 out of 175 tests: 152 tests pass and 23 fail locally.
```

- [Angular tests with Bazel@6e75219, `ivy-only`](https://gist.github.com/meteorcloudy/97d57d4aefd03988efbc1efdf1d0fa09)
```
Executed 7 out of 147 tests: 140 tests pass and 7 fail locally.
```

Current TODO list is:

- [ ] Wait for a Bazel release that contains https://github.com/bazelbuild/bazel/commit/6e752195f0b0c6d67822368b82c990dff168a258, should be 0.26 (Do you prefer this to be cherry-pick into 0.25, so that we can have it this month?)
- [ ] Fix incompatibility issues:
    1. https://github.com/angular/angular/pull/29777
    2. `bazel-0.24.1 build --nobuild //... --incompatible_bzl_disallow_load_after_statement`
    3. Wait for a fix (https://github.com/google/brotli/pull/748) for brotli, then update org_brotli
- [ ] Look into failing tests with Bazel@6e75219, will provide a way to reproduce.


## 🔬 Minimal Reproduction
```
# Get Bazel binary built at 6e752195f0b0c6d67822368b82c990dff168a258
wget https://storage.googleapis.com/bazel-builds/artifacts/windows/6e752195f0b0c6d67822368b82c990dff168a258/bazel -O <your preferred Bazel path (with .exe extension)>

# Cherry-pick https://github.com/angular/angular/pull/29777 if it's still not merged.

# Run tests except ivy-only
bazel test //... --build_tag_filters=-ivy-only --test_tag_filters=-ivy-only --incompatible_bzl_disallow_load_after_statement=false

# Run ivy-only tests 
bazel test //... --define=compile=aot --build_tag_filters=-no-ivy-aot,-fixme-ivy-aot --test_tag_filters=-no-ivy-aot,-fixme-ivy-aot --incompatible_bzl_disallow_load_after_statement=false
```
Note that we still need `--incompatible_bzl_disallow_load_after_statement=false` until the incompatibility issue is fixed.

If you failed to build brotli, you can use the following in `packages/bazel/package.bzl`:
```
    http_archive(
        name = "org_brotli",
        sha256 = "44ebae3308fd1a757fdc4891e1e1e61ab964afb223ba298d2ea0c29a49564f53",
        strip_prefix = "brotli-7388ebb113f0e1dbf4ab0f2daddf036abf29b8e6",
        url = "https://github.com/meteorcloudy/brotli/archive/7388ebb113f0e1dbf4ab0f2daddf036abf29b8e6.zip",
    )
```

## 🌍  Your Environment

**Angular Version:**
<pre><code>
ec5635430630fb895ddb43017f9939564824e8f8
</code></pre>


@alexeagle @filipesilva Can you point this issue to correct people in Angular Windows team? I will also continue to help investigating.