Skip to content
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
9 changes: 7 additions & 2 deletions .github/workflows/publish-action-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ jobs:
GH_TOKEN: ${{ secrets.ACTION_REPO_TOKEN }}
ACTION_REPOSITORY: ${{ inputs.action_repository != '' && inputs.action_repository || vars.ACTION_REPOSITORY != '' && vars.ACTION_REPOSITORY || 'hashgraph-online/hol-codex-plugin-scanner-action' }}
RELEASE_TAG: ${{ github.event.release.tag_name || inputs.release_tag }}
CREATE_REPOSITORY: ${{ github.event_name == 'workflow_dispatch' && inputs.create_repository || 'true' }}
CREATE_REPOSITORY: ${{ github.event_name == 'workflow_dispatch' && (inputs.create_repository && 'true' || 'false') || 'true' }}
SOURCE_REF: ${{ github.event.release.tag_name || inputs.release_tag || github.ref_name }}
SOURCE_REPOSITORY: ${{ github.repository }}
SOURCE_SERVER_URL: ${{ github.server_url }}
steps:
Expand Down Expand Up @@ -121,7 +122,11 @@ jobs:
run: |
VERSION="${{ steps.version.outputs.version }}"
TAG="${{ steps.version.outputs.tag }}"
NOTES="Published automatically from ${SOURCE_SERVER_URL}/${SOURCE_REPOSITORY}/releases/tag/${TAG}"
if [ -n "${RELEASE_TAG}" ]; then
NOTES="Published automatically from ${SOURCE_SERVER_URL}/${SOURCE_REPOSITORY}/releases/tag/${TAG}"
else
NOTES="Published automatically from ${SOURCE_SERVER_URL}/${SOURCE_REPOSITORY}/tree/${SOURCE_REF}"
fi

if gh release view "${TAG}" --repo "${ACTION_REPOSITORY}" >/dev/null 2>&1; then
gh release edit "${TAG}" \
Expand Down
3 changes: 3 additions & 0 deletions tests/test_action_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ def test_publish_action_repo_workflow_syncs_action_repository() -> None:
assert "hashgraph-online/hol-codex-plugin-scanner-action" in workflow_text
assert "Validate publication credentials" in workflow_text
assert 'if: secrets.ACTION_REPO_TOKEN != \'\'' not in workflow_text
assert "inputs.create_repository && 'true' || 'false'" in workflow_text
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This assertion, which checks for an exact string, is a bit brittle. It could fail if there are minor, semantically-irrelevant formatting changes in the workflow file (e.g., extra spaces). Consider using a regular expression to make the check more robust against such changes. For example:

import re
# ...
assert re.search(r"inputs\.create_repository\s*&&\s*'true'\s*\|\|\s*'false'", workflow_text)

assert "SOURCE_REF" in workflow_text
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This assertion is redundant because the assertion on line 45 already verifies the presence and usage of SOURCE_REF. Relying on the more specific assertion on line 45 is sufficient and makes the test cleaner and easier to maintain.

assert 'gh repo create "${ACTION_REPOSITORY}"' in workflow_text
assert 'cp "${GITHUB_WORKSPACE}/action/action.yml" action.yml' in workflow_text
assert 'git push origin refs/tags/v1 --force' in workflow_text
assert 'gh release create "${TAG}"' in workflow_text
assert 'Published automatically from ${SOURCE_SERVER_URL}/${SOURCE_REPOSITORY}/tree/${SOURCE_REF}' in workflow_text


def test_action_bundle_docs_live_in_action_readme() -> None:
Expand Down
Loading