Repository: cubewise-code/tm1py (language: python)

Issue:
CI Pipeline through GH Actions
Adding automated testing through GitHub Actions. This is in response to #1145 


Discussion / hints:
Nice work @nicolasbisurgi 
This should improve the robustness of our releases and provide transparency when new contributions break existing features.
Especially running tests automated and in parallel against v11 and v12 should make our lifes easier.

@onefloid 
any thoughts on this one?



 

Fix patch:
diff --git a/setup.py b/setup.py
index 79a41336..8907c95d 100644
--- a/setup.py
+++ b/setup.py
@@ -45,11 +45,6 @@
     extras_require={
         "pandas": ["pandas"],
         "dev": [
-            "pytest",
-            "pytest-xdist"
-        ],
-        "unit_test": [
-            "pandas",
             "pytest",
             "pytest-xdist",
             "python-dateutil"


Test patch:
diff --git a/.github/workflows/unit_test_pipeline.yml b/.github/workflows/unit_test_pipeline.yml
index 6e7c9aeb..72404fc6 100644
--- a/.github/workflows/unit_test_pipeline.yml
+++ b/.github/workflows/unit_test_pipeline.yml
@@ -3,6 +3,10 @@ name: TM1Py Integration Tests
 on:
   workflow_dispatch:
     inputs:
+      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
@@ -13,11 +17,30 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        environment: ${{ fromJson(github.event.inputs.environments) }}
+        environment: ${{ fromJson(inputs.environments) }}
     environment: ${{ matrix.environment }}
     steps:
+      - 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: ${{ steps.determine-ref.outputs.ref }}
 
       - name: Set up Python
         uses: actions/setup-python@v4
@@ -26,10 +49,9 @@ jobs:
 
       - name: Install dependencies
         run: |
-          pip install -e .[unit_test]
+          pip install -e .[pandas,dev]
 
       - name: Retrieve TM1 Connection Details
-        id: get-connection
         run: echo "Retrieving TM1 connection details"
         env:
           TM1_CONNECTION: ${{ vars.TM1_CONNECTION }}
@@ -52,15 +74,14 @@ jobs:
           name: test-results-${{ matrix.environment }}
           path: Tests/test-reports/
 
-      # Optional: Post results to PR
       - name: Post comment to PR
-        if: always() && github.event_name == 'workflow_dispatch' && github.event.pull_request
+        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: context.payload.pull_request.number,
+              issue_number: ${{ steps.determine-ref.outputs.pr_number }},
               body: 'Tests completed for environment: ${{ matrix.environment }}. Check artifacts for details.'
             })
\ No newline at end of file