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

fix(core): Use owners file to export wf owners #6547

Merged

Conversation

flipswitchingmonkey
Copy link
Contributor

No description provided.

@github-actions
Copy link
Contributor

Great PR! Please pay attention to the following items before merging:

Files matching packages/**:

  • If fixing bug, added test to cover scenario.
  • If addressing forum or Github issue, added link to description.

Files matching packages/**/*.ts:

  • Added unit tests to cover new or updated functionality.

Make sure to check off this list before asking for review.

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Jun 27, 2023
@codecov
Copy link

codecov bot commented Jun 27, 2023

Codecov Report

Patch coverage: 0.88% and project coverage change: +0.04 🎉

Comparison is base (b66d151) 28.72% compared to head (80026aa) 28.76%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6547      +/-   ##
==========================================
+ Coverage   28.72%   28.76%   +0.04%     
==========================================
  Files        3000     3032      +32     
  Lines      186293   187053     +760     
  Branches    20606    20705      +99     
==========================================
+ Hits        53509    53810     +301     
- Misses     131973   132407     +434     
- Partials      811      836      +25     
Impacted Files Coverage Δ
...ronments/sourceControl/sourceControl.service.ee.ts 8.33% <0.00%> (-0.85%) ⬇️
...ts/sourceControl/sourceControlExport.service.ee.ts 11.42% <0.00%> (-0.52%) ⬇️
...ts/sourceControl/sourceControlImport.service.ee.ts 11.62% <0.00%> (-4.20%) ⬇️
...es/cli/src/environments/sourceControl/constants.ts 100.00% <100.00%> (ø)

... and 49 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@flipswitchingmonkey flipswitchingmonkey marked this pull request as ready for review June 27, 2023 10:35
@flipswitchingmonkey flipswitchingmonkey marked this pull request as draft June 27, 2023 10:36
@flipswitchingmonkey flipswitchingmonkey marked this pull request as ready for review June 27, 2023 12:37
@@ -326,6 +330,13 @@ export class SourceControlService {
id = workflow.id;
name = workflow.name;
}
const existingWorkflow = await Db.collections.Workflow.find({
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe premature optimisation, but pre-fetch all existing workflows and create a hashmap so we can have faster access. Not needed tho.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point

}
}

console.log(ownerRecords);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
console.log(ownerRecords);


console.log(ownerRecords);

let importWorkflowsResult = new Array<{ id: string; name: string } | undefined>();
await Db.transaction(async (transactionManager) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I usually have a very bad experience with transactionManager as it tends to create database locks that cause running executions to fail.

Worth testing with own mode and see if this is the case (create a few workflows that run every second and attempt this process). If we get errors saying that cannot read or write due to locked database it might make sense to remove the migration, as bad as it may sound, I know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed transactions

// write list of owners to file
const ownersFileName = this.getOwnersPath();
const owners: Record<string, string> = {};
sharedWorkflows.forEach((e) => (owners[e.workflowId] = e.user.email));
Copy link
Contributor

Choose a reason for hiding this comment

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

One problem I see here is that we're always sending the full file, regardless of the workflows actually exported.

One problem I had is that I have over 100 workflows, but I exported a single one. My owners file contains all the 100 workflow owner names, even though my repo only contains a single workflow file.

I'm thinking that maybe we should read the file contents and append the rows that were added WDYT?

Copy link
Contributor

@krynble krynble left a comment

Choose a reason for hiding this comment

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

Other than the comment I left, it all looks fine.

@cypress
Copy link

cypress bot commented Jun 28, 2023

1 flaky tests on run #1344 ↗︎

0 227 0 0 Flakiness 1

Details:

🌳 pay-571-use-owners-file-to-export-wf-owners 🖥️ browsers:node18.12.0-chrome10...
Project: n8n Commit: 80026aaf3a
Status: Passed Duration: 07:19 💡
Started: Jun 28, 2023 8:44 AM Ended: Jun 28, 2023 8:52 AM
Flakiness  cypress/e2e/18-user-management.cy.ts • 1 flaky test

View Output Video

Test Artifacts
User Management > should change current user password Output Screenshots Video

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@github-actions
Copy link
Contributor

✅ All Cypress E2E specs passed

@flipswitchingmonkey flipswitchingmonkey merged commit 4b755fb into master Jun 28, 2023
@flipswitchingmonkey flipswitchingmonkey deleted the pay-571-use-owners-file-to-export-wf-owners branch June 28, 2023 09:06
MiloradFilipovic added a commit that referenced this pull request Jun 28, 2023
* master:
  fix(core): Use owners file to export wf owners (#6547)
  feat(Microsoft To Do Node): Add an option to set a reminder when creating a task (#5757)
  fix(Sendy Node): Fix issue with brand id not being sent (#6530)
  ci: Update release process to support `major` releases (no-changelog) (#6552)
This was referenced Jul 5, 2023
@janober
Copy link
Member

janober commented Jul 5, 2023

Got released with [email protected]

@github-actions github-actions bot mentioned this pull request Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants