From 46e72e56f867101a139e5116e7c5ef22b44c467e Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 30 Dec 2021 10:31:17 -0500 Subject: build: use a sparse checkout for the reports repo --- .github/workflows/coverage.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index b6cf37c8..dc5d2bbc 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -141,12 +141,14 @@ 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 version + 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 checkout main - name: "Download coverage JSON report" uses: actions/download-artifact@v2 @@ -156,6 +158,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 +184,7 @@ jobs: - name: "Push to report repo" run: | + set -xe # Make the redirect to the latest report. echo "" > reports_repo/latest.html echo "" >> reports_repo/latest.html @@ -192,7 +196,10 @@ jobs: echo "${{ env.sha10 }}: ${{ env.branch }}" >> commit.txt # Commit. cd ./reports_repo - rm ${{ env.report_dir }}/.gitignore + git sparse-checkout set '/*' '!/reports' + git sparse-checkout set '/*' '${{ env.report_dir }}' + ls -al ${{ env.report_dir }} + rm -f ${{ env.report_dir }}/.gitignore git add ${{ env.report_dir }} git add latest.html git config user.name nedbat -- cgit v1.2.1