Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make package comparison in CI optional for the sake of forks #1887

Merged
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
5 changes: 4 additions & 1 deletion .github/workflows/Bonsai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
- name: Create build matrix
id: create-matrix
run: python .github/workflows/create-build-matrix.py
env:
enable_package_comparison: ${{vars.ENABLE_PACKAGE_COMPARISON}}
will_publish_packages: ${{github.event.inputs.will_publish_packages}}

# =====================================================================================================================================================================
# Build, test, and package
Expand Down Expand Up @@ -184,7 +187,7 @@ jobs:
runs-on: ubuntu-latest
# We technically only need the dummy build jobs, but GitHub Actions lacks the ability to depend on specific jobs in a matrix
needs: build-and-test
if: github.event_name != 'pull_request'
if: github.event_name != 'pull_request' && vars.ENABLE_PACKAGE_COMPARISON == 'true'
steps:
# ----------------------------------------------------------------------- Checkout
- name: Checkout
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/create-build-matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,19 @@ def add_dummy(name: str, artifacts_suffix: str):
dummy['artifacts-suffix'] = artifacts_suffix
return dummy

if os.getenv('GITHUB_EVENT_NAME') != 'pull_request':
enable_package_comparison = os.getenv('enable_package_comparison') == 'true'
github_event_name = os.getenv('GITHUB_EVENT_NAME')
glopesdev marked this conversation as resolved.
Show resolved Hide resolved

if github_event_name != 'pull_request' and enable_package_comparison:
add_dummy('Previous Dummy', '-dummy-prev')['checkout-ref'] = 'refs/tags/latest'
add_dummy('Next Dummy', '-dummy-next')

# Fail early if we won't be able to do package comparison and the run must publish packages to make logical sense
# Package comparison requires the `latest` tag to exist, but it will usually either be missing or invalid for forks so we require it to be opt-in
if not enable_package_comparison:
if github_event_name == 'release' or (github_event_name == 'workflow_dispatch' and os.getenv('will_publish_packages') == 'true'):
gha.print_error('Release aborted. We would not be able to determine which packages need to be released as this repository is not configured for package comparison.')

# Output
matrix_json = json.dumps({ "include": matrix }, indent=2)
print(matrix_json)
Expand Down