Skip to content

Commit 322295e

Browse files
author
azure-pipelines-bot
committed
Add comprehensive testing guide for release scripts
- Document how to test each script after dependency updates - Include step-by-step testing procedures for all scripts - Provide troubleshooting guide for common issues - Add environment setup requirements - Include validation checklist for script updates - Document pipeline integration points
1 parent 5d78bbe commit 322295e

File tree

1 file changed

+187
-0
lines changed

1 file changed

+187
-0
lines changed

release/README.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# Azure Pipelines Agent Release Scripts
2+
3+
This directory contains the release automation scripts for the Azure Pipelines Agent. These scripts are used in the Azure DevOps release pipelines to automate various aspects of the release process.
4+
5+
## Scripts Overview
6+
7+
| Script | Purpose | Dependencies Used |
8+
|--------|---------|-------------------|
9+
| `createReleaseBranch.js` | Creates release branches and generates release notes from PRs | `@octokit/rest`, `@octokit/graphql`, `azure-devops-node-api` |
10+
| `createAdoPrs.js` | Creates Azure DevOps pull requests for integration files | `azure-devops-node-api`, `azure-pipelines-task-lib` |
11+
| `fillReleaseNotesTemplate.js` | Fills release notes template with version and hash values | `util.js` (local) |
12+
| `rollrelease.js` | Manages GitHub releases (marks as non-prerelease) | `@octokit/rest` |
13+
| `util.js` | Utility functions for file operations and git commands | Node.js built-ins |
14+
15+
## Testing Scripts After Dependency Updates
16+
17+
When updating npm dependencies in `package.json`, follow these steps to ensure all scripts continue working:
18+
19+
### 1. Update Dependencies
20+
21+
```bash
22+
cd release/
23+
npm update
24+
# or for major version updates:
25+
npm install package@latest
26+
npm audit fix --force
27+
```
28+
29+
### 2. Test Each Script
30+
31+
#### A. Test `fillReleaseNotesTemplate.js`
32+
33+
```bash
34+
# Create mock hash files (scripts expect these)
35+
mkdir -p ../_hashes/hash
36+
echo "abcd1234567890abcd1234567890abcd1234567890abcd1234567890abcd1234" > ../_hashes/hash/vsts-agent-win-x64-3.999.999.zip.sha256
37+
echo "efgh1234567890efgh1234567890efgh1234567890efgh1234567890efgh1234" > ../_hashes/hash/vsts-agent-osx-x64-3.999.999.tar.gz.sha256
38+
39+
# Test the script
40+
node fillReleaseNotesTemplate.js 3.999.999
41+
42+
# Check if releaseNote.md was modified correctly
43+
git diff ../releaseNote.md
44+
45+
# Restore original file
46+
git restore ../releaseNote.md
47+
```
48+
49+
#### B. Test `rollrelease.js`
50+
51+
```bash
52+
# Test with dry-run and a real release version (requires GitHub PAT)
53+
PAT="your_github_pat" node rollrelease.js --dryrun --stage="Ring 5" --ghpat="${PAT}" 3.246.0
54+
55+
# Expected: Should connect to GitHub and show what it would do without errors
56+
```
57+
58+
#### C. Test `createReleaseBranch.js`
59+
60+
```bash
61+
# Test with dry-run mode (requires GitHub PAT)
62+
PAT="your_github_pat" node createReleaseBranch.js 4.262.0 --derivedFrom=lastMinorRelease --targetCommitId=$(git rev-parse HEAD) --dryrun
63+
64+
# Expected: Should execute git operations but skip the push step
65+
# Look for: "Dry run mode: skipping push" message
66+
```
67+
68+
#### D. Test `createAdoPrs.js`
69+
70+
```bash
71+
# Test with dry-run mode (requires Azure DevOps PAT)
72+
PAT="your_azdo_pat" node createAdoPrs.js --dryrun=true 3.999.999
73+
74+
# Expected: Should create integration files and show "Dry run: Skipping Azure DevOps API calls"
75+
# Should NOT show authentication errors (401)
76+
```
77+
78+
### 3. Common Issues and Solutions
79+
80+
#### Package Compatibility Issues
81+
82+
**Symptom**: `TypeError: got.get is not a function` or similar method errors
83+
**Solution**: Check if the package changed its API. Update the code to use the new API.
84+
85+
**Example**: `got` library changed from `got.get()` to `got()` in v12+
86+
```javascript
87+
// Old (v11 and earlier)
88+
const response = await got.get(url, options);
89+
90+
// New (v12+)
91+
const response = await got(url, options);
92+
```
93+
94+
#### Missing Dependencies
95+
96+
**Symptom**: `Cannot find module 'package-name'`
97+
**Solution**: Ensure the package is listed in `package.json` and run `npm install`
98+
99+
#### Authentication Issues
100+
101+
**Symptom**: `401 Unauthorized` errors during dry-run
102+
**Solution**: Ensure API calls are properly wrapped in dry-run checks:
103+
```javascript
104+
if (dryrun) {
105+
console.log('Dry run: Skipping API calls');
106+
return mockResponse;
107+
}
108+
// Make actual API calls here
109+
```
110+
111+
### 4. Required Environment Setup
112+
113+
#### For Testing with Real APIs
114+
115+
1. **GitHub PAT**: Required for `rollrelease.js` and `createReleaseBranch.js`
116+
- Set `PAT` environment variable
117+
- Needs `repo` scope permissions
118+
119+
2. **Azure DevOps PAT**: Required for `createAdoPrs.js`
120+
- Set `PAT` environment variable
121+
- Needs `Code (read & write)` and `Pull Request (read & write)` permissions
122+
123+
3. **Git Configuration**: Required for all scripts that make commits
124+
```bash
125+
git config --global user.email "[email protected]"
126+
git config --global user.name "Your Name"
127+
```
128+
129+
#### Mock Data Setup
130+
131+
Some scripts expect certain directories/files to exist:
132+
133+
```bash
134+
# For hash-related scripts
135+
mkdir -p ../_hashes/hash
136+
137+
# For integration file generation
138+
mkdir -p ../_layout/integrations
139+
```
140+
141+
### 5. Validation Checklist
142+
143+
After testing all scripts, verify:
144+
145+
- [ ] All scripts run without syntax errors
146+
- [ ] Dry-run modes work correctly (no unintended API calls)
147+
- [ ] Scripts handle missing files/directories gracefully
148+
- [ ] Updated packages don't introduce security vulnerabilities (`npm audit`)
149+
- [ ] Git operations execute properly in dry-run mode
150+
- [ ] API authentication works with provided PATs
151+
- [ ] Generated files (integration files, release notes) are correct
152+
153+
### 6. Pipeline Integration
154+
155+
These scripts are used in `.vsts.release.yml`:
156+
157+
- `fillReleaseNotesTemplate.js` - Line ~309
158+
- `createAdoPrs.js` - Line ~450
159+
- `createReleaseBranch.js` - Line ~200
160+
161+
After testing locally, verify the pipeline still works by running a test build.
162+
163+
## Troubleshooting
164+
165+
### Common Error Messages
166+
167+
1. **"ENOENT: no such file or directory, scandir"**
168+
- Missing `_hashes` directory
169+
- Solution: Create mock hash files as shown above
170+
171+
2. **"got.get is not a function"**
172+
- Package API changed
173+
- Solution: Update code to use new API
174+
175+
3. **"Failed request: (401)"**
176+
- Authentication issue or API calls in dry-run
177+
- Solution: Check PAT and dry-run logic
178+
179+
4. **Node.js version warnings**
180+
- Using outdated Node.js version
181+
- Solution: Ensure Node.js 18+ for native fetch support
182+
183+
### Getting Help
184+
185+
- Check the Azure DevOps pipeline logs for real-world usage examples
186+
- Review git history to see how similar issues were resolved
187+
- Test with minimal reproduction cases before updating production dependencies

0 commit comments

Comments
 (0)