Explorar o código

Merge pull request #1307 from PrivateBin/experimental-8.4

Add upload test results job in CI
El RIDO %!s(int64=2) %!d(string=hai) anos
pai
achega
9239c0267f
Modificáronse 3 ficheiros con 74 adicións e 3 borrados
  1. 42 0
      .github/workflows/test-results.yml
  2. 30 2
      .github/workflows/tests.yml
  3. 2 1
      js/package.json

+ 42 - 0
.github/workflows/test-results.yml

@@ -0,0 +1,42 @@
+name: Test Results
+
+on:
+  workflow_run:
+    workflows: ["Tests"]
+    types:
+      - completed
+permissions: {}
+
+jobs:
+  test-results:
+    name: Test Results
+    runs-on: ubuntu-latest
+    if: github.event.workflow_run.conclusion != 'skipped'
+
+    permissions:
+      checks: write
+
+      # needed unless run with comment_mode: off
+      pull-requests: write
+
+      # required by download step to access artifacts API
+      actions: read
+
+    steps:
+       - name: Download and Extract Artifacts
+         uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d
+         with:
+          run_id: ${{ github.event.workflow_run.id }}
+          path: artifacts
+
+       - name: Publish Test Results
+         uses: EnricoMi/publish-unit-test-result-action@v2
+         with:
+          check_name: "Test Results (${{ github.event.workflow_run.event || github.event_name }})"
+          commit: ${{ github.event.workflow_run.head_sha }}
+          event_file: artifacts/Event File/event.json
+          event_name: ${{ github.event.workflow_run.event }}
+          files: |
+            artifacts/**/*.xml
+            artifacts/**/*.trx
+            artifacts/**/*.json

+ 30 - 2
.github/workflows/tests.yml

@@ -7,6 +7,9 @@ jobs:
 
 
   Composer:
   Composer:
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
+    # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#handling-failures
+    continue-on-error: ${{ matrix.experimental }}
+    
     steps:
     steps:
     - name: Checkout
     - name: Checkout
       uses: actions/checkout@v4
       uses: actions/checkout@v4
@@ -96,9 +99,16 @@ jobs:
 
 
     # testing
     # testing
     - name: Run unit tests
     - name: Run unit tests
-      run: ../vendor/bin/phpunit --no-coverage
+      run: ../vendor/bin/phpunit --no-coverage --log-junit results.xml
       working-directory: tst
       working-directory: tst
 
 
+    - name: Upload Test Results
+      if: always()
+      uses: actions/upload-artifact@v4
+      with:
+        name: Test Results (PHP ${{ matrix.php-versions }})
+        path: tst/results.xml
+
   Mocha:
   Mocha:
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
     steps:
     steps:
@@ -121,5 +131,23 @@ jobs:
       working-directory: js
       working-directory: js
 
 
     - name: Run unit tests
     - name: Run unit tests
-      run: npm test
+      run: npm run ci-test
       working-directory: js
       working-directory: js
+      
+    - name: Upload Test Results
+      if: always()
+      uses: actions/upload-artifact@v4
+      with:
+        name: Test Results (Mocha)
+        path: js/mocha-results.xml
+  
+  event_file:
+    name: "Event File"
+    runs-on: ubuntu-latest
+    steps:
+    - name: Upload
+      uses: actions/upload-artifact@v4
+      with:
+        name: Event File
+        path: ${{ github.event_path }}
+

+ 2 - 1
js/package.json

@@ -15,7 +15,8 @@
     "@peculiar/webcrypto": "^1.1.1"
     "@peculiar/webcrypto": "^1.1.1"
   },
   },
   "scripts": {
   "scripts": {
-    "test": "mocha"
+    "test": "mocha",
+    "ci-test": "mocha --reporter-option output=mocha-results.xml"
   },
   },
   "repository": {
   "repository": {
     "type": "git",
     "type": "git",