forked from ultralytics/yolov5
-
Notifications
You must be signed in to change notification settings - Fork 4
120 lines (115 loc) · 4.92 KB
/
util.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: report-to-testmo
on:
workflow_call:
inputs:
runs_on:
description: "runner label specifying instance running the job"
type: string
required: true
run_id:
description: "run id provided by GHA"
required: true
type: string
build_type:
description: "build type: nightly or release"
type: string
required: true
testmo_project_id:
description: "testmo project id"
type: string
required: true
jobs:
BUILD_AND_REPORT:
runs-on: ${{ inputs.runs_on }}
outputs:
status: ${{ steps.build.outputs.status }}
commitid: ${{ steps.build.outputs.commitid }}
permissions:
id-token: write
contents: read
steps:
- name: repo checkout
uses: actions/checkout@v3
- name: s3
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_WEBIDENTITY_FOR_GITHUB_ACTIONS }}
aws-region: us-east-1
- name: build
id: build
run: |
pwd
sudo apt-get -y install python3-pip
pip3 --version
sudo pip3 install virtualenv
virtualenv venv
source venv/bin/activate
if [[ "${{ inputs.build_type }}" = release ]]; then
sed -i 's/is_release = False/is_release = True/g' utils/neuralmagic/version.py
fi
status=$(make -B build || echo 'FAILED')
deactivate
echo "=========== Build log ==========="
echo "${status}"
echo "commitid=${GITHUB_SHA:0:7}" >> "$GITHUB_OUTPUT"
echo "=========== Build status ==========="
if [[ "${status}" = "FAILED" ]]; then
echo "${{ github.event.repository.name }} build failed"
echo "status=failed" >> "$GITHUB_OUTPUT"
exit 1
else
echo "${{ github.event.repository.name }} build success"
fi
echo "=========== Generated build ==========="
ls dist/
echo "=========== Copy build to S3 ==========="
aws s3 cp dist/*.whl s3://nm-github-actions/${{ github.event.repository.name }}/
if [ $? -eq 0 ]; then
echo "ok: copied to s3://nm-github-actions/${{ github.event.repository.name }}/"
else
echo "failed: copied to s3://nm-github-actions/${{ github.event.repository.name }}/"
exitCode=1
fi
if [ ${exitCode} -eq 1 ]; then
echo "status=failed" >> "$GITHUB_OUTPUT"
cp .github/workflows/result.xml.fail result.xml
else
echo "status=success" >> "$GITHUB_OUTPUT"
cp .github/workflows/result.xml.success result.xml
fi
oldDate=`date --date='-2 month' +%Y%m%d`
oldWhl=`(aws s3 ls s3://nm-github-actions/${{ github.event.repository.name }}/ | grep nightly | grep "${oldDate}") || echo "notfound"`
if [[ "${oldWhl}" != 'notfound' ]]; then
for oldwhl in $(echo "${oldWhl}" | awk '{print $4}')
do
echo "Remove old build ${oldwhl} in S3"
aws s3 rm s3://nm-github-actions/${{ github.event.repository.name }}/${oldwhl}
done
fi
# TESTMO
echo "node: $(node -v)"
echo "npm: $(npm -v)"
echo "Installing testmo cli..."
sudo npm install -g @testmo/testmo-cli
export TESTMO_TOKEN=${{ secrets.TESTMO_TEST_TOKEN }}
TESTMO_URL="https://neuralmagic.testmo.net"
todaytime=`date +%Y%m%d`
name="${{ github.event.repository.name }} ${{ inputs.build_type }} ${todaytime} ${GITHUB_SHA:0:7} RunID:${{ inputs.run_id }}"
echo "========== Build info ==========="
echo "name: ${name}"
echo "build: $GITHUB_OUTPUT"
echo "echo \"GHA job $GITHUB_OUTPUT: https://github.com/neuralmagic/${{ github.event.repository.name }}/actions/runs/${{ inputs.run_id }}\"; exit ${exitCode}" > result.sh
echo "========== Report to testmo ==========="
echo "testmo automation:run:submit \\"
echo " --instance ${TESTMO_URL} \\"
echo " --project-id ${{ inputs.testmo_project_id }} \\"
echo " --name ${name} \\"
echo " --source ${{ github.event.repository.name }} \\"
echo " --results result.xml"
testmo automation:run:submit \
--instance "${TESTMO_URL}" \
--project-id ${{ inputs.testmo_project_id }} \
--name "${name}" \
--source "${{ github.event.repository.name }}" \
--results result.xml \
-- bash result.sh