Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 4, 2025

  • Understand the codebase structure and test infrastructure
  • Create new file: pkg/workflow/js/sanitize_workflow_name.cjs with the function
  • Update pkg/workflow/js/parse_firewall_logs.cjs to import from new helper
  • Remove function definition from parse_firewall_logs.cjs
  • Create tests for the new helper file
  • Run tests to verify functionality is preserved (655 tests passing)
  • Run linting and formatting (TypeScript typecheck + prettier)
  • Merge main branch and recompile workflows
  • Update compiler to embed new cjs file and bundle properly
  • Merge latest main branch changes
Original prompt

This section details on the original issue you should resolve

<issue_title>[task] Extract sanitizeWorkflowName to dedicated helper file</issue_title>
<issue_description>## Objective
Extract the sanitizeWorkflowName function from pkg/workflow/js/parse_firewall_logs.cjs to its own dedicated helper file.

Context

The sanitizeWorkflowName function in parse_firewall_logs.cjs is a utility that could be reused. Following the pattern of "1 javascript helper per file so that they can be imported one by one", this should be extracted to its own module. Part of issue #3119.

Approach

  1. Create new file: pkg/workflow/js/sanitize_workflow_name.cjs
  2. Move the sanitizeWorkflowName function to the new file
  3. Export the function as a CommonJS module: module.exports = { sanitizeWorkflowName };
  4. Update pkg/workflow/js/parse_firewall_logs.cjs to import: const { sanitizeWorkflowName } = require('./sanitize_workflow_name.cjs');
  5. Remove the function definition from parse_firewall_logs.cjs

Files to Modify

  • Create: pkg/workflow/js/sanitize_workflow_name.cjs (new helper file)
  • Update: pkg/workflow/js/parse_firewall_logs.cjs (import and remove definition)

Acceptance Criteria

AI generated by Plan Command for #3119</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Created pkg/workflow/js/sanitize_workflow_name.cjs with the function
- Updated parse_firewall_logs.cjs to import from new helper
- Removed function definition from parse_firewall_logs.cjs
- Updated parse_firewall_logs.test.cjs to remove sanitizeWorkflowName test
- Created sanitize_workflow_name.test.cjs with comprehensive tests
- All tests passing (655 tests, 34 test files)
- TypeScript typecheck passing
- Code formatted with prettier

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Extract sanitizeWorkflowName to dedicated helper file Extract sanitizeWorkflowName to dedicated helper module Nov 4, 2025
Copilot AI requested a review from pelikhan November 4, 2025 15:20
@pelikhan pelikhan marked this pull request as ready for review November 4, 2025 15:26
Copilot AI review requested due to automatic review settings November 4, 2025 15:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR extracts the sanitizeWorkflowName function from parse_firewall_logs.cjs into its own dedicated module with comprehensive test coverage. This refactoring improves code organization and reusability.

  • Moved sanitizeWorkflowName function to a new standalone module sanitize_workflow_name.cjs
  • Created comprehensive test suite for the extracted function
  • Updated parse_firewall_logs.cjs to import the function instead of defining it locally

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
pkg/workflow/js/sanitize_workflow_name.cjs New module containing the extracted sanitizeWorkflowName function
pkg/workflow/js/sanitize_workflow_name.test.cjs New comprehensive test suite for sanitizeWorkflowName
pkg/workflow/js/parse_firewall_logs.cjs Removed sanitizeWorkflowName function and its export, added import from new module
pkg/workflow/js/parse_firewall_logs.test.cjs Removed test for sanitizeWorkflowName and cleanup of test setup code

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@pelikhan
Copy link
Contributor

pelikhan commented Nov 4, 2025

@copilot merge main and recompile

Copilot AI and others added 2 commits November 4, 2025 15:40
- Merged latest changes from main branch
- Recompiled all workflow lock files
- All unit tests passing (Go + JavaScript)
- Lock files updated to reflect latest changes

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 4, 2025

@copilot merge main and recompile

Merged main and recompiled all workflows in commit 651480d. All tests passing.

Copilot AI requested a review from pelikhan November 4, 2025 15:44
@pelikhan
Copy link
Contributor

pelikhan commented Nov 4, 2025

@copilot the require is not properly inlined by the bundled. Update compiler to embed new cjs file and bundle properly

- Added embed directive for sanitize_workflow_name.cjs
- Registered sanitize_workflow_name.cjs in GetJavaScriptSources()
- Converted parse_firewall_logs.cjs to use bundling pattern
- Added getParseFirewallLogsScript() with lazy bundling
- Updated GetLogParserScript() to use bundled version
- Verified bundler properly inlines sanitize_workflow_name function
- All tests passing (Go + JavaScript)
- Recompiled all workflow lock files

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 4, 2025

@copilot the require is not properly inlined by the bundled. Update compiler to embed new cjs file and bundle properly

Updated compiler to properly bundle sanitize_workflow_name.cjs in commit e4ff745. The bundler now:

  • Embeds sanitize_workflow_name.cjs via go:embed directive
  • Registers it in GetJavaScriptSources() for bundling
  • Converts parse_firewall_logs.cjs to use lazy bundling pattern
  • Inlines the require() call and removes module.exports

Verified bundler correctly inlines the function and removes exports.

@pelikhan
Copy link
Contributor

pelikhan commented Nov 4, 2025

@copilot merge main

…ize-workflow-name

# Conflicts:
#	.github/workflows/smoke-copilot.firewall.lock.yml
Copy link
Contributor Author

Copilot AI commented Nov 4, 2025

@copilot merge main

Merged main in commit 398e11b. Resolved conflict with smoke-copilot.firewall.lock.yml (accepted deletion). All tests passing.

@pelikhan pelikhan merged commit 7009272 into main Nov 4, 2025
3 checks passed
@pelikhan pelikhan deleted the copilot/extract-sanitize-workflow-name branch November 4, 2025 16:05
Copilot AI requested a review from pelikhan November 4, 2025 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[task] Extract sanitizeWorkflowName to dedicated helper file

2 participants