Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move windows test app to react-native-test-app #552

Closed
wants to merge 35 commits into from

Conversation

Saadnajmi
Copy link
Collaborator

@Saadnajmi Saadnajmi commented Nov 2, 2020

Platforms Impacted

  • iOS
  • macOS
  • win32 (Office)
  • windows
  • android

Description of changes

We use react-native-test-app to handle the native code of our android, iOS, and macOS test apps, rather than us creating native projects for each and checking in the native code. As of 0.2.0, react-native-test-app added support for windows. Let's move move the windows test app to use react-native-test-app as well.

With this change, all platforms (except win32, which doesn't seem to have any native code anyway) now use react-native-test-app. Perhaps we could then combine the test apps back into apps/fluent-tester now?

Steps:

  • Add the react-native-test-app dependency to the windows test app package.json. Make sure it matches the version of the other test apps so that the node module can be hoisted. This also happened to alphabetize the package.json.
  • Remove everything under apps/windows/windows/ except for the .gitignore
  • Update app.json to have a appKey.
  • Run yarn install-windows-test-app to generate FluentTester.sln

Now, yarn windows should work as expected, meaning our CI should also work as expected.

This should close #447

Verification

Built the app on my windows PC.

Screen Shot 2020-11-02 at 2 32 20 PM

Pull request checklist

This PR has considered (when applicable):

  • Automated Tests
  • Documentation and examples
  • Keyboard Accessibility
  • Voiceover
  • Internationalization and Right-to-left Layouts

@Saadnajmi Saadnajmi marked this pull request as draft November 2, 2020 23:18
@Saadnajmi
Copy link
Collaborator Author

@tido64 Our CI to build the windows test app (fails with this change in a similar way that I see locally.
Specifically, running yarn windows --logging --release --arch x64 fails with an error that looks like this:

 Building Solution
- Build failed with message D:\a\1\s\apps\windows\windows\FluentTester.sln.metaproj : error MSB3202: The project file "D:\a\1\s\apps\windows\windows\..\node_modules\.generated\windows\ReactTestApp\ReactTestApp.vcxproj" was not found. [D:\a\1\s\apps\windows\windows\FluentTester.sln]. Check your build configuration.
✖ Build failed with message D:\a\1\s\apps\windows\windows\FluentTester.sln.metaproj : error MSB3202: The project file "D:\a\1\s\apps\windows\windows\..\node_modules\.generated\windows\ReactTestApp\ReactTestApp.vcxproj" was not found. [D:\a\1\s\apps\windows\windows\FluentTester.sln]. Check your build configuration.

Looks like either an incorrect node_modules path (probably bc monorepo?) or things are not getting generated into node_modules/.generated?

@tido64
Copy link
Member

tido64 commented Nov 3, 2020

Looks like either an incorrect node_modules path (probably bc monorepo?) or things are not getting generated into node_modules/.generated?

Did you add yarn install-windows-test-app to the CI build definition?

@Saadnajmi
Copy link
Collaborator Author

@

Looks like either an incorrect node_modules path (probably bc monorepo?) or things are not getting generated into node_modules/.generated?

Did you add yarn install-windows-test-app to the CI build definition?

Do I need to do that? I ran yarn install-windows-test-app once locally, and committed the generated .sln file. I thought all CI needs to do is run react-native run-windows and it should see no difference?

@tido64
Copy link
Member

tido64 commented Nov 3, 2020

Do I need to do that? I ran yarn install-windows-test-app once locally, and committed the generated .sln file. I thought all CI needs to do is run react-native run-windows and it should see no difference?

yarn install-windows-test-app generates the actual test app project under node_modules. The .sln file just references the project, similar to .xcworkspace referencing .xcproj.

@Saadnajmi
Copy link
Collaborator Author

I see, so this change now adds an extra step to run the windows test app kinda like how iOS/macOS need a pod install. Thanks, I'll update this PR and CI


```
cd apps/windows
yarn install-windows-test-app
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the yarn windows command also run install-windows-test-app?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could... I could change the following in our package.json
"windows": "react-native run-windows" => "windows" : "install windows-test-app && react-native run-windows"

Just like how I could have done this for the iOS app
"ios": "react-native run-ios ..." => "ios": "pod install && react-native run-ios"

Buuuut something felt wrong about running two commands there to me. Not sure if that's mostly unfounded

Regardless, I could see that as a simplifying follow up change where I actually use that fluentui-scripts package we have to define tasks and run those.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tido64 any idea why the CI over here is failing? I tried doing both scripts in yarn windows but that failed too

Copy link
Member

@tido64 tido64 Nov 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing with RNTA, one difference I'm seeing is that we are specifying --sln to help the CLI find the solution. But here, the app builds so I don't think that's it. The other thing we can try is to not specify --release. I couldn't make that work locally due to some other issue:

$ react-native run-windows --sln windows/Example.sln --release
 √ Auto-linking...
Success: No auto-linking changes necessary. (1404ms)
 √ Found MSBuild v16.0 at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin (16.7.30523.141)
 √ Restoring NuGet packages
 √ Found Solution: D:\Source\react-native-test-app\example\windows\Example.sln
 i Build configuration: Release
 i Build platform: x86
 × Building Solution: D:\Source\react-native-test-app\example\node_modules\react-native-windows\PropertySheets\Bu...
 × Build failed with message      9>Failed to construct transformer : error : EBUSY: resource busy or locked, open 'D:\Source\react-native-test-app\example\msbuild.ProjectImports.zip' [D:\Source\react-native-test-app\example\node_modules\.generated\windows\ReactTestApp\ReactTestApp.vcxproj]. Check your build configuration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I found a workaround for the EBUSY error (in microsoft/react-native-windows-samples#174) and finally reproed the issue. We are outputting a .msix file but @react-native-windows/cli expects .appx (submitted a fix here microsoft/react-native-windows#6421). This happens if WindowsTargetPlatformMinVersion is high enough. Patching it locally, I can get passed the error but I'm hitting some issues with app signing. I can look into it when I have some time later...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will also need this patch: microsoft/react-native-test-app#241. You'll need both this and the @react-native-windows/cli patch. I don't know if you can bump @react-native-windows/cli alone. If not, you'll have to look into patching it somehow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can probably wait till both react-native-test-app and react-native-windows bump, and update the dependencies and rerun the CI. In the meantime, I'll try to apply changes locally and see if I can find more issues

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, both PRs are merged. For the fixes in react-native-test-app, you should use 0.2.16. The fix in @react-native-windows/cli is not yet released. It will likely hit 0.64 if I understand the release process correctly.

@Saadnajmi
Copy link
Collaborator Author

Just as an update, I'll return to this PR after ##566 is merged, where I also update to use the latest version of RNTA. (man that's a mouthful to type). I'm not sure if this is blocked on react-native-windows 0.64 getting released, but I'll investigate that when I return to this PR.

@Saadnajmi
Copy link
Collaborator Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Saadnajmi Saadnajmi mentioned this pull request Feb 3, 2021
10 tasks
@Saadnajmi
Copy link
Collaborator Author

Ok.. so the process name is "ReactTestApp" on the CI machine, but "FluentTester" on my local machine. Interesting.

Get-Process
displayName: 'Get List of processes'

# Kill ReactTestApp, leave server up and running. This was the only way I could get the server continuously running
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In PowerShell, wouldn't one use something like Start-Process to fork a new process? Starting up the test app seems like a really expensive workaround…

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't write this, but I think the interntion was to test that the test app does run, and then do other stuff after

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app gets started, then is immediately killed afterwards. There is no time to test anything. The comment also says "This was the only way I could get the server continuously running".

Pinging @samuelfreiberg, since he wrote it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for such a delayed response, not sure it matters anymore, but I couldn't get the server to run when simply starting it like normal. When using "yarn start" or whatever the command was, it wasn't starting the server. The only way I could get it to run at the time was like this. Running the test app also started the server, but then I had to kill the test app or the E2E tests wouldn't run properly. It was a 'hack' and maybe it's changed now, but it was very strange at the time.

@tido64
Copy link
Member

tido64 commented Apr 1, 2021

FYI, I'm adding more capabilities to React Native Test App:

@Saadnajmi
Copy link
Collaborator Author

FYI, I'm adding more capabilities to React Native Test App:

I saw, thank you for that! Sorry I have not had the bandwidth to see this PR more as I don't have much bandwidth to fix windows CI errors.It also.... somehow didn't block our update to RN 0.63 which I thought we would need it to update our template app 🤷🏾

@samuelfreiberg
Copy link
Contributor

I'm not too familiar with Metro and some of the other changes in this PR, I'll defer to someone else who might be able to validate these changes better. But most of it looks goof

@Saadnajmi
Copy link
Collaborator Author

Closing because #755 exists and is replacing this PR.

@Saadnajmi Saadnajmi closed this Jul 14, 2021
@Saadnajmi Saadnajmi deleted the windows-test-app branch August 26, 2021 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hook up react-native-test-app for Windows
3 participants