Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

feat: default config #383

Merged
merged 10 commits into from
Jul 31, 2023
Merged

feat: default config #383

merged 10 commits into from
Jul 31, 2023

Conversation

Venoox
Copy link
Contributor

@Venoox Venoox commented Jun 8, 2023

Resolves #327

@rndquu I think even relative path is not gonna work because the @vercel/ncc bundler doesn't put it in the build process.

@Venoox Venoox requested a review from 0xcodercrane as a code owner June 8, 2023 17:44
@netlify
Copy link

netlify bot commented Jun 8, 2023

Deploy Preview for ubiquibot-staging ready!

Name Link
🔨 Latest commit cb5c231
🔍 Latest deploy log https://app.netlify.com/sites/ubiquibot-staging/deploys/64c762e83b03290008c821aa
😎 Deploy Preview https://deploy-preview-383--ubiquibot-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@rndquu
Copy link
Member

rndquu commented Jun 8, 2023

@rndquu I think even relative path is not gonna work because the @vercel/ncc bundler doesn't put it in the build process.

Then we should try using __dirname or smth else according to the docs

@Venoox
Copy link
Contributor Author

Venoox commented Jun 9, 2023

@rndquu I think even relative path is not gonna work because the @vercel/ncc bundler doesn't put it in the build process.

This we should try using __dirname or smth else according to the docs

I tried locally with __dirname and when I run yarn build:serverless, the file is not copied over to the dist folder

@rndquu
Copy link
Member

rndquu commented Jun 9, 2023

@rndquu I think even relative path is not gonna work because the @vercel/ncc bundler doesn't put it in the build process.

This we should try using __dirname or smth else according to the docs

I tried locally with __dirname and when I run yarn build:serverless, the file is not copied over to the dist folder

I've just tried with the following code and the config was copied to the dist folder:

const DEFAULT_CONFIG_FILE = `${__dirname}/../../ubiquibot-config-default.yml`;

Could you:

  1. refactor code using __dirname
  2. run yarn build:serverless
  3. run node dist/index.js (there should be no errors) + ubiquibot-config-default.yml should be copied to the dist folder
  4. if everything is fine then update the PR

@0xcodercrane
Copy link
Contributor

@Venoox please make the PR a draft if its not ready for a reivew

@Venoox Venoox marked this pull request as draft June 9, 2023 20:27
@Venoox
Copy link
Contributor Author

Venoox commented Jun 9, 2023

Now the file gets copied over but there is another issue:
I'm guessing it has something to do with the way ncc orders the code?

const parsedDefaultConfig = (0, private_1.parseYAML)(defaultConfig);
                                                    ^

TypeError: (0 , private_1.parseYAML) is not a function
    at 59612 (/Users/tomaz/ubiquibot/dist/index.js:149514:53)
    at __nccwpck_require__ (/Users/tomaz/ubiquibot/dist/index.js:208441:43)
    at 55447 (/Users/tomaz/ubiquibot/dist/index.js:149678:19)
    at __nccwpck_require__ (/Users/tomaz/ubiquibot/dist/index.js:208441:43)
    at 80417 (/Users/tomaz/ubiquibot/dist/index.js:147390:19)
    at __nccwpck_require__ (/Users/tomaz/ubiquibot/dist/index.js:208441:43)
    at 92040 (/Users/tomaz/ubiquibot/dist/index.js:147353:23)
    at __nccwpck_require__ (/Users/tomaz/ubiquibot/dist/index.js:208441:43)
    at 39321 (/Users/tomaz/ubiquibot/dist/index.js:147182:16)
    at __nccwpck_require__ (/Users/tomaz/ubiquibot/dist/index.js:208441:43)

Node.js v20.2.0

@0x4007
Copy link
Member

0x4007 commented Jun 10, 2023

const parsedDefaultConfig = (0, private_1.parseYAML)(defaultConfig);

Yeah that definitely doesn't look like a function! Perhaps they already have an open issue on this.

