Skip to content

Commit

Permalink
Merge pull request #7 from jpower432/feat/add-assembly-task
Browse files Browse the repository at this point in the history
Feat/add assembly task
  • Loading branch information
Alex Flom authored Jun 26, 2023
2 parents 3a088de + 93f4fc7 commit d01e72b
Show file tree
Hide file tree
Showing 28 changed files with 8,145 additions and 99 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,7 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
#.idea/

# Local VSCode
.vscode/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# trestle-bot

trestle-bot assists users in leveraging [Compliance-Trestle](https://github.com/IBM/compliance-trestle) in automated workflows of for [OSCAL](https://github.com/usnistgov/OSCAL) formatted compliance content management.
trestle-bot assists users in leveraging [Compliance-Trestle](https://github.com/IBM/compliance-trestle) in automated workflows or [OSCAL](https://github.com/usnistgov/OSCAL) formatted compliance content management.

In addition to trestle-bot, this repo contains the trestle-bot GitHub Action that can optionally be used to host the tresle-bot service within GitHub Actions.

Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ author: "Red Hat Product Security"
description: "A workflow automation manager for OSCAL formatted compliance content"

inputs:
markdown_path:
description: Path relative to the repository path where the Trestle markdown files are located. See project README.md for more information.
required: true
assemble_model:
description: OSCAL Model type to assemble. Values can be catalog, profile, compdef, or ssp.
required: true
ssp_index_path:
description: Path relative to the repository path where the ssp index is located. See project README.md for information about the ssp index.
required: false
default: "ssp-index.txt"
commit_message:
description: Commit message
required: false
Expand Down
1,460 changes: 1,425 additions & 35 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ trestle-bot = "trestlebot.cli:run"
[tool.poetry.dependencies]
python = '^3.8.1'
gitpython = "^3.1.31"
compliance-trestle = "^2.1.1"

[tool.poetry.group.dev.dependencies]
flake8 = "^6.0.0"
Expand Down
76 changes: 76 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/python

# Copyright 2023 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

"""Test fixtures"""

import argparse
import os
import pathlib
from tempfile import TemporaryDirectory
from typing import Generator, Tuple, TypeVar

import pytest
from git.repo import Repo
from trestle.common.err import TrestleError
from trestle.core.commands.init import InitCmd


T = TypeVar("T")

YieldFixture = Generator[T, None, None]

_TEST_CONTENTS = """
test file
"""

_TEST_FILENAME = "test.txt"


@pytest.fixture
def tmp_repo() -> YieldFixture[Tuple[str, Repo]]:
"""Create a temporary git repository"""
with TemporaryDirectory(prefix="trestlebot_tests") as tmpdir:
with open(os.path.join(tmpdir, _TEST_FILENAME), "x", encoding="utf8") as file:
file.write(_TEST_CONTENTS)
repo = Repo.init(tmpdir)
with repo.config_writer() as config:
config.set_value("user", "email", "[email protected]")
config.set_value("user", "name", "Test User")
repo.git.add(all=True)
repo.index.commit("Initial commit")
yield tmpdir, repo


@pytest.fixture
def tmp_trestle_dir() -> YieldFixture[str]:
"""Create an initialized temporary trestle directory"""
with TemporaryDirectory(prefix="trestlebot_tests") as tmpdir:
tmp_path = pathlib.Path(tmpdir)
try:
args = argparse.Namespace(
verbose=0,
trestle_root=tmp_path,
full=True,
local=False,
govdocs=False,
)
init = InitCmd()
init._run(args)
except Exception as e:
raise TrestleError(
f"Initialization failed for temporary trestle directory: {e}."
)
yield tmpdir
Loading

0 comments on commit d01e72b

Please sign in to comment.