Fix file descriptor compilation error in zpmod module#60
Fix file descriptor compilation error in zpmod module#60
Conversation
…kip FD paths Co-authored-by: ss-o <59910950+ss-o@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sall <59910950+ss-o@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sall <59910950+ss-o@users.noreply.github.com>
…access` calls Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sall <59910950+ss-o@users.noreply.github.com>
- Updated README.md to clarify module features and installation instructions. - Added Scripts/README.md to document available utility scripts. - Introduced clean.sh for removing build artifacts. - Implemented copy_from_zsh_src.zsh for syncing with Zsh source. - Enhanced install.sh to detect Zi and guide users accordingly. - Modified zp_should_skip_compilation to accept a file stat struct. - Created release workflow for automated GitHub releases. - Updated .gitignore to include additional binary files. - Removed obsolete .vscode/settings.json. Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sall <59910950+ss-o@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sall <59910950+ss-o@users.noreply.github.com>
…in permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Sall <59910950+ss-o@users.noreply.github.com>
Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
- Consolidate all AI instruction files into standardized .github/copilot-instructions.md - Remove redundant .github/copilot/ and .github/instructions/ directories - Improve shellcheck compliance in Scripts/advanced-install.sh and Scripts/update-readme.sh - Follow VS Code standard for GitHub Copilot instructions location
- Add comprehensive project metadata and repository structure - Improve formatting and organization for better readability - Include detailed architecture and development workflow guidance - Add specific examples and error handling patterns - Enhance consistency guidelines for z-shell organization - Follow VS Code standards for GitHub Copilot instruction files - Fix all lint issues and ensure clean formatting
…onventions from Copilot instructions Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
- Reorganize docs/ directory following industry-standard Divio documentation system - Create 4 main categories: tutorials/, how-to/, reference/, explanation/ - Move existing documentation files to appropriate categories: - CONTRIBUTING.md → how-to/contributing.md - index.md → comprehensive project overview - Add README.md files for each category with clear guidelines - Remove empty files (BEST_PRACTICES.md, MODULE_FUNCTIONALITY.md) - Implement consistent structure for long-term maintainability This follows the Divio documentation system: - Tutorials: Learning-oriented, step-by-step guides - How-to: Problem-oriented, practical instructions - Reference: Information-oriented, technical specifications - Explanation: Understanding-oriented, background knowledge
- Remove broken sync-docs.yml workflow that failed due to missing extract_section function - Remove overly complex advanced-ci-cd.yml workflow (redundant with existing test workflows) - Fix README.md documentation links to match new reorganized docs structure - Fix release.yml workflow to point to correct README path - Remove broken Scripts/update-readme.sh script that had undefined functions Simplified workflow structure: - test-linux.yml ✅ Core Linux testing - test-macos.yml ✅ Core macOS testing - release.yml ✅ Release automation (fixed) This resolves workflow failures and maintains only essential, working CI/CD pipelines.
…ines - Add comprehensive documentation strategy section explaining Divio documentation system - Define four documentation categories: tutorials/, how-to/, reference/, explanation/ - Include specific guidelines for adding and maintaining documentation - Emphasize consistency across all Z-Shell organization repositories - Update contribution guidelines to reference new documentation structure - Remove reference to deleted Scripts/update-readme.sh script - Add dedicated Documentation Maintenance section in Best Practices This ensures the implemented docs/ structure is maintained consistently across all changes and repositories in the organization.
- Create dedicated CodeQL workflow to handle security scanning - Use --with-tcsetpgrp configure option to avoid TTY requirement in CI - Disable unnecessary dependencies (GDBM, PCRE) for faster builds - Set appropriate timeouts and permissions for security analysis - Schedule weekly scans for continuous security monitoring This resolves the 'configure: error: no controlling tty' issue by using CI-friendly configure options while maintaining full code analysis coverage. Alternative to GitHub's default CodeQL setup which fails due to TTY requirements.
|
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
- Expand Linux test workflow with complete feature coverage: • Source-study report generation (basic and list modes) • Path cache management and clearing operations • Compilation configuration testing (enable/disable/batch modes) • Automatic script compilation and .zwc generation • Performance tracking and timing analysis • Error handling and edge case validation • Help command verification - Enhance macOS test workflow with platform-specific testing: • macOS compatibility verification for all core features • Platform-specific test scripts and compilation • Cross-platform performance validation - Add comprehensive test file creation for realistic scenarios - Include detailed verification steps and error reporting - Test all major zpmod builtin commands and functionality - Ensure proper module loading and cleanup These workflows now properly test the implemented features including: automatic compilation, performance tracking, path caching, and configuration management that were previously untested.
- Fix corrupted string in Scripts/advanced-install.sh line 493 - Configure shellcheck to ignore copy_from_zsh_src.zsh (not supported by shellcheck) - Update both test-linux.yml and test-macos.yml workflows - Ensure all shell scripts pass shellcheck validation Resolves workflow failures caused by: 1. Malformed variable reference in advanced-install.sh 2. Shellcheck attempting to parse Zsh script (not supported)
…rrect location - Move ORGANIZATION_ACTIONS_PLAN.md from workspace root to docs/explanation/ - Rename to github-actions-strategy.md following kebab-case naming convention - Update docs/explanation/README.md to include the new file - Update docs/index.md to maintain discoverability This follows the Divio documentation system correctly: - Organization strategy is explanation-oriented (understanding background) - Placed in docs/explanation/ directory as specified in Copilot instructions - Properly integrated with documentation navigation Fixes: Incorrectly placing documentation outside the established structure
…emove obsolete files Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
…to 0644; simplify memory management in zp_lazy_loader_destroy and zp_lazy_loader_register functions. Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
…it flags and avoid CodeQL security warning Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR implements comprehensive documentation, infrastructure improvements, and new advanced features for the zpmod module, transforming it from a basic script compilation tool into a feature-rich performance optimization module with proper documentation and CI/CD infrastructure.
- Implements comprehensive documentation following the Divio documentation system with tutorials, how-to guides, reference materials, and explanations
- Adds new advanced features including path caching, compilation optimization, and lazy loading systems
- Establishes proper CI/CD infrastructure with GitHub Actions workflows for testing, security analysis, and automated releases
Reviewed Changes
Copilot reviewed 55 out of 57 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/ | Complete documentation restructure following Divio system with tutorials, how-to guides, reference docs, and explanations |
| Src/zi/zpmod.c | Major module enhancement with new advanced features, improved error handling, and integration of new subsystems |
| Src/zi/*.c | New modular components for path caching, compilation configuration, and lazy loading |
| .github/workflows/ | New CI/CD infrastructure with comprehensive testing, security analysis, and release automation |
| Scripts/ | Enhanced build and installation scripts with advanced options and better error handling |
Src/exec.c
Outdated
| O_WRONLY | O_CREAT | O_TRUNC | O_NOCTTY, 0644); | ||
|
|
||
| /* If not clobbering, attempt to create file exclusively. */ | ||
| if ((fd = open(ufname, | ||
| O_WRONLY | O_CREAT | O_EXCL | O_NOCTTY, 0666)) >= 0) | ||
| O_WRONLY | O_CREAT | O_EXCL | O_NOCTTY, 0644)) >= 0) |
There was a problem hiding this comment.
File permissions changed from 0666 to 0644, which is more secure but may break existing functionality that expects group/other write permissions. Consider if this change is intentional and document the security rationale.
Src/zi/zpmod.c
Outdated
| zwarn("Unknown option: %s", zp_options[i].name); | ||
| } | ||
| int i, optno; | ||
| for (i = 0; i < sizeof(zp_options) / sizeof(struct zp_option_name) - 10 - 1; ++i) |
There was a problem hiding this comment.
Magic numbers -10 and -1 in array size calculation make the code fragile. Consider using named constants or calculating the actual array bounds dynamically to prevent buffer overflows if the array structure changes.
| for (i = 0; i < sizeof(zp_options) / sizeof(struct zp_option_name) - 10 - 1; ++i) | |
| for (i = 0; i < sizeof(zp_options) / sizeof(struct zp_option_name) - ZP_OPTIONS_OFFSET - ZP_OPTIONS_END_PADDING; ++i) |
| } | ||
|
|
||
| printed = snprintf(NULL, 0, "%4.0lf ms %s\n", node->event.duration, | ||
| printed = fprintf(null_fle, "%4.0lf ms %s\n", node->event.duration, |
There was a problem hiding this comment.
Using fprintf to /dev/null just to calculate string length is inefficient. Consider using snprintf with NULL buffer or strlen-based calculation instead of opening /dev/null for this purpose.
| printed = fprintf(null_fle, "%4.0lf ms %s\n", node->event.duration, | |
| printed = snprintf(NULL, 0, "%4.0lf ms %s\n", node->event.duration, |
| /**/ | ||
| static int | ||
| zp_append_report(const char *nam, const char *target, UNUSED(int target_len), const char *body, int body_len) | ||
| zp_append_report(const char *nam, const char *target, int target_len, const char *body, int body_len) |
There was a problem hiding this comment.
The parameter target_len is marked as UNUSED in the original function signature but now being used. Remove the UNUSED annotation or verify the parameter is actually needed and used correctly.
| zp_append_report(const char *nam, const char *target, int target_len, const char *body, int body_len) | |
| zp_append_report(const char *nam, const char *target, const char *body, int body_len) |
|
|
||
| /* Check file size if it's not too large */ | ||
| struct stat st; | ||
| if (stat(file, &st) == 0 && S_ISREG(st.st_mode)) { |
There was a problem hiding this comment.
This function calls stat() on every file check, but the module already has a path cache system. Consider using zp_path_cache_stat() instead to leverage the existing caching infrastructure.
|
|
||
| get_latest_version() { | ||
| log "DEBUG" "Fetching latest version information" | ||
| curl -s "${RELEASES_URL}/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/' || echo "unknown" |
There was a problem hiding this comment.
The version detection command uses a fragile parsing approach that could fail silently. Consider using a more robust JSON parsing method or add better error handling when the API response format changes.
- Removed legacy files and configurations: .cvsignore, .distfiles, and .preconfig from various directories. - Updated .gitignore to exclude unnecessary files and legacy configurations. - Modified configuration file paths to align with new structure: moved from ~/.config/zpmod to ~/.config/zi. - Enhanced security by adjusting file creation permissions to respect user umask settings, preventing world-writable files. - Added new documentation on security improvements and usage of configuration helpers. - Introduced new helper functions for performance analysis and troubleshooting in the configuration file. - Updated README and tutorial documents to reflect changes in configuration and new helper functions. - Improved code quality by removing magic numbers and ensuring safe buffer usage in the source code. Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
- Introduced `Scripts/maintenance.sh` for comprehensive workspace maintenance tasks including health checks, code linting, documentation updates, version consistency checks, and security scans. - Implemented commands for deep cleaning build artifacts and validating configuration files. - Integrated trunk.io code quality tools for automated checks. refactor: Remove obsolete configuration files - Deleted unused `.epro` and `.pro` files from `Src/zi` directory to clean up the project structure. feat: Enhance version management in zpmod - Added version information constants in `Src/zi/zpmod.c` for better version tracking. - Implemented a new command to display the current version of the zpmod module. docs: Update documentation for clarity and completeness - Revised `docs/explanation/README.md` to provide a clearer overview of available explanations. - Created `docs/explanation/versioning-architecture.md` detailing the independent versioning system for zpmod. - Added `docs/how-to/branching-and-tagging-guidelines.md` to outline version management and release processes. - Updated `docs/index.md` to include new documentation links for versioning and branching guidelines. Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
…ance improvements; add comprehensive quality scripts and update documentation Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
This pull request introduces significant updates to the repository, including the removal of outdated files and content, the addition of new documentation and templates, and improvements to the CI/CD pipeline. The changes aim to streamline development workflows, enhance documentation consistency, and optimize automation processes.
Removal of outdated files and content:
.github/.cspell/project-ignored.txtand.github/.cspell/project-words.txt: Removed obsolete entries to declutter the spell-check configuration. [[1]](https://github.com/z-shell/zpmod/pull/60/files#diff-ba363a04347c98cdefaa1a2fc4d6bd7b41e61de4 501c07ef7e3246797ba1c15cL1-L3) [2].github/LICENCE: Removed the outdated license file, which may indicate a shift to a different licensing strategy or consolidation elsewhere..github/README.md: Deleted the README file, potentially to replace it with updated documentation elsewhere.Addition of new documentation and templates:
.github/PULL_REQUEST_TEMPLATE/pull_request_template.md: Added a pull request template to standardize contributions and ensure developers provide necessary information for reviews..github/copilot-instructions.md: Introduced detailed documentation for GitHub Copilot usage in the repository, including project structure, development workflow, and best practices.CI/CD pipeline enhancements:
.github/workflows/ci.yml: Added a new CI/CD workflow leveraging reusable GitHub Actions from the Z-Shell organization for tasks like setting up the development environment, building, and testing thezpmodmodule. This improves automation and reduces redundancy.