Skip to content

Commit

Permalink
Merge pull request #113 from mrmundt/workflow_logic
Browse files Browse the repository at this point in the history
Adding logic for Codecov Failures
  • Loading branch information
jsiirola authored Aug 11, 2020
2 parents da1ace6 + f36d6ba commit d99406f
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions .github/workflows/pr_master_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:
coverage xlrd
jobs:
pyomo-tests:
build:
name: ${{ matrix.TARGET }}/${{ matrix.python }}${{ matrix.NAME }}
runs-on: ${{ matrix.os }}
strategy:
Expand Down Expand Up @@ -174,9 +174,9 @@ jobs:
CODECOV_NAME: ${{matrix.TARGET}}/${{matrix.python}}${{matrix.NAME}}
run: |
[ ! -d ${GITHUB_WORKSPACE}/cache/download ] && mkdir -pv ${GITHUB_WORKSPACE}/cache/download
coverage combine || echo "Nothing to combine."
coverage report -i
coverage xml -i
ls -la
set +e
# Always attempt to update the codecov script, but fall back on
# the previously cached script if it fails
Expand All @@ -191,18 +191,54 @@ jobs:
echo "Pausing $DELAY seconds before re-attempting download"
sleep $DELAY
done
ls -la ${GITHUB_WORKSPACE}/cache/
i=0
while : ; do
((i+=1))
echo "Uploading coverage to codecov (attempt ${i})"
bash $CODECOV -Z -X gcov -X s3 -f coverage.xml
if test $? == 0; then
echo "PASS" > ${GITHUB_WORKSPACE}/codecov.result
break
elif test $i -ge 2; then
# Do not fail the build just because the codecov upload fails
echo "FAIL" > ${GITHUB_WORKSPACE}/codecov.result
break
elif test $i -ge 5; then
exit 1
fi
DELAY=$(( RANDOM % 30 + 30))
echo "Pausing $DELAY seconds before re-attempting upload"
sleep $DELAY
done
- name: Record build artifacts
uses: actions/upload-artifact@v2
with:
name: ${{github.job}}_${{env.GHA_JOBNAME}}
path: |
codecov.result
# In general, do not record test results as artifacts to
# manage total artifact storage
# TEST-*.xml

post:
name: post-build
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
path: artifacts

- name: Check codecov upload success
run: |
FAIL=`grep FAIL artifacts/*/codecov.result | wc -l`
ALL=`ls -1 artifacts/*/codecov.result | wc -l`
# Fail is more than 1/9 codecov uploads fail
echo "$FAIL of $ALL codecov uploads failed"
if test $FAIL -gt 0; then
grep FAIL artifacts/*/codecov.result | sed 's/^/ /'
if test $(( $FAIL * 9 )) -gt $ALL; then
echo "More than 1/9 codecov uploads failed:"
exit 1
fi
fi

0 comments on commit d99406f

Please sign in to comment.