Skip to content

Add a cleanup step for bootstrapper files to remove stale NUKE_ENTERPRISE_TOKEN handling#519

Open
ITaluone wants to merge 2 commits into
Fallout-build:mainfrom
ITaluone:feat/migration-cleanup-step
Open

Add a cleanup step for bootstrapper files to remove stale NUKE_ENTERPRISE_TOKEN handling#519
ITaluone wants to merge 2 commits into
Fallout-build:mainfrom
ITaluone:feat/migration-cleanup-step

Conversation

@ITaluone

@ITaluone ITaluone commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Closes: #518

Add a small cleanup step, which removes stale env var check for the NUKE_ENTERPRISE_TOKEN variable, which in return adds a special nuget source (which at best is stale and at worst non-existent).

  • Added direct cleanup tests
  • Additional MigrationsIntegrationTests

@IT-VBFK

IT-VBFK commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

@dennisdoomen Should this go into the already existing RewriteBootstrapScriptsStep.cs or like this as dedicated step?

@dennisdoomen

Copy link
Copy Markdown
Collaborator

Should this go into the already existing RewriteBootstrapScriptsStep.cs or like this as dedicated step?

I would definitely make that a dedicated step.

@IT-VBFK

IT-VBFK commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Cool :)

@ITaluone
ITaluone force-pushed the feat/migration-cleanup-step branch 2 times, most recently from b361254 to e2cbe24 Compare July 20, 2026 19:34
@ITaluone

Copy link
Copy Markdown
Collaborator Author

Should now fit definitely :)

@ITaluone ITaluone added enhancement New feature or request target/vCurrent Targets the current version labels Jul 21, 2026
@ITaluone
ITaluone force-pushed the feat/migration-cleanup-step branch from e2cbe24 to 7c062b2 Compare July 21, 2026 13:33
return Task.CompletedTask;
}

internal static RewriteResult Cleanup(string content)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔧 We don't want to test the implementation details of a step. Instead, we use the public API of this class.

🌱 (planting a seed) In principle testing the step directly is wrong as well. We should really be using the Migration class as the subject.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Do I got this correct, that the one integration test would suffice then?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I cannot see a way to not test the actual internals, without bloating this PR.

Should we for now proceed with this and refactor the tests later?

Comment thread src/Fallout.Migrate/Steps/CleanupBootstrapScriptsStep.cs
Comment thread src/Fallout.Migrate/Steps/CleanupBootstrapScriptsStep.cs
var endOfIfBlock = lines.FindIndex(indexOfEnterpriseEnvVarCheck,
line => line.Trim() == "}" || line.Trim() == "fi");

if (lines[endOfIfBlock + 1].Trim() == "")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔧🤖 endOfIfBlock (line 47) can come back -1 if the if/fi/} block is malformed, and lines[endOfIfBlock + 1] here throws IndexOutOfRangeException if the block is the last content in the file. This runs against arbitrary user-modified bootstrap scripts during migration, so a hand-edited or unusual file could crash the migration step instead of degrading gracefully (e.g. skip with a warning).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ahm.. what does this mean?

in principle: this for example is valid bash as well

 if [[ ! -z ${NUKE_ENTERPRISE_TOKEN+x} && "$NUKE_ENTERPRISE_TOKEN" != "" ]]; then
                                                             "$DOTNET_EXE" nuget remove source "nuke-enterprise" &>/dev/null || true
                                                             "$DOTNET_EXE" nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password "$NUKE_ENTERPRISE_TOKEN" --store-password-in-clear-text &>/dev/null || true; fi

but just grepping for "fi" is potentially more dangerous..

the +1 thing is fixed btw..

Comment thread src/Fallout.Migrate/Steps/CleanupBootstrapScriptsStep.cs Outdated
@ITaluone
ITaluone force-pushed the feat/migration-cleanup-step branch from 7c062b2 to 5c1845b Compare July 25, 2026 12:03
@ITaluone
ITaluone force-pushed the feat/migration-cleanup-step branch from 5c1845b to c1fa6e4 Compare July 25, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request target/vCurrent Targets the current version

Projects

None yet

3 participants