Repository navigation
fix(ci): R3-2 - correctness + cost pass on the CI pipeline #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,12 +26,19 @@ defaults: | |
| run: | ||
| shell: bash | ||
|
|
||
| # Sync fan-out gate (both jobs): "Sync articles" completes every 10 min | ||
| # during the day, but most runs commit nothing - deploying + testing an | ||
| # unchanged tree ~84x/day is pure waste. For workflow_run events, run only | ||
| # when the sync actually pushed (master head moved past the sha the sync ran | ||
| # on). github.sha for workflow_run = current default-branch head. | ||
| jobs: | ||
| build_and_deploy: | ||
| if: ${{ github.event_name != 'workflow_run' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_sha != github.sha) }} | ||
| uses: ./.github/workflows/_hugo.yml | ||
|
|
||
| unit_tests: | ||
| name: Unit Tests | ||
| if: ${{ github.event_name != 'workflow_run' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_sha != github.sha) }} | ||
|
Comment on lines
+36
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
rg -n -C 12 \
'workflow_run|Sync articles|push:|workflows:|git push|git commit' \
.github/workflowsRepository: jetthoughts/jetthoughts.github.io Length of output: 13609 🌐 Web query:
💡 Result: When using the workflow_run event in GitHub Actions, the workflow executes in the context of the repository's default branch, not the branch that triggered the original workflow [1][2]. Therefore, standard environment variables like GITHUB_REF or GITHUB_SHA will reflect the default branch rather than the branch of the triggering commit [2][3]. To access information about the original workflow run that triggered the current event, you must use the github.event.workflow_run context [2]. Key points for accessing branch and commit information: 1. Accessing the Branch Name: You can obtain the name of the branch that triggered the original workflow by using ${{ github.event.workflow_run.head_branch }} [2][3]. 2. Accessing the Commit SHA: You can obtain the SHA of the commit that triggered the original workflow by using ${{ github.event.workflow_run.head_sha }} [4][5]. 3. Checking Out the Correct Code: Because the workflow runs on the default branch by default, you must explicitly configure your checkout step to use the original branch or SHA if you need to access the code from that specific commit [2][3]. Example usage with actions/checkout: - uses: actions/checkout@v4 with: ref: ${{ github.event.workflow_run.head_sha }} Using head_sha is generally safer than head_branch for checkout, as it ensures you are working with the exact state of the code that triggered the original workflow, preventing issues if new commits have been pushed to that branch in the interim [5]. Citations:
🌐 Web query:
💡 Result: In a GitHub Actions workflow triggered by the workflow_run event, the standard github.sha context does not represent the commit that triggered the original workflow [1]. Instead, github.sha defaults to the last commit on the default branch of the repository where the workflow is running [2][3]. To access the SHA of the commit that triggered the original workflow, you must use the event payload available within the github.event context [4][5]. Specifically, you should use: ${{ github.event.workflow_run.head_sha }} This field, head_sha, contains the SHA of the commit that triggered the workflow run that this workflow is reacting to [4][1]. It is essential to use this specific property because the workflow_run event context differs significantly from events like push, where github.sha directly points to the triggering commit [4][5]. Note that head_commit is also present in the webhook payload for some events (like push), but for workflow_run, the head_sha within the workflow_run object is the standard and correct way to retrieve the triggering commit's identifier [4][6]. Citations:
Gate on whether
🤖 Prompt for AI Agents |
||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| steps: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -26,6 +26,10 @@ on: | |||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||||
| paths: | ||||||||||||||||||||||||||||
| - 'themes/**' | ||||||||||||||||||||||||||||
| # root-level template/asset overrides change rendering just like | ||||||||||||||||||||||||||||
| # their themes/ counterparts | ||||||||||||||||||||||||||||
| - 'layouts/**' | ||||||||||||||||||||||||||||
| - 'assets/**' | ||||||||||||||||||||||||||||
| - 'config/**' | ||||||||||||||||||||||||||||
| - 'postcss.config.js' | ||||||||||||||||||||||||||||
| - 'test/fixtures/screenshots/**' | ||||||||||||||||||||||||||||
|
|
@@ -55,9 +59,13 @@ jobs: | |||||||||||||||||||||||||||
| continue-on-error: ${{ github.event_name == 'pull_request' }} | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||
| # PR events use the default checkout (the PR *merge* commit): testing | ||||||||||||||||||||||||||||
| # the head branch alone misses conflicts with the base and breaks on | ||||||||||||||||||||||||||||
| # fork PRs (head_ref doesn't exist in this repo). Record dispatches | ||||||||||||||||||||||||||||
| # check out the real branch ref so the baseline commit can be pushed. | ||||||||||||||||||||||||||||
| - uses: actions/checkout@v7 | ||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||
| ref: ${{ github.head_ref || github.ref }} | ||||||||||||||||||||||||||||
| ref: ${{ github.event_name == 'workflow_dispatch' && github.ref || '' }} | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - uses: snap-diff/snap_diff-capybara/.github/actions/setup-ruby-and-dependencies@5ee298fbc3c1e070c78e3d83862ffd3228204214 | ||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||
|
|
@@ -95,18 +103,30 @@ jobs: | |||||||||||||||||||||||||||
| PRECOMPILED_ASSETS: '1' | ||||||||||||||||||||||||||||
| HUGO_DEFAULT_PATH: _dest/public-test | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # test:system, not the full `rake test`: recording only rewrites | ||||||||||||||||||||||||||||
| # screenshot baselines, and a failing unit test used to abort the run | ||||||||||||||||||||||||||||
| # AFTER 15+ min of recording, discarding every recorded PNG. | ||||||||||||||||||||||||||||
| - name: Record baselines | ||||||||||||||||||||||||||||
| id: record | ||||||||||||||||||||||||||||
| if: ${{ github.event_name == 'workflow_dispatch' && inputs.update-baselines }} | ||||||||||||||||||||||||||||
| run: FORCE_SCREENSHOT_UPDATE=true bundle exec rake test | ||||||||||||||||||||||||||||
| run: FORCE_SCREENSHOT_UPDATE=true bundle exec rake test:system | ||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||
| PRECOMPILED_ASSETS: '1' | ||||||||||||||||||||||||||||
| HUGO_DEFAULT_PATH: _dest/public-test | ||||||||||||||||||||||||||||
| # Record mode intentionally dirties the fixtures as it runs. | ||||||||||||||||||||||||||||
| ALLOW_DIRTY_SCREENSHOTS: '1' | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # always(): freshly recorded baselines must be committed even when a | ||||||||||||||||||||||||||||
| # test failed mid-run (a red test does not invalidate the OTHER pages' | ||||||||||||||||||||||||||||
| # recordings). Gated on the record step actually having run, and the | ||||||||||||||||||||||||||||
| # commit is a no-op when nothing changed. | ||||||||||||||||||||||||||||
| - name: Commit updated baselines | ||||||||||||||||||||||||||||
| if: ${{ github.event_name == 'workflow_dispatch' && inputs.update-baselines }} | ||||||||||||||||||||||||||||
| if: ${{ always() && steps.record.outcome != 'skipped' && github.event_name == 'workflow_dispatch' && inputs.update-baselines }} | ||||||||||||||||||||||||||||
|
Comment on lines
+119
to
+124
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== locate test.yml =="
fd -a 'test\.yml$' . | sed 's#^\./##' || true
echo "== relevant workflow excerpt =="
if [ -f .github/workflows/test.yml ]; then
nl -ba .github/workflows/test.yml | sed -n '90,140p'
fi
echo "== workflow_dispatch inputs/steps references =="
if [ -f .github/workflows/test.yml ]; then
rg -n "update-baselines|steps\.record|record:|cancelled\(\)|pullRequest|system|commit updated baselines" .github/workflows/test.yml
fi
echo "== GitHub Actions cancel/always/outcome docs probe =="
python3 - <<'PY'
# Read-only semantic probe: demonstrate the workflow expression logic
# from the referenced condition without importing repository code.
import json, pathlib
p = pathlib.Path('.github/workflows/test.yml')
print('exists', p.exists())
if p.exists():
text = p.read_text()
found = False
for i,line in enumerate(text.splitlines(),1):
if 'if: ${{ always() && steps.record.outcome !=' in line:
found = True
print(f'line {i}: {line.strip()}')
print('contains cancelled guard:', '!cancelled()' in line)
print('contains skipped guard:', '!= '\''skipped'\'' in line or "!= '\''skipped'\''" in line')
if not found:
print('condition not found')
PYRepository: jetthoughts/jetthoughts.github.io Length of output: 311 🌐 Web query:
💡 Result: In GitHub Actions, the Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== relevant workflow excerpt =="
python3 - <<'PY'
from pathlib import Path
p = Path('.github/workflows/test.yml')
if not p.exists():
print('missing')
raise SystemExit
for i,line in enumerate(p.read_text().splitlines(), 1):
if 90 <= i <= 140:
print(f'{i:6d}: {line}')
PY
echo "== step name references and cancellation guard =="
python3 - <<'PY'
from pathlib import Path
p = Path('.github/workflows/test.yml')
for i,line in enumerate(p.read_text().splitlines(), 1):
if any(tok in line for tok in ['update-baselines', 'steps.record.outcome', 'cancelled()', 'record:']):
print(f'{i}: {line.strip()}')
PY
echo "== check installed GitHub CLI availability/permissions =="
command -v gh || true
if command -v gh >/dev/null 2>&1; then
env | grep -i gh || true
gh --version 2>&1 | head -n 5 || true
fiRepository: jetthoughts/jetthoughts.github.io Length of output: 4722 🌐 Web query:
💡 Result: In GitHub Actions, the term cancelled is used to describe the status or conclusion of a job or step after a workflow has been manually cancelled or terminated by the system [1][2]. Contexts and Terminology 1. Job Status and Conclusion The status of a job (e.g., job.status) indicates its current lifecycle phase, such as queued, in_progress, or completed [3]. When a job finishes, it receives a conclusion, which describes the final result [3][4]. A job can have a conclusion of cancelled when the workflow run is cancelled before the job completes [3][2]. 2. Step Outcome and Conclusion Each step in a job has an outcome and a conclusion [1][2]: - outcome: The result of the step execution before the continue-on-error setting is applied [1][2]. - conclusion: The final result of the step after the continue-on-error setting is applied [1][2]. If a workflow is cancelled while a step is running, both the outcome and conclusion of that step will typically be marked as cancelled [1][2]. Expression Usage You can use the cancelled expression in if conditional statements to perform specific actions only when a job or step has been cancelled [5][2]. For example: - if: cancelled can be used on jobs or steps to ensure they run even when the workflow has been cancelled [5]. Important Note The term workflow_context is not a standard, top-level context in GitHub Actions expressions; documentation refers to the github context or specific step/job contexts [1][2]. When a workflow is cancelled, the system re-evaluates if conditions, sends termination signals to runners, and eventually forces termination of jobs and steps that do not exit promptly [5]. Citations:
🌐 Web query:
💡 Result: In GitHub Actions, the Citations:
🌐 Web query:
💡 Result: In GitHub Actions, steps.<step_id>.outcome and steps.<step_id>.conclusion are properties within the steps context that indicate the result of a completed step [1]. The outcome property represents the result of a completed step before any continue-on-error setting is applied [1]. Possible values for both outcome and conclusion include success, failure, cancelled, or skipped [1]. The distinction between the two is specifically relevant when continue-on-error is used: - If a step fails and continue-on-error is set to true, the outcome will be failure, but the final conclusion will be success [1]. If a step is cancelled, the outcome will be reported as cancelled [1]. The steps context is only available for steps that have an id specified and have already run [1]. Citations: Do not commit baselines after cancellation. Line [124] blocks only Guard the commit step against cancellation- if: ${{ always() && steps.record.outcome != 'skipped' && github.event_name == 'workflow_dispatch' && inputs.update-baselines }}
+ if: ${{ always() && !cancelled() && steps.record.outcome != 'skipped' && github.event_name == 'workflow_dispatch' && inputs.update-baselines }}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||
| if [ -z "$(git status --porcelain test/fixtures/screenshots)" ]; then | ||||||||||||||||||||||||||||
| echo "no baseline changes recorded - nothing to commit" | ||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||
| git config user.name "github-actions[bot]" | ||||||||||||||||||||||||||||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||||||||||||||||||||||||||||
| git add test/fixtures/screenshots/ | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: jetthoughts/jetthoughts.github.io
Length of output: 10301
🏁 Script executed:
Repository: jetthoughts/jetthoughts.github.io
Length of output: 50391
🏁 Script executed:
Repository: jetthoughts/jetthoughts.github.io
Length of output: 28945
🏁 Script executed:
Repository: jetthoughts/jetthoughts.github.io
Length of output: 11300
Key
hugo_stats.jsonby draft scope too.The current key does not include
BUILD_DRAFTS, but test builds run Hugo with--buildDrafts. If a production warm tree cache restores a stats file, the draft fixture can be served without regenerating it, which may make PurgeCSS miss draft-only classes. Add a draft-mode/cache-mode token to the key and make the visual-cache documentation match that scope.🤖 Prompt for AI Agents