The Importance of Version Locking in Software Development
Igor Udot 吴一格
Version locking is a critical practice in software development that helps ensure consistency and reliability across different environments.
A Real-World Example
Recently, I encountered an issue in a CI pipeline where a seemingly straightforward Python build process failed. Here's the original workflow:
name: Test Build Python Packages
on:
pull_request:
jobs:
test-build-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.7'
- name: Build packages
run: |
bash foreach.sh build
The pipeline failed with this error:
Error: The version '3.7' with architecture 'x64' was not found for Ubuntu 24.04.
What Went Wrong?
The issue arose because the workflow used ubuntu-latest
, which automatically upgraded to Ubuntu 24.04. This newer version of Ubuntu doesn't support Python 3.7, creating an incompatibility that broke the build process.
Solutions and Best Practices
There are two immediate solutions to this problem:
Update Python Version:
python-version: '3.10' # Use a newer Python version
Lock Ubuntu Version:
runs-on: ubuntu-22.04 # Lock to a specific Ubuntu version
However, this incident highlights a broader principle: the importance of version locking across your entire stack.
Why Version Locking Matters
Version locking provides several key benefits. It’s possible to list many of them, but these two are the most important, IMHO:
- Reproducibility: Ensures that builds are consistent across different environments and times
- Time Savings: Prevents unexpected failures that require immediate fixes
Updated Example
name: Test Build Python Packages
on:
pull_request:
jobs:
test-build-packages:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.7'
- name: Build packages
run: |
bash foreach.sh build
Conclusion
Remember: Version locking isn’t about avoiding updates; it’s about controlling when and how updates happen on your terms.
Save your time by avoiding unnecessary waste...