microsoft/openvmm

Public

mirrored fromhttps://github.com/microsoft/openvmmAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2633a52f553a8db6cbdcc8b968eeef579e15bf38

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/workflows/upload-petri-results.yml

102lines · modecode

1name: Upload Petri Test Results
2
3on:
4 workflow_run:
5 types:
6 - completed
7 workflows:
8 - 'OpenVMM CI'
9 - 'OpenVMM PR'
10 - '\[Optional\] OpenVMM Release PR'
11
12permissions:
13 id-token: write
14 contents: read
15 actions: read # Needed to download artifacts from other runs
16 pull-requests: write # Needed to create PR comments
17
18jobs:
19 upload-logs:
20 runs-on: ubuntu-latest
21 env:
22 BASE_URL: https://openvmmghtestresults.blob.core.windows.net/results
23
24 steps:
25 - name: Authenticate to Azure
26 uses: azure/login@v1
27 with:
28 client-id: ${{ secrets.OPENVMM_TEST_RESULT_CLIENT_ID }}
29 tenant-id: ${{ secrets.OPENVMM_TENANT_ID }}
30 subscription-id: ${{ secrets.OPENVMM_SUBSCRIPTION_ID }}
31
32 - name: Download matching artifacts
33 run: |
34 if [ "$event" = "pull_request" ]; then
35 # Get the associated PR number. Work around GitHub Actions often not
36 # populating the `pull_requests` array. See
37 # <https://github.com/orgs/community/discussions/25220>.
38 pr=$(gh pr view --repo "${repo}" "${head_branch}" --json number --jq .number)
39 echo "SOURCE_PR=$pr" >> "$GITHUB_ENV"
40 else
41 echo "SOURCE_PR=" >> "$GITHUB_ENV"
42 fi
43 mkdir -p results
44 gh run \
45 -R "$repo" \
46 download "$run_id" \
47 -p "*-vmm-tests-logs" \
48 -D results
49 test_count=$(find results -name petri.jsonl | wc -l)
50 PASS_COUNT=$(find results -name petri.passed | wc -l)
51 FAIL_COUNT=$((test_count - PASS_COUNT))
52 echo "FAIL_COUNT=$FAIL_COUNT" >> "$GITHUB_ENV"
53 echo "PASS_COUNT=$PASS_COUNT" >> "$GITHUB_ENV"
54 echo "SOURCE_BRANCH=$head_branch" >> "$GITHUB_ENV"
55 env:
56 event: ${{ github.event.workflow_run.event }}
57 repo: ${{ github.event.workflow_run.repository.full_name }}
58 run_id: ${{ github.event.workflow_run.id }}
59 # If the PR is from a fork, prefix it with `<owner-login>:`.
60 head_branch: |-
61 ${{
62 (github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login)
63 && format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch)
64 || github.event.workflow_run.head_branch
65 }}
66 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67
68 - name: Upload to Azure Blob Storage
69 run: |
70 az storage blob upload-batch \
71 --destination "$BASE_URL" \
72 --destination-path "$run_id" \
73 --source results \
74 --auth-mode login
75
76 # Store a metadata blob in a separate portion of the hierarchy so that
77 # it can be cheaply queried.
78 az storage blob upload \
79 --blob-url "$BASE_URL/runs/$run_id" \
80 --file /dev/null \
81 --metadata \
82 "petrifailed=$FAIL_COUNT" \
83 "petripassed=$PASS_COUNT" \
84 "ghbranch=$SOURCE_BRANCH" \
85 "ghpr=$SOURCE_PR" \
86 --auth-mode login
87 env:
88 run_id: ${{ github.event.workflow_run.id }}
89
90 - name: Report failing tests
91 if: ${{ env.SOURCE_PR && env.FAIL_COUNT > 0 }}
92 run: |
93 gh pr comment \
94 -R "$repo" \
95 "$SOURCE_PR" \
96 -F - <<EOF
97 [At least one Petri test failed.](https://openvmm.dev/test-results/?run=$run_id)
98 EOF
99 env:
100 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101 repo: ${{ github.event.workflow_run.repository.full_name }}
102 run_id: ${{ github.event.workflow_run.id }}
103