Skip to content

Commit 50ebf55

Browse files
committed
Split process events workflow to allow sensible badges
Badges set to a particular branch don't capture the status of repository dispatch events.
1 parent 0cb997d commit 50ebf55

3 files changed

Lines changed: 106 additions & 7 deletions

File tree

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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 != '[]'}}
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
name: Run MATLAB tests
1+
name: Run MATLAB tests (main)
22
on:
3-
# Trigger the workflow on push or pull requests and on pushes to WEC-Sim
43
push:
54
branches:
6-
- dev
75
- main
86
pull_request:
97
branches:
10-
- dev
118
- main
129
repository_dispatch:
1310
types:
14-
- wecsim-dev
1511
- wecsim-main
1612
concurrency:
1713
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -83,6 +79,7 @@ jobs:
8379
echo "folder=$(cat folder.json | jq -cr)" >> $GITHUB_OUTPUT
8480
echo "include=$(cat include.json | jq -cr)" >> $GITHUB_OUTPUT
8581
run_dispatch_event_tests:
82+
name: Run tests
8683
needs: dispatch_event
8784
uses: ./.github/workflows/run-tests-reusable.yml
8885
with:
@@ -92,6 +89,7 @@ jobs:
9289
include: ${{ needs.dispatch_event.outputs.include }}
9390
repository: ${{ needs.dispatch_event.outputs.repository }}
9491
run_other_event_tests:
92+
name: Run tests
9593
needs: other_event
9694
uses: ./.github/workflows/run-tests-reusable.yml
9795
with:

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-
![GitHub Actions Workflow Status](<https://img.shields.io/github/actions/workflow/status/WEC-Sim/WEC-Sim_Applications/process-events.yml?branch=main&label=Run%20MATLAB%20tests%20(main)>)
4-
![GitHub Actions Workflow Status](<https://img.shields.io/github/actions/workflow/status/WEC-Sim/WEC-Sim_Applications/process-events.yml?branch=dev&label=Run%20MATLAB%20tests%20(dev)>)
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)
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)