Skip to content

Conversation

sebastianmalysa-wf
Copy link
Contributor

@sebastianmalysa-wf sebastianmalysa-wf commented Aug 23, 2018

DO NOT MERGE UNTIL #2 IS MERGED

Add more test to cover additions made in AF-1928.

@corwinsheahan-wf @evanweible-wf @maxwellpeterson-wf

@rmconsole-wf
Copy link

rmconsole-wf commented Aug 23, 2018

Merge Requirements Met ✅

Request Rosie to automerge this pull request by including @Workiva/release-management-p in a comment.

  • Required artifacts are reported in build. See documentation for more details on build artifact requirements.
    • python requires one of: pip.lock, python3_pip_deps.txt, python2_pip_deps.txt

General Information

Ticket(s):

Code Review(s): #4

Reviewers: evanweible-wf

Additional Information

Watchlist Notifications: None

	When this pull is merged I will add it to the following release:
	Version: over_react_codemod 0.1.0
	Release Ticket(s): None


Note: This is a shortened report. Click here to view Rosie's full evaluation.
Last updated on Friday, September 21 12:39 AM CST

@aviary-wf
Copy link

aviary-wf commented Aug 23, 2018

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on HipChat: InfoSec Forum.

pubspec.yaml Outdated
@@ -0,0 +1,16 @@
name: over_react_codemode
Copy link
Contributor

Choose a reason for hiding this comment

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

extra e at the end

WORKDIR /build/
ADD . /build/
ENV TERM=linux
ENV TERMINFO=/etc/terminfo
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember you explaining this to me before, but could you remind me why this is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are need to run 'migrater.py' within CI so the tests run properly.

ENV TERM=linux
ENV TERMINFO=/etc/terminfo
RUN echo "Install codemod" && \
pip install git+https://github.com/georgelesica-wf/codemod@dart-convert && \
Copy link
Contributor

Choose a reason for hiding this comment

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

George's PR to codemod was accepted, so I believe we can install the official facebook version of codemod now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We still need George's branch because they haven't released the changes he made.


// ignore: deprecated_member_use
@Required(message: 'This Prop is Required for testing purposes.')
var required;
Copy link
Contributor

Choose a reason for hiding this comment

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

The alternative for the deprecated @Required is @requiredProp – let's use that and then we won't also need to ignore the deprecated member use.


// ignore: deprecated_member_use
@Required(isNullable: true, message: 'This prop can be set to null!')
var nullable;
Copy link
Contributor

Choose a reason for hiding this comment

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

@nullableRequiredProp

/// Creates a temp directory and copies the un-modified test fixtures to it. Then
/// migrater.py is run on these test fixtures to make the codemod changes.
Future<Null> setupAndCodemod(String pathToTestFixtureDirectory) async {
final pathToMigrater = p.absolute('migrater.py');
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this doesn't change, you could define it as a final var at the top of the file.

test('correctly converts components with part directive', () async {
final pathToTestFixtureDirectory = p.absolute('test/test_fixtures/before_codemod/component_in_parts');
final pathToExpectedResults = p.absolute('test/test_fixtures/after_codemod/component_in_parts/component_in_part.dart');
final pathToTestFile = p.absolute('test/test_fixtures/before_codemod/component_in_parts/temp/component_in_part.dart');
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the makeComparison method is creating the temp directory and running codemod on it, it should be the one to handle finding the result of the codemod script. In other words, let's update makeComparison to figure this path out on its own instead of needing to define it for each test and pass it in.

await Process.run('/bin/bash',
['-c', 'mkdir -p temp && cp -r *.dart /$pathToTempDirectory'], workingDirectory: pathToTestFixtureDirectory);

await Process.start('/bin/bash', ['-c', 'python $pathToMigrater'], workingDirectory: pathToTempDirectory).then((Process process) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to explicitly run the script via /bin/bash like this? Or would this work:

Process.start('python', [pathToMigrater], workingDirectory: pathToTempDirectory)...

['-c', 'mkdir -p temp && cp -r *.dart /$pathToTempDirectory'], workingDirectory: pathToTestFixtureDirectory);

await Process.start('/bin/bash', ['-c', 'python $pathToMigrater'], workingDirectory: pathToTempDirectory).then((Process process) async {
await process.stdin.write('A\nA\n');
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably add a flag to the migrater.py script that allows us to automatically apply all changes without requiring input from stdin, that way we can just include that flag in our command above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no way for codemod to run in a way that will accept all changes, at least not in the current release. A PR (facebookarchive/codemod#48) was made that adds the flag we want, but it hasn't been released :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That should be in George's branch though, so I think I can get this to work.


/// Makes the comparison between the expected result (migrated file) and the test file
/// (the file that is migrated during the test run in a temp directory).
Future<Null> makeComparison(String pathToTestFixtureDirectory, String pathToExpectedResults, String pathToTestFile) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a slightly simpler/cleaner approach would be for this function to accept:

  1. The before File, which it will copy to a temp directory and run the codemod script on
  2. The after File, which it will compare against the result of the codemod script

Copy link
Contributor

@evanweible-wf evanweible-wf left a comment

Choose a reason for hiding this comment

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

Looks great!!

@evanweible-wf
Copy link
Contributor

QA +1

  • Tests pass!

@Workiva/release-management-p

@rmconsole-wf
Copy link

@evanweible-wf I will not merge this because:

  • This PR will not Auto-Merge because a project is excluded from the
    Automerge Projects on this repo.
    Project: AF
    If you are the maintainer of this repo and would like to allow this project to automerge,
    please update the automerge projects list on the Rosie Control panel.
  • 'Hold Auto-Merge' label is applied

@rmconsole-wf
Copy link

+1 from RM

@rmconsole5-wk rmconsole5-wk merged commit 6ea4e10 into master Sep 21, 2018
@rmconsole5-wk rmconsole5-wk deleted the AF-2152 branch September 21, 2018 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants