Testing: GitHub Projects V2 Integration โ
Complete testing guide for GitHub Projects V2 automation.
Workflow: issue-automation.yml
Quick Start โ
Prerequisites โ
- GitHub CLI (
gh) installed - GitHub PAT with
repo+projectscopes - jq installed (for JSON parsing)
Setup Your PAT โ
See TESTING_API_KEY_SETUP.md for detailed setup.
Quick version:
# 1. Create PAT at: https://github.com/settings/tokens
# Scopes: repo, project
# Copy the token
# 2. Add to .env.local
echo "GH_PAT=ghp_YOUR_TOKEN_HERE" >> .env.localRun Tests โ
# Option 1: Using .env.local (easiest)
./.github/workflows/test-projects-v2.sh
# Option 2: Using environment variable
GH_PAT=ghp_YOUR_TOKEN_HERE bash ./.github/workflows/test-projects-v2.shWhat Gets Tested โ
The test script validates:
โ Project Discovery
- Searches repository โ organization โ user projects (in that order)
- Finds project by exact name match ("Lantern App")
- Returns correct project ID
โ Field Names
- Verifies "Status" field exists (case-sensitive)
- Confirms "In progress" status option exists
- Checks "Start date" field exists
โ API Connectivity
- GitHub API authentication works
- GraphQL endpoint responds
- PAT has sufficient permissions
โ Issue Linking
- Can add issue to project
- Can set Status field
- Can set Start date field
Expected Output โ
โ
GitHub CLI authenticated
โ
jq is installed
โ
Testing project discovery...
โ
Project "Lantern App" found (ID: PVT_...)
โ
Found 2 fields: Status, Start date
โ
Testing issue linking...
โ
Successfully linked test issue to project
โ
Successfully set Status = "In progress"
โ
Successfully set Start date = 2026-01-16
All tests passed!Troubleshooting โ
"gh command not found" โ
Install GitHub CLI:
# macOS
brew install gh
# Ubuntu/Debian
sudo apt install gh
# Or visit: https://cli.github.com"Not logged in" โ
Authenticate:
gh auth login"GH_PAT not found" โ
Set your token:
# Option 1: Add to .env.local
echo "GH_PAT=ghp_YOUR_TOKEN_HERE" >> .env.local
# Option 2: Export environment variable
export GH_PAT="ghp_YOUR_TOKEN_HERE"
# Option 3: Create .github/workflows/.env.local
echo "GH_PAT=ghp_YOUR_TOKEN_HERE" >> .github/workflows/.env.local"jq not installed" โ
Install JSON processor:
# macOS
brew install jq
# Ubuntu/Debian
sudo apt-get install jq
# Or visit: https://stedolan.github.io/jq/download/"Project 'Lantern App' not found" โ
Check:
- Project exists: Go to https://github.com/cattreedev/lantern_app/projects
- Correct name: Must be exactly "Lantern App" (case-sensitive)
- Correct scope: Repository-level projects checked first
- Permissions: PAT has
projectscope
Debugging:
# List projects script can find
gh project list --owner cattreedev --format json | jq .
gh api graphql -f query='query {
organization(login:"cattreedev") {
projectsV2(first:10) { nodes { title } }
}
}'"Insufficient permissions" โ
Your PAT needs scopes: repo + project
# Check current token scopes
gh auth status
# Create new token with correct scopes
# https://github.com/settings/tokens
# Scopes: repo, project"Field 'Status' not found" โ
Your project might have different field names.
Debug what fields exist:
gh api graphql -f projectId="PVT_YOUR_ID" -f query='query {
projectV2(id: $projectId) {
fields(first: 20) {
nodes { name }
}
}
}'Manual Testing โ
Test Issue Linking โ
# Create a test issue
gh issue create \
--title "Test Issue #$(date +%s)" \
--body "This is a test issue for Projects V2" \
--repo cattreedev/lantern_app
# Get the issue number from output, e.g., #999
# Link it to the project manually
gh api graphql -f query='mutation {
addProjectV2ItemById(input: {
projectId: "PVT_..."
contentId: "I_..." # Issue GraphQL ID
}) { item { id } }
}'Test Field Updates โ
# Update Status field
gh api graphql -f query='mutation {
updateProjectV2ItemFieldValue(input: {
projectId: "PVT_..."
itemId: "PVTI_..."
fieldId: "PVTF_..."
value: { singleSelectOptionId: "OPTION_ID" }
}) { projectV2Item { id } }
}'Current Configuration โ
Project Name: Lantern App (case-sensitive)
Fields:
- Status: with options ["In progress", "Todo", "Done"]
- Start date: date field
Workflow Triggers:
- Issue assigned
- Branch/PR created referencing issue
- Issue reopened
Workflow Actions:
- Adds issue to project
- Sets Status = "In progress"
- Sets Start date = today
How the Workflow Works โ
File: .github/workflows/issue-automation.yml
- Issue Event: Someone creates/assigns an issue
- Extract Issue Number: From PR title, branch name, or description
- Find Project: Searches repository โ organization โ user projects
- Link Issue: Adds issue to "Lantern App" project
- Set Fields: Status โ "In progress", Start date โ today
- Comment: Posts confirmation comment (if error, posts error details)
Testing Locally Before Deployment โ
Important: Always run local tests before deploying workflow changes:
# 1. Set up your PAT
echo "GH_PAT=ghp_YOUR_TOKEN_HERE" >> .env.local
# 2. Run the test script
./.github/workflows/test-projects-v2.sh
# 3. Verify all tests pass
# 4. Now safe to deploy to productionCost โ
GitHub Projects V2 API is FREE for repository projects.
โ
Unlimited issues
โ
Unlimited field updates
โ
Unlimited API calls
See Also โ
- API Key Setup - GitHub PAT setup
- Workflows Overview - All workflows
- GitHub Projects V2 Documentation
- GitHub GraphQL API
- Troubleshooting Guide - Advanced troubleshooting