Skip to content

Commit

Permalink
added possibility to unit test PR or branch
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasbisurgi authored and MariusWirtz committed Oct 23, 2024
1 parent fbbfe20 commit ccb2107
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions .github/workflows/unit_test_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ name: TM1Py Integration Tests
on:
workflow_dispatch:
inputs:
pr_number:
description: 'Pull request number to test'
code_reference:
description: 'PR number (e.g., #612) or branch name (e.g., master or bugfix_123 ) to test'
required: true
default: ''
environments:
description: 'JSON array of environments to test (e.g., ["tm1-11-onprem", "tm1-11-cloud"])'
required: true
Expand All @@ -19,11 +20,27 @@ jobs:
environment: ${{ fromJson(inputs.environments) }}
environment: ${{ matrix.environment }}
steps:
- name: Checkout PR code
- name: Determine ref and PR number
id: determine-ref
shell: bash
run: |
code_ref='${{ inputs.code_reference }}'
if [[ "$code_ref" == \#* ]]; then
# Remove the '#' character
pr_number="${code_ref#\#}"
echo "Detected PR number: $pr_number"
echo "ref=refs/pull/$pr_number/merge" >> $GITHUB_OUTPUT
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
else
echo "Detected branch name: $code_ref"
echo "ref=$code_ref" >> $GITHUB_OUTPUT
fi
- name: Checkout code
uses: actions/checkout@v3
with:
repository: ${{ github.repository }}
ref: refs/pull/${{ inputs.pr_number }}/merge
ref: ${{ steps.determine-ref.outputs.ref }}

- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -32,7 +49,8 @@ jobs:

- name: Install dependencies
run: |
pip install -e .[pandas,dev]
pip install -e .[pandas,dev]
- name: Retrieve TM1 Connection Details
run: echo "Retrieving TM1 connection details"
env:
Expand All @@ -57,13 +75,13 @@ jobs:
path: Tests/test-reports/

- name: Post comment to PR
if: always()
if: ${{ always() && steps.determine-ref.outputs.pr_number }}
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ inputs.pr_number }},
issue_number: ${{ steps.determine-ref.outputs.pr_number }},
body: 'Tests completed for environment: ${{ matrix.environment }}. Check artifacts for details.'
})

0 comments on commit ccb2107

Please sign in to comment.