forked from virtee/snphost
-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (58 loc) · 2.32 KB
/
snphost_ci_test.yml
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
name: snphost CI PR test
on:
pull_request_target:
types:
- reopened
- opened
- edited
- synchronize
workflow_dispatch:
inputs:
pull_request_number:
description: 'Specify the pull request number'
pull_request_branch:
description: 'Specify pull request source branch'
jobs:
snp_host_tests:
runs-on: self-hosted
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Verify if SNP is enabled on the host
run: |
source ./.github/workflows/snp_function_declarations.sh
verify_snp_host
- name: Set the PR number and PR branch environment based on GH Action event type
run: |
event_pr_number=''
event_pr_branch=''
if [ ${{ github.event_name }} == "pull_request_target" ]; then
event_pr_number=${{ github.event.pull_request.number }}
event_pr_branch=${{ github.head_ref }}
elif [ ${{ github.event_name }} == "workflow_dispatch" ]; then
event_pr_number=${{ github.event.inputs.pull_request_number }}
event_pr_branch=${{ github.event.inputs.pull_request_branch }}
fi
echo "pr_number=${event_pr_number}" >> $GITHUB_ENV
echo "pr_branch=${event_pr_branch}" >> $GITHUB_ENV
- name: Show the GH environment variable current values
run: |
echo "GH Action PR number = ${{ env.pr_number }}"
echo "GH Action PR branch = ${{ env.pr_branch }}"
- name: Run snphost cargo test on the host
run: |
# Check and install dependencies on the host
source ./.github/workflows/snp_function_declarations.sh
check_rust_on_host
# Cleanup steps on the host
rm -rf ~/snphost
cd ~/
git clone https://github.com/LakshmiSaiHarika/snphost.git
cd ~/snphost
# Checkout the PR branch
if [[ ${{ github.event_name }} == "pull_request_target" || ${{ github.event_name }} == "workflow_dispatch" ]]; then
git fetch origin pull/${{ env.pr_number }}/head:${{ env.pr_branch }}
git switch ${{ env.pr_branch }}
fi
# Perform cargo test on the host
cargo test