-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(relpro): set 'version' parameter
Tasks like `mark-as-shipped` expect a version parameter to exist. This is supposed to be set by the release-promotion action, but I neglected to add this. Typically we just assume that there's a file called `version.txt` at the root of the repo, but this PR implements a new `version-parser` key in config.yml. This defaults to a parser that reads `version.txt`, but can be used to point to a custom function in case we want to support storing the version in other locations. This function takes the parameters as input so that it can make decisions around what version to return. For example, in `mozilla-vpn-client`, there are two distinct products that can be shipped (client and addons). This will allow them to determine a version based on things like the `shipping-phase`.
- Loading branch information
Showing
7 changed files
with
104 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import os | ||
|
||
from taskgraph.util.vcs import get_repository | ||
|
||
here = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
|
||
def default_parser(params): | ||
repo_root = get_repository(here).path | ||
|
||
with open(os.path.join(repo_root, "version.txt")) as f: | ||
return f.read().strip() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def fake_version(params): | ||
return "99" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from unittest.mock import mock_open, patch | ||
|
||
from mozilla_taskgraph.version import default_parser | ||
|
||
|
||
def test_default_parser(repo_root): | ||
version = "1.0.0" | ||
|
||
with patch("mozilla_taskgraph.version.open", mock_open(read_data=version)) as m: | ||
assert default_parser({}) == version | ||
m.assert_called_with(str(repo_root / "version.txt")) |