Skip to content

Commit

Permalink
fix and clean
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbant committed Aug 21, 2024
1 parent 8d6a636 commit cdd09e0
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,28 @@ jobs:
# only run on pushes that are not also part of PR
runs-on: ubuntu-latest
outputs:
run_tests: ${{ steps.check.outputs.run_tests }}
run_tests: github.event_name == 'push' || ${{ steps.check.outputs.run_tests }}
steps:
- name: Check if tests should run
id: check
if: github.event_name == 'push'
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
if (context.eventName === 'pull_request') {
core.setOutput('run_tests', 'true');
} else if (context.eventName === 'push') {
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;
core.setOutput('run_tests', shouldRun ? 'true' : 'false');
}
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;
core.setOutput('run_tests', shouldRun ? 'true' : 'false');
tests:
needs: should_run
runs-on: ${{ matrix.os }}
if: needs.should_run.outputs.run_tests == 'true'
if: github.event_name == 'pull_request' || needs.should_run.outputs.run_tests == 'true'
strategy:
fail-fast: false
matrix:
Expand Down

0 comments on commit cdd09e0

Please sign in to comment.