microsoft/openvmm

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
7c3a527ffe19338b7bec2a98849f641769c7b569

Branches

Tags

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

Clone

HTTPS

Download ZIP

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

108lines · 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: Free Disk Space (Ubuntu)
26 uses: jlumbroso/free-disk-space@v1.3.1
27 with:
28 # Azure CLI is considered a large package
29 large-packages: false
30
31 - name: Authenticate to Azure
32 uses: azure/login@v1
33 with:
34 client-id: ${{ secrets.OPENVMM_TEST_RESULT_CLIENT_ID }}
35 tenant-id: ${{ secrets.OPENVMM_TENANT_ID }}
36 subscription-id: ${{ secrets.OPENVMM_SUBSCRIPTION_ID }}
37
38 - name: Download matching artifacts
39 run: |
40 if [ "$event" = "pull_request" ]; then
41 # Get the associated PR number. Work around GitHub Actions often not
42 # populating the `pull_requests` array. See
43 # <https://github.com/orgs/community/discussions/25220>.
44 pr=$(gh pr view --repo "${repo}" "${head_branch}" --json number --jq .number)
45 echo "SOURCE_PR=$pr" >> "$GITHUB_ENV"
46 else
47 echo "SOURCE_PR=" >> "$GITHUB_ENV"
48 fi
49 mkdir -p results
50 gh run \
51 -R "$repo" \
52 download "$run_id" \
53 -p "*-vmm-tests-logs" \
54 -D results
55 test_count=$(find results -name petri.jsonl | wc -l)
56 PASS_COUNT=$(find results -name petri.passed | wc -l)
57 FAIL_COUNT=$((test_count - PASS_COUNT))
58 echo "FAIL_COUNT=$FAIL_COUNT" >> "$GITHUB_ENV"
59 echo "PASS_COUNT=$PASS_COUNT" >> "$GITHUB_ENV"
60 echo "SOURCE_BRANCH=$head_branch" >> "$GITHUB_ENV"
61 env:
62 event: ${{ github.event.workflow_run.event }}
63 repo: ${{ github.event.workflow_run.repository.full_name }}
64 run_id: ${{ github.event.workflow_run.id }}
65 # If the PR is from a fork, prefix it with `<owner-login>:`.
66 head_branch: |-
67 ${{
68 (github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login)
69 && format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch)
70 || github.event.workflow_run.head_branch
71 }}
72 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73
74 - name: Upload to Azure Blob Storage
75 run: |
76 az storage blob upload-batch \
77 --destination "$BASE_URL" \
78 --destination-path "$run_id" \
79 --source results \
80 --auth-mode login
81
82 # Store a metadata blob in a separate portion of the hierarchy so that
83 # it can be cheaply queried.
84 az storage blob upload \
85 --blob-url "$BASE_URL/runs/$run_id" \
86 --file /dev/null \
87 --metadata \
88 "petrifailed=$FAIL_COUNT" \
89 "petripassed=$PASS_COUNT" \
90 "ghbranch=$SOURCE_BRANCH" \
91 "ghpr=$SOURCE_PR" \
92 --auth-mode login
93 env:
94 run_id: ${{ github.event.workflow_run.id }}
95
96 - name: Report failing tests
97 if: ${{ env.SOURCE_PR && env.FAIL_COUNT > 0 }}
98 run: |
99 gh pr comment \
100 -R "$repo" \
101 "$SOURCE_PR" \
102 -F - <<EOF
103 [At least one Petri test failed.](https://openvmm.dev/test-results/#/runs/$run_id)
104 EOF
105 env:
106 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107 repo: ${{ github.event.workflow_run.repository.full_name }}
108 run_id: ${{ github.event.workflow_run.id }}
109