Skip to content

Commit

Permalink
Merge pull request #97 from lsst-sqre/tickets/DM-32710
Browse files Browse the repository at this point in the history
DM-32710: Update main as default branch for editions (1.23.0 release)
  • Loading branch information
jonathansick authored Nov 29, 2021
2 parents e445607 + 248bd98 commit b9c8199
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 87 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Change log
##########

1.23.0 (2021-11-29)
===================

- Change "master" to "main" as the tracked branch for default editions when a product is created.
- Update the lsstdoc tracking mode so that it accepts either master or main as the name of a default branch to track if a semantic version is not available yet.

1.22.0 (2021-04-27)
===================

Expand Down
2 changes: 1 addition & 1 deletion keeper/api/products.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def new_product() -> Tuple[str, int, Dict[str, str]]:

# Create a default edition for the product
edition_data = {
"tracked_refs": ["master"],
"tracked_refs": ["main"],
"slug": "main",
"title": "Latest",
}
Expand Down
8 changes: 4 additions & 4 deletions keeper/editiontracking/lsstdocmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ def should_update(
# build is tracking `master`, then allow this rebuild.
# This is used in the period before a semantic version is
# available.
if candidate_build.git_refs[0] == "master":
if (
edition.build_id is None
or edition.build.git_refs[0] == "master"
if candidate_build.git_refs[0] in ("master", "main"):
if edition.build_id is None or edition.build.git_refs[0] in (
"main",
"master",
):
return True

Expand Down
2 changes: 1 addition & 1 deletion manifests/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ resources:

images:
- name: lsstsqre/ltd-keeper
newTag: 1.22.0
newTag: 1.23.0
10 changes: 5 additions & 5 deletions tests/test_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_builds(client: TestClient, mocker: Mock) -> None:
mocker.resetall()

e = {
"tracked_refs": ["master"],
"tracked_refs": ["main"],
"slug": "latest",
"title": "Latest",
"published_url": "pipelines.lsst.io",
Expand All @@ -66,7 +66,7 @@ def test_builds(client: TestClient, mocker: Mock) -> None:
b1 = {
"slug": "b1",
"github_requester": "jonathansick",
"git_refs": ["master"],
"git_refs": ["main"],
}
r = client.post("/products/pipelines/builds/", b1)
assert r.status == 201
Expand Down Expand Up @@ -166,7 +166,7 @@ def test_builds(client: TestClient, mocker: Mock) -> None:
# Add an auto-slugged build
mocker.resetall()

b2 = {"git_refs": ["master"]}
b2 = {"git_refs": ["main"]}
r = client.post("/products/pipelines/builds/", b2)

assert r.status == 201
Expand All @@ -183,7 +183,7 @@ def test_builds(client: TestClient, mocker: Mock) -> None:
# Add an auto-slugged build
mocker.resetall()

b3 = {"git_refs": ["master"]}
b3 = {"git_refs": ["main"]}
r = client.post("/products/pipelines/builds/", b3)

assert r.status == 201
Expand All @@ -208,7 +208,7 @@ def test_builds(client: TestClient, mocker: Mock) -> None:
# Add a build with a badly formatted git_refs
mocker.resetall()

b5 = {"slug": "another-bad-build", "git_refs": "master"}
b5 = {"slug": "another-bad-build", "git_refs": "main"}
with pytest.raises(ValidationError):
r = client.post("/products/pipelines/builds/", b5)

Expand Down
10 changes: 5 additions & 5 deletions tests/test_builds_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_builds_v2(client: TestClient, mocker: Mock) -> None:
mocker.resetall()

e = {
"tracked_refs": ["master"],
"tracked_refs": ["main"],
"slug": "latest",
"title": "Latest",
"published_url": "pipelines.lsst.io",
Expand All @@ -81,7 +81,7 @@ def test_builds_v2(client: TestClient, mocker: Mock) -> None:
b1 = {
"slug": "b1",
"github_requester": "jonathansick",
"git_refs": ["master"],
"git_refs": ["main"],
}
r = client.post(
"/products/pipelines/builds/", b1, headers={"Accept": v2_json_type}
Expand Down Expand Up @@ -189,7 +189,7 @@ def test_builds_v2(client: TestClient, mocker: Mock) -> None:
# Add an auto-slugged build
mocker.resetall()

b2 = {"git_refs": ["master"]}
b2 = {"git_refs": ["main"]}
r = client.post("/products/pipelines/builds/", b2)

assert r.status == 201
Expand All @@ -206,7 +206,7 @@ def test_builds_v2(client: TestClient, mocker: Mock) -> None:
# Add an auto-slugged build
mocker.resetall()

b3 = {"git_refs": ["master"]}
b3 = {"git_refs": ["main"]}
r = client.post(
"/products/pipelines/builds/", b3, headers={"Accept": v2_json_type}
)
Expand All @@ -233,7 +233,7 @@ def test_builds_v2(client: TestClient, mocker: Mock) -> None:
# Add a build with a badly formatted git_refs
mocker.resetall()

b5 = {"slug": "another-bad-build", "git_refs": "master"}
b5 = {"slug": "another-bad-build", "git_refs": "main"}
with pytest.raises(ValidationError):
r = client.post(
"/products/pipelines/builds/", b5, headers={"Accept": v2_json_type}
Expand Down
22 changes: 11 additions & 11 deletions tests/test_editions.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ def test_editions(client: TestClient, mocker: Mock) -> None:
assert e0["pending_rebuild"] is False

# ========================================================================
# Create a build of the 'master' branch
# Create a build of the 'main' branch
mocker.resetall()

r = client.post("/products/pipelines/builds/", {"git_refs": ["master"]})
r = client.post("/products/pipelines/builds/", {"git_refs": ["main"]})
b1_url = r.json["self_url"]
assert r.status == 201

# ========================================================================
# Confirm build of the 'master' branch
# Confirm build of the 'main' branch
mocker.resetall()

client.patch(b1_url, {"uploaded": True})
Expand All @@ -81,15 +81,15 @@ def test_editions(client: TestClient, mocker: Mock) -> None:
r = client.patch(e0_url, {"pending_rebuild": False})

# ========================================================================
# Create a second build of the 'master' branch
# Create a second build of the 'main' branch
mocker.resetall()

r = client.post("/products/pipelines/builds/", {"git_refs": ["master"]})
r = client.post("/products/pipelines/builds/", {"git_refs": ["main"]})
assert r.status == 201
b2_url = r.json["self_url"]

# ========================================================================
# Confirm second build of the 'master' branch
# Confirm second build of the 'main' branch
mocker.resetall()

client.patch(b2_url, {"uploaded": True})
Expand All @@ -109,11 +109,11 @@ def test_editions(client: TestClient, mocker: Mock) -> None:
r = client.patch(e0_url, {"pending_rebuild": False})

# ========================================================================
# Setup an edition also tracking master called 'latest'
# Setup an edition also tracking main called 'latest'
mocker.resetall()

e1 = {
"tracked_refs": ["master"],
"tracked_refs": ["main"],
"slug": "latest",
"title": "Latest",
"build_url": b1_url,
Expand Down Expand Up @@ -181,11 +181,11 @@ def test_editions(client: TestClient, mocker: Mock) -> None:
# Change the tracked_refs with PATCH
mocker.resetall()

r = client.patch(e1_url, {"tracked_refs": ["tickets/DM-9999", "master"]})
r = client.patch(e1_url, {"tracked_refs": ["tickets/DM-9999", "main"]})

assert r.status == 200
assert r.json["tracked_refs"][0] == "tickets/DM-9999"
assert r.json["tracked_refs"][1] == "master"
assert r.json["tracked_refs"][1] == "main"
assert r.json["pending_rebuild"] is False # no need to rebuild

mock_registry[
Expand Down Expand Up @@ -217,7 +217,7 @@ def test_editions(client: TestClient, mocker: Mock) -> None:
with pytest.raises(ValidationError):
r = client.post(
"/products/pipelines/editions/",
{"slug": "main", "tracked_refs": ["master"], "title": "Main"},
{"slug": "main", "tracked_refs": ["main"], "title": "Main"},
)


Expand Down
9 changes: 4 additions & 5 deletions tests/test_patch_edition_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_pach_lsst_doc_edition(client: TestClient, mocker: Mock) -> None:
1. Create a product with the default GIT_REF tracking mode for the
main edition.
2. Post a build on `master`; it is tracked.
2. Post a build on `main`; it is tracked.
3. Post a `v1.0` build; it is not tracked.
4. Patch the main edition to use the LSST_DOC tracking mode.
5. Post a `v1.1` build that is tracked.
Expand Down Expand Up @@ -53,7 +53,7 @@ def test_pach_lsst_doc_edition(client: TestClient, mocker: Mock) -> None:
mock_registry["keeper.api.products.launch_task_chain"].assert_called_once()

# ========================================================================
# Create a build on 'master'
# Create a build on 'main'
mocker.resetall()

# Get the URL for the default edition
Expand All @@ -63,20 +63,19 @@ def test_pach_lsst_doc_edition(client: TestClient, mocker: Mock) -> None:
b1_data = {
"slug": "b1",
"github_requester": "jonathansick",
"git_refs": ["master"],
"git_refs": ["main"],
}
r = client.post(product_url + "/builds/", b1_data)
b1_url = r.headers["Location"]

# ========================================================================
# Create a build on 'master'
# Confirm the build on 'main'
mocker.resetall()

r = client.patch(b1_url, {"uploaded": True})

# Test that the main edition updated.
r = client.get(e1_url)

assert r.json["build_url"] == b1_url

# Check pending_rebuild semaphore and manually reset it since the celery
Expand Down
2 changes: 1 addition & 1 deletion tests/test_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_products(client: TestClient, mocker: Mock) -> None:
r = client.get(default_ed_url)
assert r.json["slug"] == "main"
assert r.json["title"] == "Latest"
assert r.json["tracked_refs"] == ["master"]
assert r.json["tracked_refs"] == ["main"]
assert r.json["published_url"] == "https://pipelines.lsst.io"

# ========================================================================
Expand Down
8 changes: 4 additions & 4 deletions tests/test_track_eups_daily_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ def test_eups_daily_release_edition(client: TestClient, mocker: Mock) -> None:
assert r.json["pending_rebuild"] is False

# ========================================================================
# Create a build for the 'master' branch that is not tracked
# Create a build for the 'main' branch that is not tracked
b2_data = {
"slug": "b2",
"github_requester": "jonathansick",
"git_refs": ["master"],
"git_refs": ["main"],
}
r = client.post("/products/pipelines/builds/", b2_data)
b2_url = r.headers["Location"]
r = client.patch(b2_url, {"uploaded": True})

# Test that the main edition *did not* update because this build is
# neither for master not a semantic version.
# neither for main not a semantic version.
# with semantic versions
r = client.get(edition_url)
assert r.json["build_url"] == b1_url
Expand Down Expand Up @@ -114,7 +114,7 @@ def test_eups_daily_release_edition(client: TestClient, mocker: Mock) -> None:
r = client.patch(b4_url, {"uploaded": True})

# Test that the main edition *did not* update because this build is
# neither for master not a semantic version.
# neither for main not a semantic version.
# with semantic versions
r = client.get(edition_url)
assert r.json["build_url"] == b3_url
8 changes: 4 additions & 4 deletions tests/test_track_eups_major_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ def test_eups_major_release_edition(client: TestClient, mocker: Mock) -> None:
assert r.json["pending_rebuild"] is False

# ========================================================================
# Create a build for the 'master' branch that is not tracked
# Create a build for the 'main' branch that is not tracked
b2_data = {
"slug": "b2",
"github_requester": "jonathansick",
"git_refs": ["master"],
"git_refs": ["main"],
}
r = client.post("/products/pipelines/builds/", b2_data)
b2_url = r.headers["Location"]
r = client.patch(b2_url, {"uploaded": True})

# Test that the main edition *did not* update because this build is
# neither for master not a semantic version.
# neither for main not a semantic version.
# with semantic versions
r = client.get(edition_url)
assert r.json["build_url"] == b1_url
Expand Down Expand Up @@ -113,7 +113,7 @@ def test_eups_major_release_edition(client: TestClient, mocker: Mock) -> None:
r = client.patch(b4_url, {"uploaded": True})

# Test that the main edition *did not* update because this build is
# neither for master not a semantic version.
# neither for main not a semantic version.
# with semantic versions
r = client.get(edition_url)
assert r.json["build_url"] == b3_url
8 changes: 4 additions & 4 deletions tests/test_track_eups_weekly_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,18 @@ def test_eups_weekly_release_edition(client: TestClient, mocker: Mock) -> None:
assert r.json["pending_rebuild"] is False

# ========================================================================
# Create a build for the 'master' branch that is not tracked
# Create a build for the 'main' branch that is not tracked
b2_data = {
"slug": "b2",
"github_requester": "jonathansick",
"git_refs": ["master"],
"git_refs": ["main"],
}
r = client.post("/products/pipelines/builds/", b2_data)
b2_url = r.headers["Location"]
r = client.patch(b2_url, {"uploaded": True})

# Test that the main edition *did not* update because this build is
# neither for master not a semantic version.
# neither for main not a semantic version.
# with semantic versions
r = client.get(edition_url)
assert r.json["build_url"] == b1_url
Expand Down Expand Up @@ -146,7 +146,7 @@ def test_eups_weekly_release_edition(client: TestClient, mocker: Mock) -> None:
r = client.patch(b4_url, {"uploaded": True})

# Test that the main edition *did not* update because this build is
# neither for master nor a semantic version.
# neither for main nor a semantic version.
# with semantic versions
r = client.get(edition_url)
assert r.json["build_url"] == b3_url
Expand Down
Loading

0 comments on commit b9c8199

Please sign in to comment.