-
Notifications
You must be signed in to change notification settings - Fork 33
81 lines (74 loc) · 3.2 KB
/
_CI_update.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
name: Update Code
on:
workflow_call:
inputs:
coverage_value_updated:
required: true
description: "The C++ Coverage for target"
type: string
coverage_test_status:
required: true
description: "Status of coverage tests (passed/failed)"
type: string
permissions: {}
jobs:
commit_job:
permissions:
contents: write
pull-requests: write
name: Commit Code Updates
env:
COMMIT_MSG: "Automated coverage update"
DOCKER_ARTIFACT_DIR: "Docker_artifacts"
runs-on: ubuntu-latest
steps:
# Checkout code doesn't persist across jobs
- name: Checkout Source Branch
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- run: mkdir -p ${{ env.DOCKER_ARTIFACT_DIR }}
- name: Retrieve Current Coverage Files
if: ${{ inputs.coverage_value_updated }} == 'true' && ${{ inputs.coverage_test_status }} == 'passed'
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: coverage_artifact
path: .github/coverage/
- name: Update coverage reports with latest coverage
# Change latest coverage as develop (future target)
if: ${{ inputs.coverage_value_updated }} == 'true' && ${{ inputs.coverage_test_status }} == 'passed'
run: |
cd ${GITHUB_WORKSPACE}/.github/coverage/
rm -rf *.develop.*.txt || true
rm -rf *.old-develop.*.txt || true
ls
mv cpp.new.coverage_report.txt cpp.develop.coverage_report.txt
mv cpp.new.coverage_value.txt cpp.develop.coverage_value.txt
mv python.new.coverage_report.txt python.develop.coverage_report.txt
mv python.new.coverage_value.txt python.develop.coverage_value.txt
# Update Code and Push (Should be last steps of workflow since it changes commit)
- name: Commit Changes
id: update_commit
continue-on-error: true
run: |
cd ${GITHUB_WORKSPACE}
changes=$([ -z "$(git diff)" ] && echo "Empty" || echo "Not empty")
echo "changes=$changes" >> $GITHUB_OUTPUT
if [ "$changes" != "Empty" ]; then
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add .github/coverage/*
git commit -am "${{ env.COMMIT_MSG }}"
git push
fi
- if: steps.update_commit.outcome != 'success'
name: Check Push Failure
env:
FILE_CHANGES: ${{ steps.update_commit.outputs.changes }}
run: |
if [ "${{ env.FILE_CHANGES }}" != "Empty" ]; then
echo "Error issuing commit. Coverage reports were NOT updated"
exit 1
fi