-
Notifications
You must be signed in to change notification settings - Fork 0
Add runtime environment detection utilities #4
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
0f793b9
Apply new templates
AndrewSazonov bd2c6fd
Reapply templates
AndrewSazonov f3522b2
Make setup docs admonitions collapsible
AndrewSazonov 7615f18
Update docs; remove app docs link
AndrewSazonov 562f109
Fix docs formatting for Pixi setup
AndrewSazonov 3d79426
Bump copier template; set release PR name
AndrewSazonov a8cbc89
Add branch protection rulesets and tasks
AndrewSazonov 06225b2
Add issue label checks; rename PR labels workflow
AndrewSazonov f9bf2e1
Bump template; enforce 1 review on develop
AndrewSazonov a70ee72
Add GitHub Pages config and repo setup tasks
AndrewSazonov 85f9fd3
Enable GitHub Discussions in repo config
AndrewSazonov e8ef8a0
Update backmerge workflow and labels
AndrewSazonov 5682ff3
Move GH config files; modularize backmerge issue
AndrewSazonov 5bc7b37
Add runtime environment detection utilities
AndrewSazonov e3659af
Add tests for environment module
AndrewSazonov f20cd8b
Refactor environment tests for robustness
AndrewSazonov 321aeae
Enable Ruff linting; adjust docstrings and tests
AndrewSazonov 941d720
Add environment module docs to API reference
AndrewSazonov d570d0a
Remove GSL dependency
AndrewSazonov cf040f7
Update release label; fix backmerge script path
AndrewSazonov 8631de1
Narrow exception handling in IPython checks
AndrewSazonov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,6 @@ | ||
| { | ||
| "source": { | ||
| "branch": "gh-pages", | ||
| "path": "/" | ||
| } | ||
| } |
This file contains hidden or 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,37 @@ | ||
| { | ||
| "name": "develop branch", | ||
| "target": "branch", | ||
| "enforcement": "active", | ||
| "conditions": { | ||
| "ref_name": { | ||
| "include": ["refs/heads/develop"], | ||
| "exclude": [] | ||
| } | ||
| }, | ||
| "bypass_actors": [ | ||
| { | ||
| "actor_id": 2476259, | ||
| "actor_type": "Integration", | ||
| "bypass_mode": "always" | ||
| } | ||
| ], | ||
| "rules": [ | ||
| { | ||
| "type": "non_fast_forward" | ||
| }, | ||
| { | ||
| "type": "deletion" | ||
| }, | ||
| { | ||
| "type": "pull_request", | ||
| "parameters": { | ||
| "allowed_merge_methods": ["squash"], | ||
| "dismiss_stale_reviews_on_push": false, | ||
| "require_code_owner_review": false, | ||
| "require_last_push_approval": false, | ||
| "required_approving_review_count": 1, | ||
| "required_review_thread_resolution": false | ||
| } | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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,19 @@ | ||
| { | ||
| "name": "gh-pages branch", | ||
| "target": "branch", | ||
| "enforcement": "active", | ||
| "conditions": { | ||
| "ref_name": { | ||
| "include": ["refs/heads/gh-pages"], | ||
| "exclude": [] | ||
| } | ||
| }, | ||
| "rules": [ | ||
| { | ||
| "type": "non_fast_forward" | ||
| }, | ||
| { | ||
| "type": "deletion" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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,30 @@ | ||
| { | ||
| "name": "master branch", | ||
| "target": "branch", | ||
| "enforcement": "active", | ||
| "conditions": { | ||
| "ref_name": { | ||
| "include": ["~DEFAULT_BRANCH"], | ||
| "exclude": [] | ||
| } | ||
| }, | ||
| "rules": [ | ||
| { | ||
| "type": "non_fast_forward" | ||
| }, | ||
| { | ||
| "type": "deletion" | ||
| }, | ||
| { | ||
| "type": "pull_request", | ||
| "parameters": { | ||
| "allowed_merge_methods": ["merge"], | ||
| "dismiss_stale_reviews_on_push": false, | ||
| "require_code_owner_review": false, | ||
| "require_last_push_approval": false, | ||
| "required_approving_review_count": 0, | ||
| "required_review_thread_resolution": false | ||
| } | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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,69 @@ | ||
| module.exports = async ({ github, context, core }) => { | ||
| // Repo context | ||
| const owner = context.repo.owner | ||
| const repo = context.repo.repo | ||
|
|
||
| // Link to the exact workflow run that detected the conflict | ||
| const runUrl = `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}` | ||
|
|
||
| // We use a *stable title* so we can find/reuse the same "conflict tracker" issue | ||
| // instead of creating a new issue on every failed run. | ||
| const title = 'Backmerge conflict: master → develop' | ||
|
|
||
| // Comment/issue body includes the run URL so maintainers can jump straight to logs. | ||
| const body = [ | ||
| 'Automatic backmerge failed due to merge conflicts.', | ||
| '', | ||
| `Workflow run: ${runUrl}`, | ||
| '', | ||
| 'Manual resolution required.', | ||
| ].join('\n') | ||
|
|
||
| // Label applied to the tracker issue (assumed to already exist in the repo). | ||
| const label = '[bot] backmerge' | ||
|
|
||
| // Search issues by title across *open and closed* issues. | ||
| // Why: if the conflict was resolved previously and the issue was closed, | ||
| // we prefer to reopen it and append a new comment instead of creating duplicates. | ||
| const q = `repo:${owner}/${repo} is:issue in:title "${title}"` | ||
| const search = await github.rest.search.issuesAndPullRequests({ | ||
| q, | ||
| per_page: 10, | ||
| }) | ||
|
|
||
| // Pick the first exact-title match (search can return partial matches). | ||
| const existing = search.data.items.find((i) => i.title === title) | ||
|
|
||
| if (existing) { | ||
| // If a tracker issue exists, reuse it: | ||
| // - reopen it if needed | ||
| // - add a comment with the new run URL | ||
| if (existing.state === 'closed') { | ||
| await github.rest.issues.update({ | ||
| owner, | ||
| repo, | ||
| issue_number: existing.number, | ||
| state: 'open', | ||
| }) | ||
| } | ||
|
|
||
| await github.rest.issues.createComment({ | ||
| owner, | ||
| repo, | ||
| issue_number: existing.number, | ||
| body, | ||
| }) | ||
|
|
||
| core.notice(`Conflict issue updated: #${existing.number}`) | ||
| return | ||
| } | ||
|
|
||
| // No tracker issue exists yet -> create the first one. | ||
| await github.rest.issues.create({ | ||
| owner, | ||
| repo, | ||
| title, | ||
| body, | ||
| labels: [label], | ||
| }) | ||
| } |
This file contains hidden or 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 hidden or 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,39 @@ | ||
| # Verifies if an issue has at least one of the `[scope]` and one of the | ||
| # `[priority]` labels. If not, the bot adds labels with a warning emoji | ||
| # to indicate that those labels need to be added. | ||
|
|
||
| name: Issue labels check | ||
|
|
||
| on: | ||
| issues: | ||
| types: [opened, labeled, unlabeled] | ||
|
|
||
| jobs: | ||
| check-labels: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Setup easyscience[bot] | ||
| id: bot | ||
| uses: ./.github/actions/setup-easyscience-bot | ||
| with: | ||
| app-id: ${{ vars.EASYSCIENCE_APP_ID }} | ||
| private-key: ${{ secrets.EASYSCIENCE_APP_KEY }} | ||
|
|
||
| - name: Check for required [scope] label | ||
| uses: trstringer/require-label-prefix@v1 | ||
| with: | ||
| secret: ${{ steps.bot.outputs.token }} | ||
| prefix: '[scope]' | ||
| labelSeparator: ' ' | ||
| addLabel: true | ||
| defaultLabel: '[scope] ⚠️ label needed' | ||
|
|
||
| - name: Check for required [priority] label | ||
| uses: trstringer/require-label-prefix@v1 | ||
| with: | ||
| secret: ${{ steps.bot.outputs.token }} | ||
| prefix: '[priority]' | ||
| labelSeparator: ' ' | ||
| addLabel: true | ||
| defaultLabel: '[priority] ⚠️ label needed' |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is titled "Add runtime environment detection utilities", but it also introduces/changes multiple GitHub operational workflows and branch protection rulesets. Consider splitting the GitHub automation/ruleset changes into a separate PR so the environment-utility change can be reviewed and released independently.