|
| 1 | +# GraphHopper Build Pipeline Documentation |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The GraphHopper build pipeline (`build.yml`) is a GitHub Actions workflow that automates building, testing, and deploying the GraphHopper routing engine to Azure DevOps. The pipeline runs on every push to the repository. |
| 6 | + |
| 7 | +## Pipeline Structure |
| 8 | + |
| 9 | +### Job 1: Build and Test |
| 10 | +**Trigger:** Every push to any branch |
| 11 | + |
| 12 | +This job builds and tests the GraphHopper project across multiple Java versions to ensure compatibility. |
| 13 | + |
| 14 | +**Steps:** |
| 15 | +1. **Checkout code** - Retrieves the repository code |
| 16 | +2. **Setup Java** - Configures Java using the Temurin distribution |
| 17 | + - Tested versions: Java 25 and Java 26-ea (early access) |
| 18 | + - Uses a matrix strategy to test both versions in parallel |
| 19 | +3. **Cache Maven artifacts** - Caches `~/.m2/repository` to speed up builds |
| 20 | +4. **Cache node** - Caches `web-bundle/node` directory |
| 21 | +5. **Cache node_modules** - Caches `web-bundle/node_modules` directory |
| 22 | +6. **Build and Test** - Runs `mvn -B clean test` |
| 23 | + |
| 24 | +### Job 2: Push to Azure DevOps |
| 25 | +**Trigger:** Only runs on successful build when pushing to the `master` branch |
| 26 | + |
| 27 | +This job packages the GraphHopper JAR file and pushes it to the Azure DevOps repository for deployment. |
| 28 | + |
| 29 | +**Configuration Variables:** |
| 30 | +- `AZURE_ORG`: trihydro |
| 31 | +- `AZURE_PROJECT`: SDX |
| 32 | +- `AZURE_REPO`: graphhopper |
| 33 | +- `JAVA_VERSION`: 25 |
| 34 | + |
| 35 | +**Steps:** |
| 36 | +1. **Checkout code** - Retrieves the repository code |
| 37 | +2. **Package JAR** - Runs `mvn -B package -DskipTests` to create the JAR file |
| 38 | +3. **Get JAR info** - Extracts JAR filename and creates a timestamp |
| 39 | +4. **Clone Azure DevOps Repository** - Clones the Azure repo using PAT authentication |
| 40 | +5. **Commit and push JAR** - Creates a new branch, backs up old JAR, commits new JAR |
| 41 | +6. **Create Pull Request** - Creates PR in Azure DevOps with designated reviewers |
| 42 | + |
| 43 | +## Required Secrets |
| 44 | + |
| 45 | +The following GitHub repository secrets must be configured for the pipeline to work: |
| 46 | + |
| 47 | +### `AZURE_DEVOPS_PAT` |
| 48 | +**Type:** Personal Access Token |
| 49 | +**Purpose:** Authenticates GitHub Actions with Azure DevOps |
| 50 | +**Permissions Required:** |
| 51 | +- Code: Read & Write |
| 52 | + |
| 53 | +**How to Update:** |
| 54 | +1. Go to Azure DevOps → User Settings → Personal Access Tokens |
| 55 | +2. Create a new token or regenerate existing one with the required permissions |
| 56 | +3. Copy the token value |
| 57 | +4. Go to GitHub repository → Settings → Secrets and variables → Actions |
| 58 | +5. Update or create `AZURE_DEVOPS_PAT` secret with the new token value |
| 59 | + |
| 60 | +### `AZURE_GH_REPO_ID` |
| 61 | +**Type:** Repository GUID |
| 62 | +**Purpose:** Identifies the Azure DevOps repository for API calls |
| 63 | + |
| 64 | +**How to Find:** |
| 65 | +1. Run command: `az repos list --organization "https://dev.azure.com/trihydro" --project "SDX" --query "[?name == 'graphhopper'].id" --output tsv` |
| 66 | + |
| 67 | +### `TEAGHEN_DEVOPS_USER_ID` & `CHAN_DEVOPS_USER_ID` |
| 68 | +**Type:** User GUID |
| 69 | +**Purpose:** Adds Teaghen and Chan as a PR reviewer automatically |
| 70 | + |
| 71 | +**How to Find/Update:** |
| 72 | +1. Make API call to: https://vssps.dev.azure.com/trihydro/_apis/graph/users?api-version=7.1-preview.1 |
| 73 | + 1. Authorization header: Basic `<AZURE_DEVOPS_PAT>` |
| 74 | + 2. Content-Type header: application/json |
| 75 | +2. Update the GitHub secret with the originId value. |
| 76 | + |
| 77 | +## Maintenance Guide |
| 78 | + |
| 79 | +### Updating Java Versions |
| 80 | +To test against different Java versions: |
| 81 | +1. Edit `.github/workflows/build.yml` |
| 82 | +2. Modify the `matrix.java-version` array (currently `[25, 26-ea]`) |
| 83 | +3. Update the `JAVA_VERSION` environment variable in the `push-to-azure` job if changing the deployment version |
| 84 | + |
| 85 | +### Updating Azure DevOps Configuration |
| 86 | +To change the target Azure DevOps organization, project, or repository: |
| 87 | +1. Edit `.github/workflows/build.yml` |
| 88 | +2. Update the environment variables in the `push-to-azure` job: |
| 89 | + - `AZURE_ORG` |
| 90 | + - `AZURE_PROJECT` |
| 91 | + - `AZURE_REPO` |
| 92 | + |
| 93 | +### Adding/Removing Reviewers |
| 94 | +To modify automatic PR reviewers: |
| 95 | +1. Add the new reviewer user ID secrets in GitHub repository settings |
| 96 | +2. Edit the `Create Pull Request in Azure DevOps` step in `build.yml` |
| 97 | +3. Add/remove reviewer objects in the `reviewers` array of the PR payload |
| 98 | + |
| 99 | +### Monitoring Secrets Expiration |
| 100 | +**Recommended Schedule:** |
| 101 | +- Azure DevOps PATs typically expire after 90 days depending on configuration |
| 102 | +- Set up calendar reminders 2 weeks before known expiration dates |
| 103 | + |
| 104 | +### Troubleshooting Common Issues |
| 105 | + |
| 106 | +**Build fails but tests pass locally:** |
| 107 | +- Check Java version compatibility (pipeline uses Java 25/26) |
| 108 | +- Clear Maven cache by removing the cache action temporarily |
| 109 | + |
| 110 | +**Azure push fails with an authentication error:** |
| 111 | +- `AZURE_DEVOPS_PAT` has likely expired - regenerate it |
| 112 | +- Verify the PAT has Code and Pull Request permissions |
| 113 | + |
| 114 | +**Pull Request creation fails:** |
| 115 | +- Verify `AZURE_GH_REPO_ID` is correct |
| 116 | +- Check that reviewer IDs are valid and users have access to the repository |
| 117 | +- Ensure the target branch (master) exists in Azure DevOps repo |
| 118 | + |
| 119 | +## Workflow Diagram |
| 120 | + |
| 121 | +``` |
| 122 | +┌─────────────────┐ |
| 123 | +│ Push Event │ |
| 124 | +└────────┬────────┘ |
| 125 | + │ |
| 126 | + ▼ |
| 127 | +┌─────────────────────────┐ |
| 128 | +│ Build & Test Job │ |
| 129 | +│ - Java 25 │ |
| 130 | +│ - Java 26-ea │ |
| 131 | +│ - Maven clean test │ |
| 132 | +└────────┬────────────────┘ |
| 133 | + │ |
| 134 | + ▼ |
| 135 | + [master branch?] |
| 136 | + │ Yes |
| 137 | + ▼ |
| 138 | +┌─────────────────────────┐ |
| 139 | +│ Push to Azure Job │ |
| 140 | +│ 1. Package JAR │ |
| 141 | +│ 2. Clone Azure repo │ |
| 142 | +│ 3. Create branch │ |
| 143 | +│ 4. Commit JAR │ |
| 144 | +│ 5. Push branch │ |
| 145 | +│ 6. Create PR │ |
| 146 | +└─────────────────────────┘ |
| 147 | +``` |
| 148 | + |
0 commit comments