Skip to content

feat(e2e): add optional minimum version to test #1363

feat(e2e): add optional minimum version to test

feat(e2e): add optional minimum version to test #1363

Workflow file for this run

name: sim
on:
push:
branches:
- develop
- release/*
pull_request:
types: [opened, synchronize, labeled]
schedule:
- cron: "0 6 * * *"
workflow_dispatch:
inputs:
make-targets:
description: 'Comma separated list of make targets to run (e.g., test-sim-nondeterminism, test-sim-fullappsimulation)'
required: true
default: 'test-sim-nondeterminism'
concurrency:
group: simulation-${{ github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
changed-files:
runs-on: ubuntu-latest
outputs:
x_changed: ${{ steps.x-changes.outputs.any_changed }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get changed files in x directory
id: x-changes
uses: tj-actions/changed-files@v45
with:
files: x/**
matrix-conditionals:
needs: changed-files
runs-on: ubuntu-22.04
outputs:
SIM_TEST_NOND: ${{ steps.matrix-conditionals.outputs.SIM_TEST_NOND }}
SIM_TEST_FULL: ${{ steps.matrix-conditionals.outputs.SIM_TEST_FULL }}
SIM_TEST_IMPORT_EXPORT: ${{ steps.matrix-conditionals.outputs.SIM_TEST_IMPORT_EXPORT }}
SIM_TEST_AFTER_IMPORT: ${{ steps.matrix-conditionals.outputs.SIM_TEST_AFTER_IMPORT }}
steps:
- id: matrix-conditionals
uses: actions/github-script@v7
with:
script: |
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);
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;
}
console.log('makeTargets: ', makeTargets);
core.setOutput('SIM_TEST_NOND', makeTargets.includes('test-sim-nondeterminism'));
core.setOutput('SIM_TEST_FULL', makeTargets.includes('test-sim-fullappsimulation'));
core.setOutput('SIM_TEST_IMPORT_EXPORT', makeTargets.includes('test-sim-import-export'));
core.setOutput('SIM_TEST_AFTER_IMPORT', makeTargets.includes('test-sim-after-import'));
simulation-tests:
needs:
- matrix-conditionals
strategy:
fail-fast: false
matrix:
include:
- make-target: "test-sim-nondeterminism"
run: ${{ needs.matrix-conditionals.outputs.SIM_TEST_NOND == 'true' }}
- make-target: "test-sim-fullappsimulation"
run: ${{ needs.matrix-conditionals.outputs.SIM_TEST_FULL == 'true' }}
- make-target: "test-sim-import-export"
run: ${{ needs.matrix-conditionals.outputs.SIM_TEST_IMPORT_EXPORT == 'true' }}
- make-target: "test-sim-after-import"
run: ${{ needs.matrix-conditionals.outputs.SIM_TEST_AFTER_IMPORT == 'true' }}
name: ${{ matrix.make-target }}
uses: ./.github/workflows/reusable-sim.yml
with:
make-target: ${{ matrix.make-target }}
run: ${{ matrix.run }}
sim-ok:
runs-on: ubuntu-22.04
needs:
- simulation-tests
if: ${{ !cancelled() }}
steps:
- name: Aggregate Results
run: |
result="${{ needs.simulation-tests.result }}"
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi