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

feat: Add port number feature to build command #1346

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

plato79
Copy link

@plato79 plato79 commented Apr 14, 2024

Status

READY

Description

Added the port number to the build option for #1327

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@plato79 plato79 requested a review from a team as a code owner April 14, 2024 22:50
@tomarra tomarra changed the title Added port number feature to build command feat: Add port number feature to build command Apr 15, 2024
@tomarra
Copy link
Contributor

tomarra commented Apr 15, 2024

Hi @plato79 👋thanks for taking on the issue and opening a PR! It looks like there are some failures in CI so please take a look at the output and get everything to green before we start the review process. Thanks!

vars was initialized with "var" though it should have been "final".
@plato79
Copy link
Author

plato79 commented Apr 15, 2024

The only "problem" was the initialization of "vars" variable which I didn't change. I fixed it as final. It should now pass ci analyze step. Though some of the tests fails and I don't think it's because of my additions.

@plato79
Copy link
Author

plato79 commented Apr 16, 2024

Now, it's past anlalyze.. Though there is an error in prod_server_builder test. This one is a bit complex though, while the fix is very easy.

The code below is the reason for the error.

prod_server_builder.dart:

    final vars = <String, dynamic>{
      'dartVersion': dartVersion,
      'port': port,
    };

    logger.detail('[codegen] running pre-gen...');
    await prodServerBundleGenerator.hooks.preGen(
      vars: vars,
      workingDirectory: workingDirectory.path,
      onVarsChanged: (v) => vars..addAll(v ?? {}),
    );

There is a vars variable which has default dartVersion which is "stable" and default port which is "8080". There is possibility additional variables are provided through mason. We add those to the current variables defined in vars we have here. It modifies the value if the same key is used so everything is alright.

