|
| 1 | +# CI/CD Pipeline Documentation |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +GridPACK uses GitHub Actions to build multi-architecture Docker images that are automatically published to Docker Hub at `pnnl/gridpack`. |
| 6 | + |
| 7 | +## Pipeline Architecture |
| 8 | + |
| 9 | +The pipeline uses native ARM64 and AMD64 runners for optimal build performance: |
| 10 | + |
| 11 | +``` |
| 12 | +prepare-metadata → build-native (amd64 + arm64) → merge-manifest → test-native (amd64 + arm64) |
| 13 | + ↓ parallel ↓ ↓ ↓ parallel ↓ |
| 14 | +``` |
| 15 | + |
| 16 | +### Jobs |
| 17 | + |
| 18 | +1. **prepare-metadata**: Generates Docker tags and labels |
| 19 | +2. **build-native**: Builds images natively on AMD64 and ARM64 runners in parallel |
| 20 | +3. **merge-manifest**: Stitches architecture-specific images into a multi-arch manifest |
| 21 | +4. **test-native**: Runs ctest smoke tests on both architectures in parallel |
| 22 | + |
| 23 | +### Performance |
| 24 | + |
| 25 | +- **Native ARM64 builds**: 3-10x faster than QEMU emulation |
| 26 | +- **Parallel execution**: Both architectures build simultaneously |
| 27 | +- **Total build time**: ~20-35 minutes (vs 45-90 minutes with QEMU) |
| 28 | + |
| 29 | +## Triggers |
| 30 | + |
| 31 | +### Automatic: Release Published |
| 32 | + |
| 33 | +When a GitHub release is created, the pipeline automatically builds and publishes: |
| 34 | + |
| 35 | +```bash |
| 36 | +gh release create v3.3.0 --title "Release 3.3.0" --notes "Release notes" |
| 37 | +``` |
| 38 | + |
| 39 | +Generated tags: |
| 40 | +- `pnnl/gridpack:3.3.0` |
| 41 | +- `pnnl/gridpack:3.3` |
| 42 | +- `pnnl/gridpack:latest` |
| 43 | + |
| 44 | +### Manual: Workflow Dispatch |
| 45 | + |
| 46 | +Trigger builds manually from the GitHub Actions UI or CLI: |
| 47 | + |
| 48 | +**Via GitHub UI:** |
| 49 | +1. Go to: Actions → Docker Multi-Architecture Build and Publish |
| 50 | +2. Click "Run workflow" |
| 51 | +3. Configure options: |
| 52 | + - **tag**: Custom Docker tag (default: `dev`) |
| 53 | + - **skip_tests**: Skip ctest smoke tests (default: `false`) |
| 54 | + - **dockerfile**: Dockerfile path (default: `./Dockerfile`) |
| 55 | +4. Click "Run workflow" |
| 56 | + |
| 57 | +**Via GitHub CLI:** |
| 58 | + |
| 59 | +```bash |
| 60 | +# Basic run with defaults |
| 61 | +gh workflow run docker-build.yml |
| 62 | + |
| 63 | +# With custom tag |
| 64 | +gh workflow run docker-build.yml -f tag=test-build |
| 65 | + |
| 66 | +# Skip tests for faster iteration |
| 67 | +gh workflow run docker-build.yml -f skip_tests=true |
| 68 | + |
| 69 | +# Use custom Dockerfile |
| 70 | +gh workflow run docker-build.yml -f dockerfile=./Dockerfile.custom |
| 71 | +``` |
| 72 | + |
| 73 | +## Docker Image |
| 74 | + |
| 75 | +### Repository |
| 76 | +- **Location**: `pnnl/gridpack` |
| 77 | +- **Registry**: Docker Hub |
| 78 | + |
| 79 | +### Supported Architectures |
| 80 | +- `linux/amd64` (Intel/AMD) |
| 81 | +- `linux/arm64` (ARM64/Apple Silicon/AWS Graviton) |
| 82 | + |
| 83 | +### Usage |
| 84 | + |
| 85 | +See [Docker Usage Guide](./DOCKER.md) for detailed examples. |
| 86 | + |
| 87 | +## Testing |
| 88 | + |
| 89 | +The pipeline runs ctest smoke tests on both architectures after building. Key points: |
| 90 | + |
| 91 | +- **Non-blocking**: Test failures do NOT prevent image publication (`continue-on-error: true`) |
| 92 | +- **Expected pass rate**: ~94% |
| 93 | +- **Can be skipped**: Use `skip_tests=true` for faster iteration |
| 94 | + |
| 95 | +## Secrets Required |
| 96 | + |
| 97 | +The pipeline requires two GitHub repository secrets: |
| 98 | + |
| 99 | +| Secret | Description | |
| 100 | +|--------|-------------| |
| 101 | +| `DOCKERHUB_USERNAME` | Docker Hub username for authentication | |
| 102 | +| `DOCKERHUB_TOKEN` | Docker Hub access token (not password!) | |
| 103 | + |
| 104 | +### Setting Up Secrets |
| 105 | + |
| 106 | +1. **Generate Docker Hub Access Token:** |
| 107 | + - Go to: https://hub.docker.com → Account Settings → Security |
| 108 | + - Create token: Name: `gridpack-ci`, Permissions: Read, Write, Delete |
| 109 | + - Copy the token (shown only once) |
| 110 | + |
| 111 | +2. **Add to GitHub:** |
| 112 | + - Go to: Repository Settings → Secrets and variables → Actions |
| 113 | + - Add both secrets with the values above |
| 114 | + |
| 115 | +## Monitoring |
| 116 | + |
| 117 | +### View Workflow Runs |
| 118 | + |
| 119 | +```bash |
| 120 | +# List recent runs |
| 121 | +gh run list --workflow=docker-build.yml --limit 5 |
| 122 | + |
| 123 | +# Watch a specific run |
| 124 | +gh run watch <run-id> |
| 125 | + |
| 126 | +# View detailed logs |
| 127 | +gh run view <run-id> --log |
| 128 | +``` |
| 129 | + |
| 130 | +### Inspect Published Image |
| 131 | + |
| 132 | +```bash |
| 133 | +# View manifest with both architectures |
| 134 | +docker buildx imagetools inspect pnnl/gridpack:latest |
| 135 | + |
| 136 | +# Expected output shows: |
| 137 | +# - linux/amd64 manifest |
| 138 | +# - linux/arm64 manifest |
| 139 | +``` |
| 140 | + |
| 141 | +## Caching |
| 142 | + |
| 143 | +The pipeline uses GitHub Actions cache to speed up builds: |
| 144 | + |
| 145 | +- Separate cache per architecture (`build-amd64`, `build-arm64`) |
| 146 | +- Automatically managed by GitHub |
| 147 | +- Improves rebuild times significantly |
| 148 | + |
| 149 | +## Troubleshooting |
| 150 | + |
| 151 | +### Build Fails on One Architecture |
| 152 | + |
| 153 | +The pipeline uses `fail-fast: false`, so if one architecture fails, the other continues. Check job logs for architecture-specific issues. |
| 154 | + |
| 155 | +### Manifest Merge Fails |
| 156 | + |
| 157 | +This usually indicates both architecture builds failed. Check that: |
| 158 | +- Docker Hub credentials are correct |
| 159 | +- Both build jobs completed successfully |
| 160 | +- Digest artifacts were uploaded |
| 161 | + |
| 162 | +### Authentication Issues |
| 163 | + |
| 164 | +Verify secrets are configured correctly: |
| 165 | +```bash |
| 166 | +gh secret list |
| 167 | +``` |
| 168 | + |
| 169 | +Should show: |
| 170 | +- `DOCKERHUB_USERNAME` |
| 171 | +- `DOCKERHUB_TOKEN` |
| 172 | + |
| 173 | +## Technical Details |
| 174 | + |
| 175 | +### Push-by-Digest Workflow |
| 176 | + |
| 177 | +The pipeline uses a digest-based approach: |
| 178 | + |
| 179 | +1. Each architecture builds and pushes: `pnnl/gridpack@sha256:abc123...` |
| 180 | +2. These are content-addressed (by digest), not tagged yet |
| 181 | +3. Manifest merge creates tags that reference both digests |
| 182 | +4. Docker automatically selects the right image based on client platform |
| 183 | + |
| 184 | +### Why Native Runners? |
| 185 | + |
| 186 | +- **Performance**: 3-10x faster ARM64 builds without QEMU |
| 187 | +- **Reliability**: No emulation issues or crashes |
| 188 | +- **Testing**: Tests run on actual target platforms |
| 189 | +- **Cost**: Same GitHub Actions pricing as AMD64 |
| 190 | + |
| 191 | +## Workflow File |
| 192 | + |
| 193 | +Location: `.github/workflows/docker-build.yml` |
| 194 | + |
| 195 | +The workflow definition must be in the default branch to be accessible. Changes to the workflow require merging to the default branch. |
| 196 | + |
| 197 | +## Future Enhancements |
| 198 | + |
| 199 | +Potential improvements: |
| 200 | +- Additional architectures (RISC-V when runners available) |
| 201 | +- Multi-registry support (GitHub Container Registry) |
| 202 | +- Build time metrics/reporting |
| 203 | +- Automated security scanning per architecture |
0 commit comments