Repository navigation
84 lines (70 loc) · 2.95 KB
/
Copy pathCalculateUnsafeCode.yml
File metadata and controls
84 lines (70 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# A workflow to analyze unsafe code usage and generate badges
# to show the amount of unsafe code in the repository.
#
##
# Copyright (c) Microsoft Corporation.
#
# SPDX-License-Identifier: Apache-2.0
##
name: "Unsafe Code Analysis"
on:
workflow_call:
jobs:
analyze-unsafe-code:
name: Analyze Unsafe Code Usage
runs-on: ubuntu-latest
if: github.repository_owner == 'OpenDevicePartnership'
steps:
- name: Generate Token
id: app-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
app-id: ${{ secrets.PATINA_AUTOMATION_APPLICATION_ID }}
private-key: ${{ secrets.PATINA_AUTOMATION_APPLICATION_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: ✅ Checkout Repository ✅
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Checkout patina-devops scripts
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: OpenDevicePartnership/patina-devops
path: patina-devops-scripts
token: ${{ steps.app-token.outputs.token }}
sparse-checkout: |
.github/scripts
sparse-checkout-cone-mode: false
- name: 🛠️ Download Rust Tools 🛠️
uses: OpenDevicePartnership/patina-devops/.github/actions/rust-tool-cache@main
- name: Run unsafe code analysis
env:
RUSTC_BOOTSTRAP: 1
run: |
python3 patina-devops-scripts/.github/scripts/analyze_unsafe_code_geiger.py
- name: Update git credentials
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Checkout the unsafe-code-badges branch
run: |
mkdir -p /tmp/badge-data
cp -r unsafe-code-analysis/* /tmp/badge-data/
rm -rf unsafe-code-analysis
git fetch origin
if git ls-remote --exit-code --heads origin unsafe-code-badges; then
git checkout -B unsafe-code-badges origin/unsafe-code-badges
else
git checkout -b unsafe-code-badges
fi
# Remove the old data and copy the new data
rm -rf x86_64-unknown-uefi aarch64-unknown-uefi unsafe_analysis.* 2>/dev/null || true
cp -r /tmp/badge-data/* .
- name: Push badge data to the unsafe-code-badges branch
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
git add x86_64-unknown-uefi/ aarch64-unknown-uefi/ unsafe_analysis.* 2>/dev/null || true
git commit -m "Update unsafe code analysis badge data" || echo "No changes to commit"
git push origin unsafe-code-badges