Skip to content

Commit ea1fef2

Browse files
ci(doccano-django): graceful bootstrap when base ref lacks the sample
Run 25196349264 (the very PR introducing doccano-django/) failed in release-coverage with: An error occurred trying to start process '/usr/bin/bash' with working directory '.../doccano-django'. No such file or directory Expected: the workflow checks out the PR's base ref to compute the baseline coverage, but on the introducing PR there's no baseline — `doccano-django/` doesn't exist on main yet. Fix: a `detect` step inspects whether `doccano-django/flow.sh` exists on the checked-out base ref. If yes, the measurement runs as before. If no (first-PR-bootstrap case), an `empty-baseline` step emits coverage=0.0 onto the job output, the measurement step is skipped via `if:`, and the upload- artifact step is also skipped (so we don't claim a non-existent report file). The job's `outputs.coverage` falls back through `||` so the gate sees 0.0 either way. Net effect on the introducing PR: build's coverage (currently ~11%) is compared against 0%, gate trivially passes. After this PR merges and a future PR edits doccano-django/, the detect step finds the sample on main, real measurement runs, real diff applies. Signed-off-by: Akash Kumar <meakash7902@gmail.com>
1 parent 524884f commit ea1fef2

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

.github/workflows/doccano-django.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,48 @@ jobs:
102102
runs-on: ubuntu-latest
103103
timeout-minutes: 20
104104
outputs:
105-
coverage: ${{ steps.measure.outputs.coverage }}
105+
coverage: ${{ steps.measure.outputs.coverage || steps.empty-baseline.outputs.coverage }}
106+
sample-existed: ${{ steps.detect.outputs.sample-existed }}
106107
steps:
107108
- uses: actions/checkout@v4
108109
with:
109110
ref: ${{ github.event.pull_request.base.ref }}
111+
112+
# First-PR bootstrap escape hatch: the very PR that
113+
# introduces the doccano-django/ sample has no baseline
114+
# (doccano-django/ doesn't exist on the base ref). Detect
115+
# that and short-circuit to coverage=0; the gate then
116+
# treats build's coverage as the new baseline and trivially
117+
# passes for any percentage > 0. After the introducing PR
118+
# merges, every subsequent PR has a real baseline to diff
119+
# against.
120+
- id: detect
121+
name: Detect baseline presence
122+
run: |
123+
if [ -d doccano-django ] && [ -x doccano-django/flow.sh ]; then
124+
echo "sample-existed=true" >>"$GITHUB_OUTPUT"
125+
echo "Sample exists on base ref — running full measurement."
126+
else
127+
echo "sample-existed=false" >>"$GITHUB_OUTPUT"
128+
echo "No doccano-django/ on base ref — first-PR bootstrap; baseline coverage treated as 0%."
129+
fi
130+
110131
- id: measure
111132
name: Run sample end-to-end + measure coverage
133+
if: steps.detect.outputs.sample-existed == 'true'
112134
working-directory: doccano-django
113135
env:
114136
DOCCANO_FIRED_ROUTES_FILE: ${{ runner.temp }}/fired-routes-release.log
115137
DOCCANO_PHASE: ci-release
116138
run: ../.github/workflows/scripts/run-and-measure.sh
117139

140+
- id: empty-baseline
141+
name: Emit zero baseline (first-PR bootstrap)
142+
if: steps.detect.outputs.sample-existed != 'true'
143+
run: echo "coverage=0.0" >>"$GITHUB_OUTPUT"
144+
118145
- name: Upload coverage report
119-
if: always()
146+
if: always() && steps.detect.outputs.sample-existed == 'true'
120147
uses: actions/upload-artifact@v4
121148
with:
122149
name: coverage-release

0 commit comments

Comments
 (0)