-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from jpower432/feat/add-outputs
Feat/add outputs
- Loading branch information
Showing
7 changed files
with
133 additions
and
50 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,27 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
output=$(python3.8 -m trestlebot \ | ||
--markdown-path="${INPUT_MARKDOWN_PATH}" \ | ||
--assemble-model="${INPUT_ASSEMBLE_MODEL}" \ | ||
--ssp-index-path="${INPUT_SSP_INDEX_PATH}" \ | ||
--commit-message="${INPUT_COMMIT_MESSAGE}" \ | ||
--branch="${INPUT_BRANCH}" \ | ||
--patterns="${INPUT_FILE_PATTERN}" \ | ||
--committer-name="${INPUT_COMMIT_USER_NAME}" \ | ||
--committer-email="${INPUT_COMMIT_USER_EMAIL}" \ | ||
--author-name="${INPUT_COMMIT_AUTHOR_NAME}" \ | ||
--author-email="${INPUT_COMMIT_AUTHOR_EMAIL}" \ | ||
--working-dir="${INPUT_WORKING_DIR}" 2>&1 | tee log.txt) | ||
|
||
cat log.txt | ||
|
||
commit=$(echo "$output" | grep "Commit Hash:" | sed 's/.*: //') | ||
|
||
if [ -n "$commit" ]; then | ||
echo "changes=true" >> "$GITHUB_OUTPUT" | ||
echo "commit=$commit" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "changes=false" >> "$GITHUB_OUTPUT" | ||
fi |
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 |
---|---|---|
|
@@ -60,12 +60,13 @@ def test_local_commit(tmp_repo: Tuple[str, Repo]) -> None: | |
repo.index.add(test_file_path) | ||
|
||
# Commit the test file | ||
bot._local_commit( | ||
commit_sha = bot._local_commit( | ||
repo, | ||
commit_user="Test User", | ||
commit_email="[email protected]", | ||
commit_message="Test commit message", | ||
) | ||
assert commit_sha != "" | ||
|
||
# Verify that the commit is made | ||
commit = next(repo.iter_commits()) | ||
|
@@ -91,13 +92,15 @@ def test_local_commit_with_committer(tmp_repo: Tuple[str, Repo]) -> None: | |
repo.index.add(test_file_path) | ||
|
||
# Commit the test file | ||
bot._local_commit( | ||
commit_sha = bot._local_commit( | ||
repo, | ||
commit_user="Test Commit User", | ||
commit_email="[email protected]", | ||
commit_message="Test commit message", | ||
) | ||
|
||
assert commit_sha != "" | ||
|
||
# Verify that the commit is made | ||
commit = next(repo.iter_commits()) | ||
assert commit.message.strip() == "Test commit message" | ||
|
@@ -122,14 +125,15 @@ def test_local_commit_with_author(tmp_repo: Tuple[str, Repo]) -> None: | |
repo.index.add(test_file_path) | ||
|
||
# Commit the test file | ||
bot._local_commit( | ||
commit_sha = bot._local_commit( | ||
repo, | ||
commit_user="Test User", | ||
commit_email="[email protected]", | ||
commit_message="Test commit message", | ||
author_name="The Author", | ||
author_email="[email protected]", | ||
) | ||
assert commit_sha != "" | ||
|
||
# Verify that the commit is made | ||
commit = next(repo.iter_commits()) | ||
|
@@ -153,7 +157,7 @@ def test_run_dry_run(tmp_repo: Tuple[str, Repo]) -> None: | |
f.write("Test content") | ||
|
||
# Test running the bot | ||
bot.run( | ||
commit_sha = bot.run( | ||
working_dir=repo_path, | ||
branch="main", | ||
commit_name="Test User", | ||
|
@@ -164,6 +168,7 @@ def test_run_dry_run(tmp_repo: Tuple[str, Repo]) -> None: | |
patterns=["*.txt"], | ||
dry_run=True, | ||
) | ||
assert commit_sha != "" | ||
|
||
# Verify that the commit is made | ||
commit = next(repo.iter_commits()) | ||
|
@@ -175,3 +180,24 @@ def test_run_dry_run(tmp_repo: Tuple[str, Repo]) -> None: | |
assert os.path.basename(test_file_path) in commit.stats.files | ||
|
||
clean(repo_path, repo) | ||
|
||
|
||
def test_empty_commit(tmp_repo: Tuple[str, Repo]) -> None: | ||
"""Test running bot with no file updates""" | ||
repo_path, repo = tmp_repo | ||
|
||
# Test running the bot | ||
commit_sha = bot.run( | ||
working_dir=repo_path, | ||
branch="main", | ||
commit_name="Test User", | ||
commit_email="[email protected]", | ||
commit_message="Test commit message", | ||
author_name="The Author", | ||
author_email="[email protected]", | ||
patterns=["*.txt"], | ||
dry_run=True, | ||
) | ||
assert commit_sha == "" | ||
|
||
clean(repo_path, repo) |
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