|
| 1 | +# CI/CD Workflows |
| 2 | + |
| 3 | +This directory contains GitHub Actions workflows for automated testing. |
| 4 | + |
| 5 | +## Workflows |
| 6 | + |
| 7 | +### python-test.yml |
| 8 | + |
| 9 | +Automated testing workflow for Python modules that: |
| 10 | + |
| 11 | +1. **Detects versions to test** based on: |
| 12 | + - Pre-release files in PR (e.g., `bearsampp-python-3.13.5-2025.8.21.7z`) |
| 13 | + - Version numbers in PR titles (fallback) |
| 14 | + - Manual workflow dispatch with specific version |
| 15 | + |
| 16 | +2. **Tests each Python version** through multiple phases: |
| 17 | + - **Phase 1.1**: Download and extract Python module |
| 18 | + - **Phase 1.2**: Verify Python installation and executables |
| 19 | + - **Phase 2**: Test basic functionality (version, pip, imports) |
| 20 | + |
| 21 | +3. **Reports results**: |
| 22 | + - Generates test summary with badges |
| 23 | + - Comments on pull requests |
| 24 | + - Uploads test artifacts |
| 25 | + |
| 26 | +## Triggering Tests |
| 27 | + |
| 28 | +### Automatic Triggers |
| 29 | + |
| 30 | +Tests run automatically when: |
| 31 | + |
| 32 | +- **Push to main**: Tests latest version only |
| 33 | +- **Pull Request with pre-release files**: Tests versions detected from `.7z` filenames |
| 34 | +- **Pull Request with version in title**: Tests versions mentioned in PR title (fallback) |
| 35 | +- **Manual workflow dispatch**: Tests specified version or all versions |
| 36 | + |
| 37 | +### Manual Trigger |
| 38 | + |
| 39 | +You can manually trigger tests: |
| 40 | + |
| 41 | +1. Go to the Actions tab |
| 42 | +2. Select "Python Module Tests" |
| 43 | +3. Click "Run workflow" |
| 44 | +4. Optionally specify a version to test |
| 45 | + |
| 46 | +### PR Title Format |
| 47 | + |
| 48 | +To test specific versions in a PR, include version numbers in the title: |
| 49 | + |
| 50 | +- ✅ `Add Python 3.13.5 support` |
| 51 | +- ✅ `Update docs for 3.12.9` |
| 52 | +- ✅ `Fix issue with Python 3.13.3 and 3.12.6.0` |
| 53 | +- ❌ `Update documentation` (no version, won't trigger tests unless releases.properties changed) |
| 54 | + |
| 55 | +## Test Phases |
| 56 | + |
| 57 | +### Phase 1: Installation Validation |
| 58 | + |
| 59 | +**Phase 1.1 - Download and Extract** |
| 60 | +- Reads version from `releases.properties` |
| 61 | +- Downloads the `.7z` archive |
| 62 | +- Extracts to test directory |
| 63 | +- Verifies Python directory structure |
| 64 | + |
| 65 | +**Phase 1.2 - Verify Executables** |
| 66 | +- Checks for `python.exe` |
| 67 | +- Checks for `pip.exe` (in root or Scripts directory) |
| 68 | +- Validates executable paths |
| 69 | + |
| 70 | +### Phase 2: Basic Functionality |
| 71 | + |
| 72 | +- Tests `python --version` |
| 73 | +- Tests `pip --version` (via `python -m pip`) |
| 74 | +- Tests Python import system |
| 75 | +- Validates all critical components work |
| 76 | + |
| 77 | +## Test Results |
| 78 | + |
| 79 | +### Artifacts |
| 80 | + |
| 81 | +Test results are uploaded as artifacts: |
| 82 | + |
| 83 | +- `test-results-python-{version}`: Individual version test results |
| 84 | + |
| 85 | +Artifacts are retained for 30 days. |
| 86 | + |
| 87 | +### PR Comments |
| 88 | + |
| 89 | +For pull requests, the workflow posts a comment with: |
| 90 | + |
| 91 | +- Overall test status |
| 92 | +- Version-specific badges (PASS/FAIL) |
| 93 | +- Detailed results for failed tests |
| 94 | +- Links to artifacts |
| 95 | + |
| 96 | +### Status Badges |
| 97 | + |
| 98 | +Each version gets a badge: |
| 99 | + |
| 100 | +- 🟢  |
| 101 | +- 🔴  |
| 102 | +- ⚪  |
| 103 | + |
| 104 | +## Configuration |
| 105 | + |
| 106 | +### releases.properties Format |
| 107 | + |
| 108 | +```properties |
| 109 | +# Version = Download URL |
| 110 | +3.13.5 = https://github.com/Bearsampp/module-python/releases/download/2025.8.21/bearsampp-python-3.13.5-2025.8.21.7z |
| 111 | +3.12.9 = https://github.com/Bearsampp/module-python/releases/download/2025.4.19/bearsampp-python-3.12.9-2025.4.19.7z |
| 112 | +``` |
| 113 | + |
| 114 | +### Required Archive Structure |
| 115 | + |
| 116 | +The `.7z` archive must contain: |
| 117 | + |
| 118 | +``` |
| 119 | +bearsampp-python-X.X.X-YYYY.MM.DD.7z |
| 120 | +└── python-X.X.X/ |
| 121 | + ├── python.exe # Required |
| 122 | + ├── python3.dll # Required |
| 123 | + ├── python3XX.dll # Required |
| 124 | + ├── Scripts/ |
| 125 | + │ └── pip.exe # Optional but recommended |
| 126 | + └── Lib/ # Required |
| 127 | +``` |
| 128 | + |
| 129 | +## Troubleshooting |
| 130 | + |
| 131 | +### Tests Not Running |
| 132 | + |
| 133 | +**Problem**: Tests skipped on PR |
| 134 | + |
| 135 | +**Solutions**: |
| 136 | +- Add version number to PR title |
| 137 | +- Modify `releases.properties` |
| 138 | +- Manually trigger workflow |
| 139 | + |
| 140 | +### Download Failures |
| 141 | + |
| 142 | +**Problem**: Download fails with 404 |
| 143 | + |
| 144 | +**Solutions**: |
| 145 | +- Verify URL in `releases.properties` is correct |
| 146 | +- Check that release exists on GitHub |
| 147 | +- Ensure URL is publicly accessible |
| 148 | + |
| 149 | +### Extraction Failures |
| 150 | + |
| 151 | +**Problem**: Archive extraction fails |
| 152 | + |
| 153 | +**Solutions**: |
| 154 | +- Verify `.7z` archive is valid |
| 155 | +- Check archive structure matches expected format |
| 156 | +- Ensure archive is not corrupted |
| 157 | + |
| 158 | +### Executable Not Found |
| 159 | + |
| 160 | +**Problem**: `python.exe` not found after extraction |
| 161 | + |
| 162 | +**Solutions**: |
| 163 | +- Verify archive contains `python-X.X.X/` directory |
| 164 | +- Check that `python.exe` is in the root of that directory |
| 165 | +- Ensure extraction completed successfully |
| 166 | + |
| 167 | +## Permissions |
| 168 | + |
| 169 | +The workflow requires these permissions: |
| 170 | + |
| 171 | +- `contents: read` - Read repository contents |
| 172 | +- `pull-requests: write` - Comment on PRs |
| 173 | +- `issues: write` - Update issue comments |
| 174 | + |
| 175 | +## Best Practices |
| 176 | + |
| 177 | +1. **Test locally first**: Verify changes work before pushing |
| 178 | +2. **Use descriptive PR titles**: Include version numbers when relevant |
| 179 | +3. **Check workflow logs**: Review detailed logs for failures |
| 180 | +4. **Update documentation**: Keep docs in sync with code changes |
| 181 | +5. **Monitor artifacts**: Download and review test results |
| 182 | + |
| 183 | +## Support |
| 184 | + |
| 185 | +For issues with the CI/CD workflow: |
| 186 | + |
| 187 | +1. Check workflow logs in the Actions tab |
| 188 | +2. Review this README for troubleshooting tips |
| 189 | +3. Open an issue with workflow run details |
| 190 | +4. Include error messages and relevant logs |
0 commit comments