Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: updates GitHub Actions runner image and restart policy #255

Merged
merged 4 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpower432 should this use a logger instance vs logging?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. I think the logging statement should be removed here. It was left in for temporary debugging for an issue that this change resolves.

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