Skip to content

Commit

Permalink
Merge pull request #20 from sobomax/pr_split_jobs
Browse files Browse the repository at this point in the history
Split tests into individual jobs.
  • Loading branch information
razvancrainea authored Nov 24, 2023
2 parents 605758a + 29197bb commit 40a9dc6
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 15 deletions.
27 changes: 23 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,27 @@ on:
pull_request:

jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:

test:
- name: Prepare SIPssert
uses: OpenSIPS/SIPssert/actions/Prepare_SIPssert@main
with:
sipssert-repo: ${{ github.repository }}
tests-repo: OpenSIPS/sipssert-opensips-tests

runs-on: ubuntu-latest
- name: Read and parse YAML file
id: set-matrix
uses: ./sipssert/actions/Set_Matrix

test:
needs: setup-matrix
strategy:
matrix: ${{fromJson(needs.setup-matrix.outputs.matrix)}}
runs-on: ${{ matrix.os }}

steps:

Expand All @@ -19,5 +36,7 @@ jobs:
sipssert-repo: ${{ github.repository }}
tests-repo: OpenSIPS/sipssert-opensips-tests

- name: Run All Tests
uses: OpenSIPS/SIPssert/actions/Run_All_Tests@main
- name: Run Test
uses: ./sipssert/actions/Run_Test
with:
scenario: ${{ matrix.scenario }}
21 changes: 21 additions & 0 deletions actions/Publish_Logs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 'Publish Logs'
description: 'Collect and upload logs for all scenarious'
inputs:
log_name:
description: "Name of logs after upload"
default: sipssert-logs
required: true
runs:
using: 'composite'
steps:
- name: Resolve logs path
run: |
cd tests
echo "LOGS_PATH=$(readlink -f logs/latest)" >> $GITHUB_ENV
shell: bash

- name: Publish logs
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.log_name }}
path: ${{ env.LOGS_PATH }}
12 changes: 1 addition & 11 deletions actions/Run_All_Tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ runs:
sh -x ./run-all.sh
shell: bash

- name: Resolve logs path
if: always()
run: |
cd tests
echo "LOGS_PATH=$(readlink -f logs/latest)" >> $GITHUB_ENV
shell: bash

- name: Publish logs
uses: actions/upload-artifact@v3
if: always()
with:
name: sipssert-logs
path: ${{ env.LOGS_PATH }}
uses: ./sipssert/actions/Publish_Logs
20 changes: 20 additions & 0 deletions actions/Run_Test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Run Test'
description: 'Runs specific test, resolves the logs path, and uploads the logs'
inputs:
scenario:
description: "Name of scenario to run"
required: true
runs:
using: 'composite'
steps:
- name: Run All Tests
run: |
cd tests
SETS=${{ inputs.scenario }} sh -x ./run-all.sh
shell: bash

- name: Publish logs
if: always()
uses: ./sipssert/actions/Publish_Logs
with:
log_name: sipssert-${{ inputs.scenario }}-logs
17 changes: 17 additions & 0 deletions actions/Set_Matrix/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Read Job Matrix'
description: 'Read list of scenarious to run and output matrix.'
inputs: {}
outputs:
matrix:
description: "The job matrix"
value: ${{ steps.set-matrix.outputs.matrix }}
runs:
using: 'composite'
steps:
- name: Read and parse YAML file
id: set-matrix
run: |
echo "Reading YAML file to create matrix"
MATRIX=$(python3 sipssert/actions/read_matrix.py tests/matrix.yml)
echo "matrix=${MATRIX}" >> $GITHUB_OUTPUT
shell: bash
3 changes: 3 additions & 0 deletions actions/read_matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import sys, json, yaml

print(json.dumps(yaml.safe_load(open(sys.argv[1]))))

0 comments on commit 40a9dc6

Please sign in to comment.