Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split tests into individual jobs. #20

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]))))
Loading