Skip to content

Commit

Permalink
fix: updates GitHub Actions runner image and restart policy (#255)
Browse files Browse the repository at this point in the history
* chore: updates ubuntu runner version

The newest version of the runner has podman v4
which is needed for compatibilty with the version of
docker

* fix: updates e2e-test container restart policy

Restarting trestlebot containers cfreate unexpected behavior
because of the shared volume. For this use case, it should be never.

Signed-off-by: Jennifer Power <[email protected]>

* fix: updates GitHub Actions runner flavor for CI E2E tests

Signed-off-by: Jennifer Power <[email protected]>

* fix: removes logging from test fixture

The logging statement was for debugging and should be removed
to ensure resource cleanup errors are properly logged

Signed-off-by: Jennifer Power <[email protected]>

---------

Signed-off-by: Jennifer Power <[email protected]>
  • Loading branch information
jpower432 committed Jul 12, 2024
1 parent c4a85c5 commit 7fd64e0
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
run: make test

e2e-test:
runs-on: ubuntu-latest
runs-on: 'ubuntu-24.04'
permissions:
contents: read
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ concurrency:

jobs:
publish-image:
runs-on: 'ubuntu-latest'
runs-on: 'ubuntu-24.04'
permissions:
contents: read
# kics-scan ignore-line
Expand Down
23 changes: 9 additions & 14 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"""Common test fixtures."""

import argparse
import logging
import pathlib
from tempfile import TemporaryDirectory
import tempfile
from typing import Any, Dict, Generator, Tuple, TypeVar

import pytest
Expand Down Expand Up @@ -36,23 +35,19 @@
@pytest.fixture(scope="function")
def tmp_repo() -> YieldFixture[Tuple[str, Repo]]:
"""Create a temporary git repository with an initialized trestle workspace root"""
with TemporaryDirectory(prefix=_TEST_PREFIX) as tmpdir:
tmp_path = pathlib.Path(tmpdir)
repo: Repo = repo_setup(tmp_path)
remote_url = "http://localhost:8080/test.git"
repo.create_remote("origin", url=remote_url)
yield tmpdir, repo

try:
clean(tmpdir, repo)
except Exception as e:
logging.error(f"Failed to clean up temporary git repository: {e}")
tmpdir = tempfile.mkdtemp(prefix=_TEST_PREFIX)
tmp_path = pathlib.Path(tmpdir)
repo: Repo = repo_setup(tmp_path)
remote_url = "http://localhost:8080/test.git"
repo.create_remote("origin", url=remote_url)
yield tmpdir, repo
clean(tmpdir, repo)


@pytest.fixture(scope="function")
def tmp_trestle_dir() -> YieldFixture[str]:
"""Create an initialized temporary trestle directory"""
with TemporaryDirectory(prefix=_TEST_PREFIX) as tmpdir:
with tempfile.TemporaryDirectory(prefix=_TEST_PREFIX) as tmpdir:
tmp_path = pathlib.Path(tmpdir)
try:
args = argparse.Namespace(
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/e2e_testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ def build_test_command(
E2ETestRunner.TRESTLEBOT_TEST_POD_NAME,
"--entrypoint",
f"trestlebot-{command_name}",
"--rm",
"--restart",
"never",
]

# Add mounts
Expand Down
5 changes: 2 additions & 3 deletions tests/trestlebot/tasks/test_sync_upstream_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ def test_sync_upstream_invalid_git(
) -> None:
"""Test sync upstreams task with invalid git source"""
tmp_repo_path, _ = tmp_repo
# Now remove the git repo
shutil.rmtree(tmp_repo_path)
sync = SyncUpstreamsTask(tmp_trestle_dir, [f"{tmp_repo_path}@main"])
new_path = f"{tmp_repo_path}1"
sync = SyncUpstreamsTask(tmp_trestle_dir, [f"{new_path}@main"])
with pytest.raises(
TaskException, match="Git error occurred while fetching content from .*"
):
Expand Down
4 changes: 1 addition & 3 deletions tests/trestlebot/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from git.repo import Repo
from responses import GET, POST, RequestsMock

from tests.testutils import JSON_TEST_DATA_PATH, clean
from tests.testutils import JSON_TEST_DATA_PATH
from trestlebot.github import GitHub, GitHubActionsResultsReporter, set_output
from trestlebot.provider import GitProviderException
from trestlebot.reporter import BotResults
Expand Down Expand Up @@ -50,8 +50,6 @@ def test_parse_repository_integration(tmp_repo: Tuple[str, Repo]) -> None:
assert owner == "test"
assert repo_name == "repo"

clean(repo_path, repo)


def test_parse_repository_with_incorrect_name() -> None:
"""Test an invalid url input"""
Expand Down
3 changes: 0 additions & 3 deletions tests/trestlebot/test_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from gitlab.exceptions import GitlabAuthenticationError, GitlabCreateError
from responses import GET, POST, RequestsMock

from tests.testutils import clean
from trestlebot.gitlab import GitLab, GitLabCIResultsReporter
from trestlebot.provider import GitProviderException
from trestlebot.reporter import BotResults
Expand Down Expand Up @@ -86,8 +85,6 @@ def test_parse_repository_integration(tmp_repo: Tuple[str, Repo]) -> None:
assert owner == "test"
assert repo_name == "repo"

clean(repo_path, repo)


def test_parse_repository_with_incorrect_name() -> None:
"""Test an invalid url input"""
Expand Down

0 comments on commit 7fd64e0

Please sign in to comment.