summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-12-30 10:31:17 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-12-30 14:38:23 -0500
commitea44f13536b2f37dd3269fa1936ebf2bab8f972a (patch)
tree6c18140c37a8d318d271826dbbcdc4870fc90f52
parent4c01c6ee1b998ef789459f7b0b46e781a3dbe413 (diff)
downloadpython-coveragepy-git-ea44f13536b2f37dd3269fa1936ebf2bab8f972a.tar.gz
build: use a sparse checkout for the reports repo
-rw-r--r--.github/workflows/coverage.yml23
1 files changed, 13 insertions, 10 deletions
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index 78359be3..9385ff5f 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -141,12 +141,15 @@ jobs:
steps:
- name: "Checkout reports repo"
- # TODO: sparse checkout would be great
- uses: actions/checkout@v2
- with:
- repository: nedbat/coverage-reports
- path: ./reports_repo
- token: ${{ secrets.COVERAGE_REPORTS_TOKEN }}
+ run: |
+ set -xe
+ git clone --depth=1 --no-checkout https://${{ secrets.COVERAGE_REPORTS_TOKEN }}@github.com/nedbat/coverage-reports reports_repo
+ cd reports_repo
+ git sparse-checkout init --cone
+ git sparse-checkout set '/*' '!/reports'
+ git config user.name nedbat
+ git config user.email ned@nedbatchelder.com
+ git checkout main
- name: "Download coverage JSON report"
uses: actions/download-artifact@v2
@@ -156,6 +159,7 @@ jobs:
- name: "Compute info for later steps"
id: info
run: |
+ set -xe
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
export PCTINT=$(echo $TOTAL | cut -f1 -d.)
export SHA10=$(echo ${{ github.sha }} | cut -c 1-10)
@@ -181,6 +185,7 @@ jobs:
- name: "Push to report repo"
run: |
+ set -xe
# Make the redirect to the latest report.
echo "<html><head>" > reports_repo/latest.html
echo "<meta http-equiv='refresh' content='0;url=${{ env.url }}' />" >> reports_repo/latest.html
@@ -192,11 +197,9 @@ jobs:
echo "${{ env.sha10 }}: ${{ env.branch }}" >> commit.txt
# Commit.
cd ./reports_repo
+ git sparse-checkout set '/*' '${{ env.report_dir }}'
rm ${{ env.report_dir }}/.gitignore
- git add ${{ env.report_dir }}
- git add latest.html
- git config user.name nedbat
- git config user.email ned@nedbatchelder.com
+ git add ${{ env.report_dir }} latest.html
git commit --file=../commit.txt
git push