You might also be able to experiment with pulling out the function's contents and running them without calling the function. I'm not sure.

@rndquu
Copy link
Member

rndquu commented Jun 10, 2023

Now the file gets copied over but there is another issue: I'm guessing it has something to do with the way ncc orders the code?

const parsedDefaultConfig = (0, private_1.parseYAML)(defaultConfig);
                                                    ^

TypeError: (0 , private_1.parseYAML) is not a function
    at 59612 (/Users/tomaz/ubiquibot/dist/index.js:149514:53)
    at __nccwpck_require__ (/Users/tomaz/ubiquibot/dist/index.js:208441:43)
    at 55447 (/Users/tomaz/ubiquibot/dist/index.js:149678:19)
    at __nccwpck_require__ (/Users/tomaz/ubiquibot/dist/index.js:208441:43)
    at 80417 (/Users/tomaz/ubiquibot/dist/index.js:147390:19)
    at __nccwpck_require__ (/Users/tomaz/ubiquibot/dist/index.js:208441:43)
    at 92040 (/Users/tomaz/ubiquibot/dist/index.js:147353:23)
    at __nccwpck_require__ (/Users/tomaz/ubiquibot/dist/index.js:208441:43)
    at 39321 (/Users/tomaz/ubiquibot/dist/index.js:147182:16)
    at __nccwpck_require__ (/Users/tomaz/ubiquibot/dist/index.js:208441:43)

Node.js v20.2.0

Which command throws this error? This one node dist/index.js ?

@Venoox
Copy link
Contributor Author

Venoox commented Jun 13, 2023

Which command throws this error? This one node dist/index.js ?

Yes. It seems it's an issue with top level code. If I wrap the code in a function then the error is gone.

Now there are two solutions, either we read the default config in getWideConfig and pass defaults as the last parameter in the function like getChainId(parsedRepo, parsedOrg, default['chain-id']), or load the config in the functions themselves using a singleton variable to prevent loading multiple times

@rndquu
Copy link
Member

rndquu commented Jun 13, 2023

Which command throws this error? This one node dist/index.js ?

Yes. It seems it's an issue with top level code. If I wrap the code in a function then the error is gone.

Now there are two solutions, either we read the default config in getWideConfig and pass defaults as the last parameter in the function like getChainId(parsedRepo, parsedOrg, default['chain-id']), or load the config in the functions themselves using a singleton variable to prevent loading multiple times

I don't get any errors on node dist/index.js in this PR's branch though I use a slightly different node version v18.14.0

Perhaps you should leave this PR in its current state and open a QA issue so that we could see how it works in your repo?

@Venoox
Copy link
Contributor Author

Venoox commented Jun 14, 2023

https://github.com/Venoox/ubiquibot/actions/runs/5271555816/jobs/9532609741

As I understand this error: private.ts imports helpers.ts which executes parseYAML but parseYAML is defined later in private.ts, so it's basically a dependency cycle?

@rndquu
Copy link
Member

rndquu commented Jun 14, 2023

https://github.com/Venoox/ubiquibot/actions/runs/5271555816/jobs/9532609741

As I understand this error: private.ts imports helpers.ts which executes parseYAML but parseYAML is defined later in private.ts, so it's basically a dependency cycle?

yes, seems like that

perhaps here you could refactor to:

const parsedDefaultConfig: WideRepoConfig = YAML.parse(defaultConfig);

The YAML.parse() does not return a promise so it's ok to use it at the top of the file

@Venoox
Copy link
Contributor Author

Venoox commented Jun 15, 2023

