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

[pull] master from CobayaSampler:master #4

Merged
merged 1 commit into from
Feb 20, 2025
Merged
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
27 changes: 18 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ env:

jobs:
should_run:
# only run on pushes that are not also part of PR
# only run on pushes that are not also part of PR, EXCEPT for master branch pushes (always run on master)
runs-on: ubuntu-latest
outputs:
run_tests: github.event_name == 'push' || ${{ steps.check.outputs.run_tests }}
run_tests: ${{ steps.check.outputs.run_tests }}
steps:
- name: Check if tests should run
id: check
Expand All @@ -22,13 +22,22 @@ jobs:
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
head: `${context.repo.owner}:${context.ref.replace('refs/heads/', '')}`,
state: 'open'
});
const shouldRun = prs.length === 0;
const ref = context.ref;
const isMasterPush = ref === 'refs/heads/master';
let shouldRun = false;

if (isMasterPush) {
shouldRun = true; // Always run on master pushes
} else {
// For other branches, check for open PRs
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
head: `${context.repo.owner}:${context.ref.replace('refs/heads/', '')}`,
state: 'open'
});
shouldRun = prs.length === 0; // Run if no open PRs for this branch
}
core.setOutput('run_tests', shouldRun ? 'true' : 'false');

tests:
Expand Down
Loading