Skip to content

Commit

Permalink
fix(ci): adjust sim conditional logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Jan 22, 2025
1 parent 815c8b8 commit 8b65aa9
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions .github/workflows/sim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,19 @@ jobs:
changed-files:
runs-on: ubuntu-latest
outputs:
modified_files: ${{ steps.changes.outputs.modified_files }}
x_changed: ${{ steps.x-changes.outputs.any_changed }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Get changed files in x directory
id: changes
run: |
echo "::set-output name=modified_files::$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '^x/' | xargs)"
id: x-changes
uses: tj-actions/changed-files@v45
with:
files: x/**

matrix-conditionals:
needs: changed-files
if: |
contains(github.event.pull_request.labels.*.name, 'SIM_TESTS') || needs.changed-files.outputs.modified_files
runs-on: ubuntu-22.04
outputs:
SIM_TEST_NOND: ${{ steps.matrix-conditionals.outputs.SIM_TEST_NOND }}
Expand All @@ -48,10 +47,27 @@ jobs:
uses: actions/github-script@v7
with:
script: |
const makeTargetsInput = context.payload.inputs ? context.payload.inputs['make-targets'] : null;
const defaultTargets = ['test-sim-nondeterminism', 'test-sim-fullappsimulation', 'test-sim-import-export', 'test-sim-after-import'];
let makeTargets = [];
if (context.eventName === 'pull_request') {
const changedFiles = ${{ needs.changed-files.outputs.x_changed }};
const pull_number = context.payload.pull_request.number;
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull_number,
});
const labels = pr.labels.map(label => label.name);
console.log(`labels for ${pull_number}:`, labels);
console.log(`changedFiles for ${pull_number}:`, changedFiles);
const makeTargets = makeTargetsInput ? makeTargetsInput.split(',') : defaultTargets;
if (changedFiles || labels.includes('SIM_TESTS')) {
makeTargets = defaultTargets;
}
} else {
const makeTargetsInput = context.payload.inputs ? context.payload.inputs['make-targets'] : null;
makeTargets = makeTargetsInput ? makeTargetsInput.split(',') : defaultTargets;
}
core.setOutput('SIM_TEST_NOND', makeTargets.includes('test-sim-nondeterminism'));
core.setOutput('SIM_TEST_FULL', makeTargets.includes('test-sim-fullappsimulation'));
Expand All @@ -61,8 +77,6 @@ jobs:
simulation-tests:
needs:
- matrix-conditionals
if: |
contains(github.event.pull_request.labels.*.name, 'SIM_TESTS') || needs.changed-files.outputs.modified_files
runs-on: ubuntu-22.04
strategy:
fail-fast: false
Expand Down Expand Up @@ -97,8 +111,6 @@ jobs:
sim-ok:
needs:
- simulation-tests
if: |
contains(github.event.pull_request.labels.*.name, 'SIM_TESTS') || needs.changed-files.outputs.modified_files
runs-on: ubuntu-22.04
steps:
- name: Aggregate Results
Expand Down

0 comments on commit 8b65aa9

Please sign in to comment.