Skip to content

Commit 683119c

Browse files
committed
Refactor test workflows
Test workflows are refactored to split out those triggered by WEC-Sim commits (wec-sim-***-tests) from those triggered by modifications to the applications (changed-tests).
1 parent 82e9830 commit 683119c

8 files changed

Lines changed: 138 additions & 205 deletions
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Reusable all application test workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
client_payload:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
targets:
12+
name: Collect folders
13+
runs-on: ubuntu-latest
14+
outputs:
15+
base_ref: ${{ fromJSON(inputs.client_payload).branch }}
16+
folder: ${{ steps.output.outputs.folder }}
17+
head_ref: ${{ fromJSON(inputs.client_payload).branch }}
18+
include: ${{ steps.output.outputs.include }}
19+
repository: ${{ github.repository }}
20+
steps:
21+
- run: echo "Triggered by WEC-Sim commit ${{ fromJSON(inputs.client_payload).sha }}"
22+
- name: Check out repository
23+
uses: actions/checkout@v4
24+
with:
25+
lfs: true
26+
ref: ${{ fromJSON(inputs.client_payload).branch }}
27+
- name: Install MATLAB
28+
uses: matlab-actions/setup-matlab@v2
29+
with:
30+
release: R2024a
31+
- name: Get test target folder
32+
uses: matlab-actions/run-command@v2
33+
with:
34+
command: getTestTargets
35+
- name: Save output
36+
id: output
37+
run: |
38+
echo "folder=$(cat folder.json | jq -cr)" >> $GITHUB_OUTPUT
39+
echo "include=$(cat include.json | jq -cr)" >> $GITHUB_OUTPUT
40+
run_tests:
41+
name: Run tests
42+
needs: targets
43+
uses: ./.github/workflows/run-tests-reusable.yml
44+
with:
45+
base_ref: ${{ needs.targets.outputs.base_ref }}
46+
folder: ${{ needs.targets.outputs.folder }}
47+
head_ref: ${{ needs.targets.outputs.head_ref }}
48+
include: ${{ needs.targets.outputs.include }}
49+
repository: ${{ needs.targets.outputs.repository }}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Test changed applications
2+
on:
3+
push:
4+
branches:
5+
- dev
6+
- main
7+
pull_request:
8+
branches:
9+
- dev
10+
- main
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
jobs:
15+
targets:
16+
name: Collect folders
17+
runs-on: ubuntu-latest
18+
outputs:
19+
base_ref: ${{ github.base_ref || github.ref_name }}
20+
head_ref: ${{ github.head_ref || github.ref_name }}
21+
folder: ${{ steps.output.outputs.folder }}
22+
include: ${{ steps.output.outputs.include }}
23+
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
24+
if: github.event_name != 'repository_dispatch'
25+
steps:
26+
- name: Check out repository
27+
uses: actions/checkout@v4
28+
with:
29+
lfs: true
30+
fetch-depth: 0
31+
- name: Generate git diff
32+
uses: GrantBirki/git-diff-action@v2
33+
id: git-diff-action
34+
with:
35+
json_diff_file_output: diff.json
36+
file_output_only: "true"
37+
- name: Install MATLAB
38+
uses: matlab-actions/setup-matlab@v2
39+
with:
40+
release: R2024a
41+
- name: Get test target folder
42+
uses: matlab-actions/run-command@v2
43+
with:
44+
command: getTestTargets("diff.json")
45+
- name: Save output
46+
id: output
47+
run: |
48+
echo "folder=$(cat folder.json | jq -cr)" >> $GITHUB_OUTPUT
49+
echo "include=$(cat include.json | jq -cr)" >> $GITHUB_OUTPUT
50+
run_tests:
51+
name: Run tests
52+
needs: targets
53+
uses: ./.github/workflows/run-tests-reusable.yml
54+
with:
55+
base_ref: ${{ needs.targets.outputs.base_ref }}
56+
head_ref: ${{ needs.targets.outputs.head_ref }}
57+
folder: ${{ needs.targets.outputs.folder }}
58+
include: ${{ needs.targets.outputs.include }}
59+
repository: ${{ needs.targets.outputs.repository }}
60+
if: ${{ needs.targets.outputs.folder != '[]'}}

.github/workflows/process-events-dev.yml

Lines changed: 0 additions & 101 deletions
This file was deleted.

.github/workflows/process-events-main.yml

Lines changed: 0 additions & 101 deletions
This file was deleted.

.github/workflows/run-tests-reusable.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
type: string
2121

2222
jobs:
23-
run_tests:
23+
main:
2424
runs-on: ${{ matrix.os }}
2525
strategy:
2626
fail-fast: false
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Test WEC-Sim dev branch
2+
on:
3+
repository_dispatch:
4+
types:
5+
- wecsim-dev
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
8+
cancel-in-progress: true
9+
jobs:
10+
main:
11+
uses: ./.github/workflows/all-tests-reusable.yml
12+
with:
13+
client_payload: ${{ toJSON(github.event.client_payload) }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Test WEC-Sim main branch
2+
on:
3+
repository_dispatch:
4+
types:
5+
- wecsim-main
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
8+
cancel-in-progress: true
9+
jobs:
10+
main:
11+
uses: ./.github/workflows/all-tests-reusable.yml
12+
with:
13+
client_payload: ${{ toJSON(github.event.client_payload) }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# WEC-Sim_Applications
22

3-
[![main build status](https://github.com/WEC-Sim/WEC-Sim_Applications/actions/workflows/process-events-main.yml/badge.svg)](https://github.com/WEC-Sim/WEC-Sim_Applications/actions/workflows/process-events-main.yml)
4-
[![dev build status](https://github.com/WEC-Sim/WEC-Sim_Applications/actions/workflows/process-events-dev.yml/badge.svg)](https://github.com/WEC-Sim/WEC-Sim_Applications/actions/workflows/process-events-dev.yml)
3+
[![main build status](https://github.com/WEC-Sim/WEC-Sim_Applications/actions/workflows/wec-sim-main-tests.yml/badge.svg)](https://github.com/WEC-Sim/WEC-Sim_Applications/actions/workflows/wec-sim-main-tests.yml)
4+
[![dev build status](https://github.com/WEC-Sim/WEC-Sim_Applications/actions/workflows/wec-sim-dev-tests.yml/badge.svg)](https://github.com/WEC-Sim/WEC-Sim_Applications/actions/workflows/wec-sim-dev-tests.yml)
55

66
This repository contains applications of the WEC-Sim code, including tutorials by the WEC-Sim team as well as user-shared examples.
77

0 commit comments

Comments
 (0)