From 060e4a77dc5c51967ff82c17741921ae15163cd7 Mon Sep 17 00:00:00 2001 From: Guarzo Date: Sat, 8 Aug 2026 14:42:08 -0400 Subject: [PATCH 1/2] ci: surface Ash resource-snapshot drift in the test workflow `mix ash.codegen --check` catches resource definitions that have drifted from priv/resource_snapshots. Drift is otherwise invisible until someone runs `mix ash.codegen` locally for an unrelated change and gets a surprise diff -- or worse, a generated migration that collides with a hand-written one. Advisory (continue-on-error), like the other checks in this job, and reported in the results table. --- .github/workflows/test.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ac9f87ab..c12a5664 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -72,6 +72,22 @@ jobs: fi continue-on-error: true + # Advisory, like the other checks here. Catches resource definitions that + # have drifted from priv/resource_snapshots โ€” usually after a dependency + # bump changes how a default is serialized, which is otherwise invisible + # until someone runs `mix ash.codegen` locally and gets an unrelated diff. + - name: Check Ash codegen is up to date + id: codegen + run: | + if mix ash.codegen --check; then + echo "status=โœ… Up to date" >> $GITHUB_OUTPUT + echo "count=0" >> $GITHUB_OUTPUT + else + echo "status=โŒ Pending changes" >> $GITHUB_OUTPUT + echo "count=1" >> $GITHUB_OUTPUT + fi + continue-on-error: true + - name: Compile code and capture warnings id: compile run: | @@ -279,6 +295,7 @@ jobs: | Category | Status | Count | Details | |----------|---------|-------|---------| | ๐Ÿ“ **Code Formatting** | ${{ steps.format.outputs.status }} | ${{ steps.format.outputs.count }} issues | `mix format --check-formatted` | + | ๐Ÿงฌ **Ash Codegen** | ${{ steps.codegen.outputs.status }} | ${{ steps.codegen.outputs.count }} pending | `mix ash.codegen --check` | | ๐Ÿ”จ **Compilation** | ${{ steps.compile.outputs.status }} | ${{ steps.compile.outputs.warnings }} warnings | `mix compile` | | ๐Ÿงช **Tests** | ${{ steps.tests.outputs.status }} | ${{ steps.tests.outputs.failures }}/${{ steps.tests.outputs.total }} failed | Success rate: ${{ steps.tests.outputs.success_rate }}% | | ๐Ÿ“Š **Coverage** | ${{ steps.coverage.outputs.status }} | ${{ steps.coverage.outputs.percentage }}% | `mix coveralls` | From 45c92a385c79eb760658ef5b974880cd4ef6ede5 Mon Sep 17 00:00:00 2001 From: Guarzo Date: Sat, 8 Aug 2026 17:05:42 -0400 Subject: [PATCH 2/2] review: order the codegen check after compile and surface drift Move the Ash codegen check after the compile step so a non-building branch reports a compile error rather than spurious codegen drift, and emit the drift detail into the PR comment (bounded to the last 40 lines). --- .github/workflows/test.yml | 58 +++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c12a5664..ccd19486 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -72,22 +72,6 @@ jobs: fi continue-on-error: true - # Advisory, like the other checks here. Catches resource definitions that - # have drifted from priv/resource_snapshots โ€” usually after a dependency - # bump changes how a default is serialized, which is otherwise invisible - # until someone runs `mix ash.codegen` locally and gets an unrelated diff. - - name: Check Ash codegen is up to date - id: codegen - run: | - if mix ash.codegen --check; then - echo "status=โœ… Up to date" >> $GITHUB_OUTPUT - echo "count=0" >> $GITHUB_OUTPUT - else - echo "status=โŒ Pending changes" >> $GITHUB_OUTPUT - echo "count=1" >> $GITHUB_OUTPUT - fi - continue-on-error: true - - name: Compile code and capture warnings id: compile run: | @@ -111,6 +95,42 @@ jobs: echo "EOF" >> $GITHUB_OUTPUT continue-on-error: true + # Advisory, like the other checks here. Catches resource definitions that + # have drifted from priv/resource_snapshots โ€” usually after a dependency + # bump changes how a default is serialized, which is otherwise invisible + # until someone runs `mix ash.codegen` locally and gets an unrelated diff. + # + # Runs after the compile step on purpose: `mix ash.codegen` compiles first, + # so on a branch that doesn't build it would fail here and report a + # codegen-drift verdict for what is really a compile error. + - name: Check Ash codegen is up to date + id: codegen + run: | + # Capture codegen output + if output=$(mix ash.codegen --check 2>&1); then + echo "status=โœ… Up to date" >> $GITHUB_OUTPUT + echo "count=0" >> $GITHUB_OUTPUT + echo "details=" >> $GITHUB_OUTPUT + else + echo "status=โŒ Pending changes" >> $GITHUB_OUTPUT + echo "count=1" >> $GITHUB_OUTPUT + + # Surface the drift in the PR comment; bounded so a large diff + # cannot blow out the comment body. + echo "details<> $GITHUB_OUTPUT + echo "
" >> $GITHUB_OUTPUT + echo "๐Ÿงฌ Pending Ash codegen changes" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo '```' >> $GITHUB_OUTPUT + echo "$output" | tail -n 40 >> $GITHUB_OUTPUT + echo '```' >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "Run \`mix ash.codegen \` locally and commit the result." >> $GITHUB_OUTPUT + echo "
" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + fi + continue-on-error: true + - name: Setup database run: | mix ecto.create @@ -253,6 +273,10 @@ jobs: credo_score=$(echo "scale=0; (100 - ${{ steps.credo.outputs.total_issues }} * 2)" | bc | sed 's/^-.*$/0/') dialyzer_score=$(echo "scale=0; (100 - ${{ steps.dialyzer.outputs.warnings }} * 2 - ${{ steps.dialyzer.outputs.errors }} * 10)" | bc | sed 's/^-.*$/0/') + # Note: the Ash codegen drift row is reported in the metrics table but + # deliberately left out of this score โ€” `main` is currently drifted, so + # including it would permanently depress every PR's score. Add it as a + # term once `main` is clean. overall_score=$(echo "scale=1; ($format_score + $compile_score + $test_score + $coverage_score + $credo_score + $dialyzer_score) / 6" | bc) echo "overall_score=$overall_score" >> $GITHUB_OUTPUT @@ -311,6 +335,8 @@ jobs: - **Test Coverage**: ${{ steps.coverage.outputs.percentage }}%/50% (minimum: 50%) - **Test Failures**: ${{ steps.tests.outputs.failures }}/0 (limit: 0) + ${{ steps.codegen.outputs.details }} +
๐Ÿ“ˆ Progress Toward Goals