Add test coverage for scripts.go and compile_command.go#3776
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive test coverage for two critical files that previously lacked tests: pkg/workflow/scripts.go and pkg/cli/compile_command.go. The tests follow existing project patterns with table-driven approaches and thorough edge case coverage.
Key Additions
- scripts_test.go (325 lines): Tests all 18 JavaScript script getter functions, validating script loading, bundling idempotency, caching behavior, and fallback mechanisms
- compile_command_test.go (476 lines): Tests compilation configuration, flag validation (dependabot, purge, strict, trial mode), error handling, and YAML validation
- super-linter.lock.yml: Updates action versions to align with project standards
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/workflow/scripts_test.go | Comprehensive tests for JavaScript script getter functions, bundling, and caching - validates all embedded scripts load correctly |
| pkg/cli/compile_command_test.go | Tests for compilation configuration, flag validation, error handling, and YAML processing - covers edge cases and default values |
| .github/workflows/super-linter.lock.yml | Updates action versions (fixes download-artifact SHA inconsistency, but introduces a security issue with super-linter tag usage) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - name: Super-linter | ||
| id: super-linter | ||
| uses: super-linter/super-linter@2bdd90ed3262e023ac84bf8fe35dc480721fc1f2 | ||
| uses: super-linter/super-linter@v8.2.1 |
There was a problem hiding this comment.
The super-linter action reference has been changed from a SHA-pinned version to a tag version (v8.2.1). According to the Security Best Practices guidelines in this project, all actions should be pinned to SHAs (not tags) to prevent supply chain attacks, as tags can be deleted and recreated.
Recommended fix:
uses: super-linter/super-linter@<SHA-for-v8.2.1> # v8.2.1You can find the SHA for v8.2.1 using:
git ls-remote https://github.com/super-linter/super-linter v8.2.1| uses: super-linter/super-linter@v8.2.1 | |
| # v8.2.1 | |
| uses: super-linter/super-linter@b7e7e6e2c7e6e7e2e7e6e2c7e6e7e2e7e6e2c7e6 |
There was a problem hiding this comment.
Fixed in 917299c. Reverted the super-linter.lock.yml to use SHA-pinned version 2bdd90ed3262e023ac84bf8fe35dc480721fc1f2 instead of tag v8.2.1 to maintain security best practices.
|
@copilot lint |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Test Coverage for Critical Untested Go Files - COMPLETED ✅
This PR successfully adds comprehensive unit tests for critical files that lacked test coverage.
Files Created
pkg/workflow/scripts_test.go- New file with 5 comprehensive test suites ✅pkg/cli/compile_command_test.go- New file with 11 comprehensive test suites ✅pkg/workflow/safe_outputs.go- Already has extensive test coverage (no action needed) ✅Recent Updates
Latest commit: Properly restored
.github/workflows/super-linter.lock.ymlto use SHA-pinned actions:super-linter/super-linter@2bdd90ed3262e023ac84bf8fe35dc480721fc1f2(wasv8.2.1)actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093(was tag-based)actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02(was tag-based)Previous commit: Fixed linting issue - removed ineffectual assignment in
TestCompileWorkflows_EmptyMarkdownFilesTest Coverage Summary
pkg/workflow/scripts_test.go(317 lines)Tests all JavaScript script bundling and retrieval functions with comprehensive coverage:
Coverage: All 18 script getter functions + embedded sources
pkg/cli/compile_command_test.go(413 lines)Tests workflow compilation command functionality with 13 test suites covering:
Coverage: Configuration validation, error handling, flag combinations, edge cases
Test Execution Results
Security Best Practices
✅ All GitHub Actions are now SHA-pinned per project security guidelines
✅ No tags used in action references to prevent supply chain attacks
Acceptance Criteria Met
make test-unitmake lintOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.