|
| 1 | +name: Run MATLAB tests (dev) |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - dev |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - dev |
| 9 | + repository_dispatch: |
| 10 | + types: |
| 11 | + - wecsim-dev |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 14 | + cancel-in-progress: true |
| 15 | +jobs: |
| 16 | + dispatch_event: |
| 17 | + name: Process dispatch event |
| 18 | + runs-on: ubuntu-latest |
| 19 | + outputs: |
| 20 | + base_ref: ${{ github.event.client_payload.branch }} |
| 21 | + folder: ${{ steps.output.outputs.folder }} |
| 22 | + head_ref: ${{ github.event.client_payload.branch }} |
| 23 | + include: ${{ steps.output.outputs.include }} |
| 24 | + repository: ${{ github.repository }} |
| 25 | + if: github.event_name == 'repository_dispatch' |
| 26 | + steps: |
| 27 | + - run: echo "Triggered by WEC-Sim commit ${{ github.event.client_payload.sha }}" |
| 28 | + - name: Check out repository |
| 29 | + uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + lfs: true |
| 32 | + ref: ${{ github.event.client_payload.branch }} |
| 33 | + - name: Install MATLAB |
| 34 | + uses: matlab-actions/setup-matlab@v2 |
| 35 | + with: |
| 36 | + release: R2024a |
| 37 | + - name: Get test target folder |
| 38 | + uses: matlab-actions/run-command@v2 |
| 39 | + with: |
| 40 | + command: getTestTargets |
| 41 | + - name: Save output |
| 42 | + id: output |
| 43 | + run: | |
| 44 | + echo "folder=$(cat folder.json | jq -cr)" >> $GITHUB_OUTPUT |
| 45 | + echo "include=$(cat include.json | jq -cr)" >> $GITHUB_OUTPUT |
| 46 | + other_event: |
| 47 | + name: Process other events |
| 48 | + runs-on: ubuntu-latest |
| 49 | + outputs: |
| 50 | + base_ref: ${{ github.base_ref || github.ref_name }} |
| 51 | + head_ref: ${{ github.head_ref || github.ref_name }} |
| 52 | + folder: ${{ steps.output.outputs.folder }} |
| 53 | + include: ${{ steps.output.outputs.include }} |
| 54 | + repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} |
| 55 | + if: github.event_name != 'repository_dispatch' |
| 56 | + steps: |
| 57 | + - name: Check out repository |
| 58 | + uses: actions/checkout@v4 |
| 59 | + with: |
| 60 | + lfs: true |
| 61 | + fetch-depth: 0 |
| 62 | + - name: Generate git diff |
| 63 | + uses: GrantBirki/git-diff-action@v2 |
| 64 | + id: git-diff-action |
| 65 | + with: |
| 66 | + json_diff_file_output: diff.json |
| 67 | + file_output_only: "true" |
| 68 | + - name: Install MATLAB |
| 69 | + uses: matlab-actions/setup-matlab@v2 |
| 70 | + with: |
| 71 | + release: R2024a |
| 72 | + - name: Get test target folder |
| 73 | + uses: matlab-actions/run-command@v2 |
| 74 | + with: |
| 75 | + command: getTestTargets("diff.json") |
| 76 | + - name: Save output |
| 77 | + id: output |
| 78 | + run: | |
| 79 | + echo "folder=$(cat folder.json | jq -cr)" >> $GITHUB_OUTPUT |
| 80 | + echo "include=$(cat include.json | jq -cr)" >> $GITHUB_OUTPUT |
| 81 | + run_dispatch_event_tests: |
| 82 | + name: Run tests |
| 83 | + needs: dispatch_event |
| 84 | + uses: ./.github/workflows/run-tests-reusable.yml |
| 85 | + with: |
| 86 | + base_ref: ${{ needs.dispatch_event.outputs.base_ref }} |
| 87 | + folder: ${{ needs.dispatch_event.outputs.folder }} |
| 88 | + head_ref: ${{ needs.dispatch_event.outputs.head_ref }} |
| 89 | + include: ${{ needs.dispatch_event.outputs.include }} |
| 90 | + repository: ${{ needs.dispatch_event.outputs.repository }} |
| 91 | + run_other_event_tests: |
| 92 | + name: Run tests |
| 93 | + needs: other_event |
| 94 | + uses: ./.github/workflows/run-tests-reusable.yml |
| 95 | + with: |
| 96 | + base_ref: ${{ needs.other_event.outputs.base_ref }} |
| 97 | + head_ref: ${{ needs.other_event.outputs.head_ref }} |
| 98 | + folder: ${{ needs.other_event.outputs.folder }} |
| 99 | + include: ${{ needs.other_event.outputs.include }} |
| 100 | + repository: ${{ needs.other_event.outputs.repository }} |
| 101 | + if: ${{ needs.other_event.outputs.folder != '[]'}} |
0 commit comments