Skip to content

Commit

Permalink
Refactor test workflows
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
H0R5E committed Sep 16, 2024
1 parent 687bc8c commit 2ec947a
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 205 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/all-tests-reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Reusable all application test workflow

on:
workflow_call:
inputs:
client_payload:
required: true
type: string

jobs:
targets:
name: Collect folders
runs-on: ubuntu-latest
outputs:
base_ref: ${{ fromJSON(inputs.client_payload).branch }}
folder: ${{ steps.output.outputs.folder }}
head_ref: ${{ fromJSON(inputs.client_payload).branch }}
include: ${{ steps.output.outputs.include }}
repository: ${{ github.repository }}
steps:
- run: echo "Triggered by WEC-Sim commit ${{ fromJSON(inputs.client_payload).sha }}"
- name: Check out repository
uses: actions/checkout@v4
with:
lfs: true
ref: ${{ fromJSON(inputs.client_payload).branch }}
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v2
with:
release: R2024a
- name: Get test target folder
uses: matlab-actions/run-command@v2
with:
command: getTestTargets
- name: Save output
id: output
run: |
echo "folder=$(cat folder.json | jq -cr)" >> $GITHUB_OUTPUT
echo "include=$(cat include.json | jq -cr)" >> $GITHUB_OUTPUT
run_tests:
name: Run tests
needs: targets
uses: ./.github/workflows/run-tests-reusable.yml
with:
base_ref: ${{ needs.targets.outputs.base_ref }}
folder: ${{ needs.targets.outputs.folder }}
head_ref: ${{ needs.targets.outputs.head_ref }}
include: ${{ needs.targets.outputs.include }}
repository: ${{ needs.targets.outputs.repository }}
60 changes: 60 additions & 0 deletions .github/workflows/changed-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Test changed applications
on:
push:
branches:
- dev
- main
pull_request:
branches:
- dev
- main
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
targets:
name: Collect folders
runs-on: ubuntu-latest
outputs:
base_ref: ${{ github.base_ref || github.ref_name }}
head_ref: ${{ github.head_ref || github.ref_name }}
folder: ${{ steps.output.outputs.folder }}
include: ${{ steps.output.outputs.include }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
if: github.event_name != 'repository_dispatch'
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: Generate git diff
uses: GrantBirki/git-diff-action@v2
id: git-diff-action
with:
json_diff_file_output: diff.json
file_output_only: "true"
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v2
with:
release: R2024a
- name: Get test target folder
uses: matlab-actions/run-command@v2
with:
command: getTestTargets("diff.json")
- name: Save output
id: output
run: |
echo "folder=$(cat folder.json | jq -cr)" >> $GITHUB_OUTPUT
echo "include=$(cat include.json | jq -cr)" >> $GITHUB_OUTPUT
run_tests:
name: Run tests
needs: targets
uses: ./.github/workflows/run-tests-reusable.yml
with:
base_ref: ${{ needs.targets.outputs.base_ref }}
head_ref: ${{ needs.targets.outputs.head_ref }}
folder: ${{ needs.targets.outputs.folder }}
include: ${{ needs.targets.outputs.include }}
repository: ${{ needs.targets.outputs.repository }}
if: ${{ needs.targets.outputs.folder != '[]'}}
101 changes: 0 additions & 101 deletions .github/workflows/process-events-dev.yml

This file was deleted.

101 changes: 0 additions & 101 deletions .github/workflows/process-events-main.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/run-tests-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
type: string

jobs:
run_tests:
main:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/wec-sim-dev-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Test WEC-Sim dev branch
on:
repository_dispatch:
types:
- wecsim-dev
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
main:
uses: ./.github/workflows/all-tests-reusable.yml
with:
client_payload: ${{ toJSON(github.event.client_payload) }}
13 changes: 13 additions & 0 deletions .github/workflows/wec-sim-main-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Test WEC-Sim main branch
on:
repository_dispatch:
types:
- wecsim-main
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
main:
uses: ./.github/workflows/all-tests-reusable.yml
with:
client_payload: ${{ toJSON(github.event.client_payload) }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# WEC-Sim_Applications

[![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)
[![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)
[![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)
[![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)

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

Expand Down

0 comments on commit 2ec947a

Please sign in to comment.