Skip to content

Commit

Permalink
Merge pull request #378 from FoamyGuy/test_build_before_push
Browse files Browse the repository at this point in the history
Test bundle builds job before push
  • Loading branch information
tannewt authored Oct 8, 2024
2 parents 2b4f6f7 + 0b7eccc commit 6705480
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
31 changes: 30 additions & 1 deletion adabot/circuitpython_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
If updates are found the bundle is updated, updates are pushed to the
remote, and a new release is made.
"""

import contextlib
from datetime import date
from io import StringIO
import json
Expand All @@ -16,6 +16,7 @@
import subprocess

import sh
from circuitpython_build_tools.scripts.build_bundles import build_bundles
from sh.contrib import git

from adabot import github_requests as gh_reqs
Expand Down Expand Up @@ -419,6 +420,26 @@ def add_contributors(master_list, additions):
master_list[contributor] += additions[contributor]


def test_bundle_build(bundle_dir):
"""
Attempts to build the bundle at the given location.
Raises system exit status 0 if successful.
Raises system exit status >0 if failed to build.
"""
with contextlib.chdir(bundle_dir):
build_bundles(
[
"--filename_prefix",
"test-build-bundle",
"--library_location",
"libraries",
"--library_depth",
"2",
],
standalone_mode=False,
)


# pylint: disable=too-many-locals,too-many-branches,too-many-statements
def new_release(bundle, bundle_path):
"""Creates a new release for `bundle`."""
Expand Down Expand Up @@ -561,12 +582,20 @@ def new_release(bundle, bundle_path):
try:
fetch_bundle(cp_bundle, bundle_dir)
updates, release_required = update_bundle(bundle_dir)

# test bundle build and stop if it does not succeed
try:
test_bundle_build(bundle_dir)
except SystemExit as e:
if e.code != 0:
raise RuntimeError("Test Build of Bundle Failed") from e
if release_required:
commit_updates(bundle_dir, updates)
push_updates(bundle_dir)
new_release(cp_bundle, bundle_dir)
except RuntimeError as e:
print("Failed to update and release:", cp_bundle)
print(e)
raise e
finally:
contributor_cache_fn.write_text(json.dumps(CONTRIBUTOR_CACHE))
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: MIT

black==24.3.0
circuitpython-build-tools
packaging==22.0
pylint==3.2.6
pytest
Expand Down

0 comments on commit 6705480

Please sign in to comment.