|
| 1 | +# Go Version Upgrade Guide |
| 2 | + |
| 3 | +This document outlines the process for upgrading the Go version used in the prometheus-rds-exporter project. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The prometheus-rds-exporter project uses Go for building the application and relies on specific Go versions defined in multiple configuration files. When upgrading Go, all references must be updated consistently. |
| 8 | + |
| 9 | +## Files to Update |
| 10 | + |
| 11 | +When upgrading Go version, the following files need to be updated: |
| 12 | + |
| 13 | +### 1. go.mod |
| 14 | +- Update the `go` directive to specify the new Go version |
| 15 | +- Update the `toolchain` directive to match the new Go version |
| 16 | + |
| 17 | +**Example:** |
| 18 | +```go |
| 19 | +go 1.24.0 |
| 20 | + |
| 21 | +toolchain go1.24.0 |
| 22 | +``` |
| 23 | + |
| 24 | +### 2. GitHub Actions Workflows |
| 25 | + |
| 26 | +Update the `go-version` in the `actions/setup-go@v5` step |
| 27 | + |
| 28 | +**Example:** |
| 29 | +```yaml |
| 30 | +- uses: actions/setup-go@v5 |
| 31 | + with: |
| 32 | + go-version: '1.24' |
| 33 | +``` |
| 34 | +
|
| 35 | +Update the Go version in all workflow files: |
| 36 | +- `.github/workflows/build.yaml` |
| 37 | +- `.github/workflows/test.yaml` |
| 38 | +- `github/workflows/linter.yaml` |
| 39 | + |
| 40 | +### 3. Local development environment |
| 41 | + |
| 42 | +- Update golang base image version (`FROM`) in the `scripts/prometheus/Dockerfile` |
| 43 | + |
| 44 | +## Upgrade Process |
| 45 | + |
| 46 | +1. Check for any deprecated features or breaking changes in the new Go version |
| 47 | +2. Update `go.mod` with the new Go version and toolchain |
| 48 | +3. Run tests |
| 49 | + 1. Run local tests to ensure compatibility: |
| 50 | + ```bash |
| 51 | + make test |
| 52 | + make lint |
| 53 | + make build |
| 54 | + ``` |
| 55 | + 2. Update Go dependencies if required: |
| 56 | + ```bash |
| 57 | + go mod tidy |
| 58 | + go mod download |
| 59 | + ``` |
| 60 | +4. Update GitHub Actions workflows with the specific Go version |
| 61 | +5. Commit these changes |
| 62 | +6. Verify GitHub Actions pass: |
| 63 | + - Push changes to a feature branch |
| 64 | + - Ensure all CI checks pass (linter, tests, build) |
| 65 | +7. Update this document with any new considerations |
| 66 | +8. Update README.md if it mentions specific Go version requirements |
| 67 | + |
| 68 | +## Considerations |
| 69 | + |
| 70 | +### Compatibility |
| 71 | + |
| 72 | +- Ensure all dependencies support the new Go version |
| 73 | +- Check for any breaking changes in the Go release notes |
| 74 | +- Verify that the Docker base images support the new Go version (if using Go-based images) |
| 75 | + |
| 76 | +### Testing |
| 77 | + |
| 78 | +- Run the full test suite locally before pushing |
| 79 | +- Monitor CI/CD pipelines for any failures |
| 80 | +- Test the built binary in a staging environment |
| 81 | + |
| 82 | +### Rollback Plan |
| 83 | + |
| 84 | +If issues arise after the upgrade: |
| 85 | +1. Revert the configuration files to the previous Go version |
| 86 | +2. Run tests to ensure stability |
| 87 | +3. Investigate and resolve the compatibility issues |
| 88 | +4. Retry the upgrade process |
| 89 | + |
| 90 | +## Useful Commands |
| 91 | + |
| 92 | +```bash |
| 93 | +# Overrides golang version for test if not installed locally |
| 94 | +GOTOOLCHAIN=go1.24.0 make test |
| 95 | +
|
| 96 | +# Check current Go version |
| 97 | +go version |
| 98 | +
|
| 99 | +# Update dependencies |
| 100 | +go mod tidy |
| 101 | +
|
| 102 | +# Run tests |
| 103 | +make test |
| 104 | +
|
| 105 | +# Build the application |
| 106 | +make build |
| 107 | +
|
| 108 | +# Run linter |
| 109 | +make lint |
| 110 | +
|
| 111 | +# Check for security issues |
| 112 | +make checkcov |
| 113 | +``` |
| 114 | + |
| 115 | +## References |
| 116 | + |
| 117 | +- [Go Release Notes](https://golang.org/doc/devel/release.html) |
| 118 | +- [Go Module Reference](https://golang.org/ref/mod) |
| 119 | +- [GitHub Actions Go Setup](https://github.com/actions/setup-go) |
0 commit comments