Skip to content

Commit

Permalink
Merge pull request #17 from FiniteStateInc/cp/upgrade-sdk
Browse files Browse the repository at this point in the history
Upgrade Finitestate Python SDK pip package
  • Loading branch information
cpfarherFinitestate authored May 2, 2024
2 parents c0bbb09 + 6074d93 commit 45a676b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion DEV_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ hash.
steps:
- name: Finite State Binary Scan
id: binary_scan
uses: FiniteStateInc/[email protected].0
uses: FiniteStateInc/[email protected].1
with:
finite-state-client-id: ${{ secrets.CLIENT_ID }}
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ and Created By User. If you need to change these, you can provide IDs for them.
>
> To avoid issues, consider using a GitHub-hosted runner image like
> 'ubuntu-latest' or 'microsoft-latest' that comes pre-installed with both
> Node.js and Python.
> Node.js and Python required versions.
<!-- action-docs-description -->

Expand Down Expand Up @@ -113,7 +113,7 @@ optional fields.
**Example:**
```yaml
uses: FiniteStateInc/[email protected].0
uses: FiniteStateInc/[email protected].1
with:
finite-state-client-id: ${{ secrets.CLIENT_ID }}
finite-state-secret: ${{ secrets.CLIENT_SECRET }}
Expand Down Expand Up @@ -212,7 +212,7 @@ jobs:
path: # The path to the scan results generated in the previous step
- name: SBOM analysis
uses: FiniteStateInc/[email protected].0
uses: FiniteStateInc/[email protected].1
id: third_party_upload
with:
finite-state-client-id: ${{ secrets.CLIENT_ID }}
Expand Down
2 changes: 1 addition & 1 deletion dist/python/requirements.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions dist/python/upload_test_results.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/python/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8.18
2 changes: 1 addition & 1 deletion src/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
finite-state-sdk==0.1.2
finite-state-sdk==0.1.9
24 changes: 12 additions & 12 deletions src/python/upload_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,24 @@ def create_and_upload_test_results():
INPUT_PRODUCT_ID = os.environ.get("INPUT_PRODUCT_ID")
INPUT_ARTIFACT_DESCRIPTION = os.environ.get("INPUT_ARTIFACT_DESCRIPTION")
except KeyError:
msg = f"Required inputs not available. Please, check required inputs definition"
msg = "Required inputs not available. Please, check required inputs definition"
error = msg
logger.error(msg)
raise

error = None
asset_version = ""
logger.info(f"Starting - Create new asset version and upload test results")
logger.info("Starting - Create new asset version and upload test results")

if not INPUT_GITHUB_TOKEN and INPUT_AUTOMATIC_COMMENT:
msg = f"Caught an exception. The [Github Token] input is required when [Automatic comment] is enabled."
msg = "Caught an exception. The [Github Token] input is required when [Automatic comment] is enabled."
error = msg
logger.error(msg)
logger.debug(e)

if error == None:
if error is None:
# Authenticate
try:
logger.info(f"Starting - Authentication")
logger.info("Starting - Authentication")
token = finite_state_sdk.get_auth_token(
INPUT_FINITE_STATE_CLIENT_ID, INPUT_FINITE_STATE_SECRET
)
Expand All @@ -84,7 +83,7 @@ def create_and_upload_test_results():
logger.debug(e)

# Create new asset version an upload test results:
if error == None:
if error is None:
try:
response = (
finite_state_sdk.create_new_asset_version_and_upload_test_results(
Expand All @@ -98,6 +97,7 @@ def create_and_upload_test_results():
product_id=INPUT_PRODUCT_ID,
artifact_description=INPUT_ARTIFACT_DESCRIPTION,
test_type=INPUT_TEST_TYPE,
upload_method=finite_state_sdk.UploadMethod.GITHUB_INTEGRATION,
)
)
set_multiline_output("response", response)
Expand All @@ -120,23 +120,23 @@ def create_and_upload_test_results():
logger.error(msg)
logger.debug(e)

if error == None:
logger.info(f"File uploaded - Extracting asset version")
if error is None:
logger.info("File uploaded - Extracting asset version")
set_multiline_output("response", json.dumps(response, indent=4))
asset_version_url = "https://platform.finitestate.io/artifacts/{asset_id}/versions/{version}".format(
asset_id=INPUT_ASSET_ID, version=asset_version
)
set_output("asset-version-url", asset_version_url)
logger.info(f"Asset version URL: {asset_version_url}")
if not INPUT_AUTOMATIC_COMMENT:
logger.info(f"Automatic comment disabled")
logger.info("Automatic comment disabled")
else:
if is_pull_request():
logger.info(f"Automatic comment enabled. Generating comment...")
logger.info("Automatic comment enabled. Generating comment...")
generate_comment(INPUT_GITHUB_TOKEN, asset_version_url, logger)
else:
logger.info(
f"Automatic comment enabled. But this isn't a pull request. Skip generating comment..."
"Automatic comment enabled. But this isn't a pull request. Skip generating comment..."
)
else:
set_multiline_output("error", error)
Expand Down

0 comments on commit 45a676b

Please sign in to comment.