generated from canonical/template-operator
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache charmcraft pack container, skip unstable tests except on schedu…
…le (#27)
- Loading branch information
1 parent
8607528
commit d4816a0
Showing
7 changed files
with
109 additions
and
83 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
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 @@ | ||
# Copyright 2023 Canonical Ltd. | ||
# See LICENSE file for licensing details. |
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,28 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright 2022 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
import json | ||
import os | ||
from pathlib import Path | ||
|
||
import pytest | ||
from pytest_operator.plugin import OpsTest | ||
|
||
|
||
@pytest.fixture | ||
def ops_test(ops_test: OpsTest) -> OpsTest: | ||
if os.environ.get("CI") == "true": | ||
# Running in GitHub Actions; skip build step | ||
# (GitHub Actions uses a separate, cached build step. See .github/workflows/ci.yaml) | ||
packed_charms = json.loads(os.environ["CI_PACKED_CHARMS"]) | ||
|
||
async def build_charm(charm_path, bases_index: int = None) -> Path: | ||
for charm in packed_charms: | ||
if Path(charm_path) == Path(charm["directory_path"]): | ||
if bases_index is None or bases_index == charm["bases_index"]: | ||
return charm["file_path"] | ||
raise ValueError(f"Unable to find .charm file for {bases_index=} at {charm_path=}") | ||
|
||
ops_test.build_charm = build_charm | ||
return ops_test |
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