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

add check for documentation building #699

Merged
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
56 changes: 56 additions & 0 deletions .github/workflows/check-documentation-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Documentation Check

on:
push:
branches:
- "main"
paths:
- "docs/**"
- ".readthedocs.yaml"
- "setup.py"
- "VERSION"
- ".github/workflows/check-documentation-build.yml"

pull_request:
branches:
- "main"
- "stable"
paths:
- "docs/**"
- ".readthedocs.yaml"
- "setup.py"
- "VERSION"
- ".github/workflows/check-documentation-build.yml"
LeonLuttenberger marked this conversation as resolved.
Show resolved Hide resolved

# Allows this workflow to be run manually from the Actions tab
workflow_dispatch:

jobs:
build:
name: Build Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install yq
run: sudo snap install yq
- name: Get Python Version
id: get-version
run: |
python_version=$(cat .readthedocs.yaml | yq ".build.tools.python")
echo python-version=$python_version >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '${{ steps.get-version.outputs.python-version }}'
- name: Update pip
run: pip install --upgrade pip
- name: Install Requirements for building docs
run: pip install -r docs/requirements-docs.txt
- name: Install SeedFarmer
run: pip install -e .
- name: Sphinx Build
working-directory: ./docs/
run: make html
3 changes: 2 additions & 1 deletion seedfarmer/mgmt/archive_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from seedfarmer.services.session_manager import SessionManager

_logger: logging.Logger = logging.getLogger(__name__)
parent_dir = os.path.join(config.OPS_ROOT, "seedfarmer.archive")


def _download_archive(archive_url: str, secret_name: Optional[str]) -> Response:
Expand Down Expand Up @@ -84,6 +83,7 @@ def _extract_archive(archive_name: str, extracted_dir_path: str) -> str:


def _process_archive(archive_name: str, response: Response, extracted_dir: str) -> str:
parent_dir = os.path.join(config.OPS_ROOT, "seedfarmer.archive")
pathlib.Path(parent_dir).mkdir(parents=True, exist_ok=True)

with open(archive_name, "wb") as archive_file:
Expand All @@ -105,6 +105,7 @@ def _process_archive(archive_name: str, response: Response, extracted_dir: str)


def _get_release_with_link(archive_url: str, secret_name: Optional[str]) -> Tuple[str, str]:
parent_dir = os.path.join(config.OPS_ROOT, "seedfarmer.archive")
parsed_url = urlparse(archive_url)

if not parsed_url.scheme == "https":
Expand Down
19 changes: 8 additions & 11 deletions test/unit-test/test_mgmt_archive_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from moto import mock_aws

import seedfarmer.mgmt.archive_support as archive
from seedfarmer import config
from seedfarmer.errors.seedfarmer_errors import InvalidConfigurationError
from seedfarmer.services._service_utils import boto3_client
from seedfarmer.services.session_manager import SessionManager
Expand Down Expand Up @@ -71,6 +72,13 @@ def session_manager(sts_client):
)


@pytest.fixture(scope="function", autouse=True)
def parent_dir_prepare():
parent_dir = os.path.join(config.OPS_ROOT, "seedfarmer.archive")
if os.path.exists(parent_dir):
shutil.rmtree(parent_dir)


example_archive_files = [
("modules/test-module/modulestack.yaml", io.BytesIO(b"111")),
("modules/test-module/pyproject.toml", io.BytesIO(b"222")),
Expand Down Expand Up @@ -111,7 +119,6 @@ def archive_file_data(
@pytest.mark.mgmt
@pytest.mark.mgmt_archive_support
def test_fetch_module_repo_dns_path():
shutil.rmtree(archive.parent_dir) if os.path.exists(archive.parent_dir) else None
archive_path_test = (
"archive::https://github.com/awslabs/idf-modules/archive/refs/tags/v1.6.0.tar.gz?module=modules/dummy/blank"
)
Expand All @@ -124,7 +131,6 @@ def test_fetch_module_repo_dns_path():
@pytest.mark.mgmt
@pytest.mark.mgmt_archive_support
def test_fetch_module_repo_dns_path_zip():
shutil.rmtree(archive.parent_dir) if os.path.exists(archive.parent_dir) else None
archive_path_test = (
"archive::https://github.com/awslabs/idf-modules/archive/refs/tags/v1.6.0.zip?module=modules/dummy/blank"
)
Expand All @@ -138,7 +144,6 @@ def test_fetch_module_repo_dns_path_zip():
def test_fetch_module_repo_dns_path_missing_https():
from seedfarmer.errors import InvalidConfigurationError

shutil.rmtree(archive.parent_dir) if os.path.exists(archive.parent_dir) else None
archive_path_test = (
"archive::http://github.com/awslabs/idf-modules/archive/refs/tags/v1.6.0.tar.gz?module=modules/dummy/blank"
)
Expand All @@ -151,7 +156,6 @@ def test_fetch_module_repo_dns_path_missing_https():
def test_fetch_module_repo_dns_path_missing_module():
from seedfarmer.errors import InvalidConfigurationError

shutil.rmtree(archive.parent_dir) if os.path.exists(archive.parent_dir) else None
archive_path_test = "archive::https://github.com/awslabs/idf-modules/archive/refs/tags/v1.6.0.tar.gz"
with pytest.raises(InvalidConfigurationError):
archive.fetch_archived_module(release_path=archive_path_test)
Expand All @@ -162,7 +166,6 @@ def test_fetch_module_repo_dns_path_missing_module():
def test_fetch_module_repo_dns_path_missing_archive():
from seedfarmer.errors import InvalidConfigurationError

shutil.rmtree(archive.parent_dir) if os.path.exists(archive.parent_dir) else None
archive_path_test = (
"archive::http://github.com/awslabs/idf-modules/archive/refs/tags/v1.6.1.tar.gz?module=modules/dummy/blank"
)
Expand All @@ -178,8 +181,6 @@ def test_fetch_module_repo_dns_path_missing_archive():
def test_fetch_module_repo_from_s3(
session_manager: None, archive_file_data: Tuple[bytes, str], s3_bucket_http_url: str
) -> None:
shutil.rmtree(archive.parent_dir) if os.path.exists(archive.parent_dir) else None

archive_bytes, archive_extension = archive_file_data

response_mock = MagicMock()
Expand Down Expand Up @@ -215,8 +216,6 @@ def test_fetch_module_repo_from_s3(
def test_fetch_module_repo_from_s3_with_error(
session_manager: None, archive_file_data: Tuple[bytes, str], s3_bucket_http_url: str
) -> None:
shutil.rmtree(archive.parent_dir) if os.path.exists(archive.parent_dir) else None

_, archive_extension = archive_file_data

response_mock = MagicMock()
Expand All @@ -239,8 +238,6 @@ def test_fetch_module_repo_from_s3_with_error(
def test_fetch_module_repo_from_https_with_secret(
session_manager: None, archive_file_data: Tuple[bytes, str], secretsmanager_client: boto3.client
) -> None:
shutil.rmtree(archive.parent_dir) if os.path.exists(archive.parent_dir) else None

secret_name = "testing-archive-credentials-modules"
username = "test-user"
password = "test-password"
Expand Down
Loading