microsoft/openvmm

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
f1701ab43fd29fd424895bc4a17c40c5dc53ac56

Branches

Tags

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

Clone

HTTPS

Download ZIP

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

101lines · modecode

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