Seems like the issue is solved but there is an unrelated error regarding telegram bot (https://github.com/Venoox/ubiquibot/actions/runs/5275990184/jobs/9542118341)

@rndquu
Copy link
Member

rndquu commented Jun 15, 2023

Seems like the issue is solved but there is an unrelated error regarding telegram bot (https://github.com/Venoox/ubiquibot/actions/runs/5275990184/jobs/9542118341)

It's missing here https://github.com/Venoox/ubiquibot/blob/default-config/.github/workflows/bot.yml but I think it's ok to pass it empty for QA workflow runs not related to Telegram issues

@rndquu rndquu marked this pull request as ready for review June 15, 2023 08:12
@rndquu
Copy link
Member

rndquu commented Jun 15, 2023

@0xcodercrane could you review this PR again?

@Venoox thank you for fixing errors

@0xcodercrane
Copy link
Contributor

@0xcodercrane could you review this PR again?

@Venoox thank you for fixing errors

Sure!

@0xcodercrane
Copy link
Contributor

0xcodercrane commented Jun 15, 2023

In terms of code review, I had a couple of changes for @Venoox but committed what I want to the Venoox:default-config to save hours. To be honest, I didn't get a chance to try to build so please take my changes into consideration as suggested changes and fix build issues if needed.
Once the build issue fixed, we can go to the QA step

@rndquu
Copy link
Member

rndquu commented Jun 15, 2023

@Venoox could you fix typescript errors? Notice there are some changes introduced by @0xcodercrane

@rndquu
Copy link
Member

rndquu commented Jun 16, 2023

@Venoox thank you

@0xcodercrane pls review again

0xcodercrane
0xcodercrane previously approved these changes Jun 17, 2023
@0x4007
Copy link
Member

0x4007 commented Jul 27, 2023

Hey @Venoox really sorry about the delay I decided to manually try and take this over but I'm having issues resolving those merge conflicts.

My progress is here:

@0xcodercrane
Copy link
Contributor

0xcodercrane commented Jul 31, 2023

To wrap up the issue asap.

  • We should resolve conflicts first.
  • Regenerate the QA because I am seeing more comments after the last QA and review. @Draeieg
  • Any configuration change PRs need to be created on staging/production @rndquu

If you @Venoox can resolve the conflicts, we will appreciate it a lot.

auto-merge was automatically disabled July 31, 2023 07:29

Head branch was pushed to by a user without write access

@Venoox
Copy link
Contributor Author

Venoox commented Jul 31, 2023

@0xcodercrane I resolved the conflicts

@0xcodercrane
Copy link
Contributor

@0xcodercrane I resolved the conflicts

Thank you. To merge the PR, I will wait for the rest 2 items. @Venoox would you re-post the QA link with the latest codebase?

@0x4007
Copy link
Member

0x4007 commented Jul 31, 2023

Lol @0xcodercrane I think it would have made more sense to ask @Venoox to resolve the merge conflicts as the last step.

Alternatively we can pause merging into development and rush merging this in so that they don't have to keep doing more unnecessary work. But due to all the merge delays lately I'm not a fan of intentionally adding to the delays.

@0x4007 0x4007 requested review from Draeieg and removed request for Draeieg July 31, 2023 08:39
@0xcodercrane
Copy link
Contributor

Lol @0xcodercrane I think it would have made more sense to ask @Venoox to resolve the merge conflicts as the last step.

Alternatively we can pause merging into development and rush merging this in so that they don't have to keep doing more unnecessary work. But due to all the merge delays lately I'm not a fan of intentionally adding to the delays.

Ok. we can skip the QA processing for now. but need to wait @rndquu 's input for configuration changes

@rndquu
Copy link
Member

rndquu commented Jul 31, 2023

Lol @0xcodercrane I think it would have made more sense to ask @Venoox to resolve the merge conflicts as the last step.
Alternatively we can pause merging into development and rush merging this in so that they don't have to keep doing more unnecessary work. But due to all the merge delays lately I'm not a fan of intentionally adding to the delays.

Ok. we can skip the QA processing for now. but need to wait @rndquu 's input for configuration changes

The PR looks good, no need for additional config update PRs

@0xcodercrane 0xcodercrane added this pull request to the merge queue Jul 31, 2023
Merged via the queue into ubiquity:development with commit d85196e Jul 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add default yml config
5 participants