...until no variables are sent to here. Which makes v null (it says it shouldn't happen but it happens). Why vhas null value I am not sure. I thought that code would execute only when there is a value in v but this is not the situation.

Now the fix is easy as you can see. Just adding a null check fixes. But this time flutter says I shouldn't add a null check to a variable which shouldn't be null at all. While the code above fixes the problem and causes no problem, it probably will pop up in the ci analyze section as error just like the previous `"vars" should be defined as final" warning appears as error in analyze.

Do you have any suggestion about this?

@plato79
Copy link
Author

plato79 commented Apr 16, 2024

Now, it's past anlalyze.. Though there is an error in prod_server_builder test. This one is a bit complex though, while the fix is very easy.

The code below is the reason for the error.

prod_server_builder.dart:

    final vars = <String, dynamic>{
      'dartVersion': dartVersion,
      'port': port,
    };

    logger.detail('[codegen] running pre-gen...');
    await prodServerBundleGenerator.hooks.preGen(
      vars: vars,
      workingDirectory: workingDirectory.path,
      onVarsChanged: (v) => vars..addAll(v ?? {}),
    );

There is a vars variable which has default dartVersion which is "stable" and default port which is "8080". There is possibility additional variables are provided through mason. We add those to the current variables defined in vars we have here. It modifies the value if the same key is used so everything is alright.

...until no variables are sent to here. Which makes v null (it says it shouldn't happen but it happens). Why vhas null value I am not sure. I thought that code would execute only when there is a value in v but this is not the situation.

Now the fix is easy as you can see. Just adding a null check fixes. But this time flutter says I shouldn't add a null check to a variable which shouldn't be null at all. While the code above fixes the problem and causes no problem, it probably will pop up in the ci analyze section as error just like the previous `"vars" should be defined as final" warning appears as error in analyze.

Do you have any suggestion about this?

Ok, that was not the cause. Still checking to see what the real problem here is.

…"vars"

When there are no "port" number defined in this test, it causes error. This fixes it.
@plato79
Copy link
Author

plato79 commented Apr 16, 2024

This last commit should fix the error in the test.

@plato79
Copy link
Author

plato79 commented Apr 17, 2024

The failing tests are actually runs successfully if you execute the commands outside of the test. For example build_test fails, but if you run dart run build/bin/server.dart in the temporary directory it created and call http://localhost:8080 it works. But the test itself cannot get a response from that page.

@tomarra Are you sure that these tests worked without problem before I made the change?

plato79 and others added 4 commits April 20, 2024 10:19
@plato79
Copy link
Author

plato79 commented Apr 25, 2024

I think this is ready for merge. What do you think?

@alestiago
Copy link
Contributor

alestiago commented May 16, 2024

Hi @plato79! I've added this to the review column for the next iteration (May 18 to May 31). Hopefully we get to review it by then 🙌

@alestiago alestiago removed their assignment May 24, 2024
@tomarra
Copy link
Contributor

tomarra commented May 24, 2024

Hi @plato79 👋

I got this PR updated with main and we are still seeing failures in the CI pipeline. In looking more closely at the output it actually looks like there are changes that are needed on the Docker side of things. While the Dart code looks like it solves the need the Dockerfile needs to be updated to reflect the port change. Pretty sure this is why the tests are failing to establish a connection with the container to run the tests.

@alestiago alestiago added the waiting for response Waiting for follow up label Jun 18, 2024
@alestiago alestiago requested a review from wolfenrain August 13, 2024 12:41
@@ -14,7 +14,7 @@ final dartFrogProdServerBundle = MasonBundle.fromJson(<String, dynamic>{
{
"path": "build/bin/server.dart",
"data":
"Ly8gR0VORVJBVEVEIENPREUgLSBETyBOT1QgTU9ESUZZIEJZIEhBTkQKLy8gaWdub3JlX2Zvcl9maWxlOiB0eXBlPWxpbnQsIGltcGxpY2l0X2R5bmFtaWNfbGlzdF9saXRlcmFsCgppbXBvcnQgJ2RhcnQ6aW8nOwoKaW1wb3J0ICdwYWNrYWdlOmRhcnRfZnJvZy9kYXJ0X2Zyb2cuZGFydCc7Cgp7eyNpbnZva2VDdXN0b21FbnRyeXBvaW50fX1pbXBvcnQgJy4uL21haW4uZGFydCcgYXMgZW50cnlwb2ludDt7ey9pbnZva2VDdXN0b21FbnRyeXBvaW50fX0Ke3sjcm91dGVzfX1pbXBvcnQgJ3t7e3BhdGh9fX0nIGFzIHt7I3NuYWtlQ2FzZX19e3t7bmFtZX19fXt7L3NuYWtlQ2FzZX19Owp7ey9yb3V0ZXN9fQp7eyNtaWRkbGV3YXJlfX1pbXBvcnQgJ3t7e3BhdGh9fX0nIGFzIHt7I3NuYWtlQ2FzZX19e3t7bmFtZX19fXt7L3NuYWtlQ2FzZX19Owp7ey9taWRkbGV3YXJlfX0Kdm9pZCBtYWluKCkgYXN5bmMgewogIGZpbmFsIGFkZHJlc3MgPSBJbnRlcm5ldEFkZHJlc3MuYW55SVB2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kbGV3YXJlKXt7L21pZGRsZXdhcmV9fXt7L21pZGRsZXdhcmUuMH19OwogIGZpbmFsIHJvdXRlciA9IFJvdXRlcigpCiAgICB7eyNmaWxlc319e3sjd2lsZGNhcmR9fS4ubW91bnQoJ3t7e3JvdXRlfX19JywgKGNvbnRleHQpID0+IHt7I3NuYWtlQ2FzZX19e3t7bmFtZX19fXt7L3NuYWtlQ2FzZX19Lm9uUmVxdWVzdChjb250ZXh0LGNvbnRleHQucmVxdWVzdC51cmwucGF0aCkpe3svd2lsZGNhcmR9fXt7XndpbGRjYXJkfX0uLmFsbCgne3t7cm91dGV9fX0nLCAoY29udGV4dHt7I2ZpbGVfcGFyYW1zLjB9fSx7eyNmaWxlX3BhcmFtc319e3sufX0se3svZmlsZV9wYXJhbXN9fXt7L2ZpbGVfcGFyYW1zLjB9fSkgPT4ge3sjc25ha2VDYXNlfX17e3tuYW1lfX19e3svc25ha2VDYXNlfX0ub25SZXF1ZXN0KGNvbnRleHQse3sjZGlyZWN0b3J5X3BhcmFtc319e3sufX0se3svZGlyZWN0b3J5X3BhcmFtc319e3sjZmlsZV9wYXJhbXN9fXt7Ln19LHt7L2ZpbGVfcGFyYW1zfX0pKXt7L3dpbGRjYXJkfX17ey9maWxlc319OwogIHJldHVybiBwaXBlbGluZS5hZGRIYW5kbGVyKHJvdXRlcik7Cn0Ke3svZGlyZWN0b3JpZXN9fQo=",
Copy link
Contributor

Choose a reason for hiding this comment

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

We do not manually update the bundles, can you revert this change? The bot will take care of updating the bundle after the PR is merged.

@alestiago
Copy link
Contributor

Hi @plato79 this seems silent for a while, are you still able to complete the effort?

@plato79
Copy link
Author

plato79 commented Aug 23, 2024

Sorry, because of my "paying" work, I couldn't concentrate on this for a while. I'll try to fix it tomorrow.

@tomarra tomarra added the p2 Important issues not at the top of the work list label Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2 Important issues not at the top of the work list waiting for response Waiting for follow up
Projects
Status: Community
Development

Successfully merging this pull request may close these issues.

4 participants