ferrflow 4.5.0

Universal semantic versioning for monorepos and classic repos
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_dispatch:
    inputs:
      dry_run:
        description: 'Dry run'
        type: boolean
        default: false

permissions:
  contents: read

jobs:
  test:
    name: Test
    if: github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'chore(release):')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: clippy, rustfmt
      - uses: Swatinem/rust-cache@v2
      - name: Format check
        run: cargo fmt --check
      - name: Clippy
        run: cargo clippy -- -D warnings
        env:
          FERRFLOW_HMAC_SECRET: ${{ secrets.FERRFLOW_HMAC_SECRET }}
      - name: Tests
        run: cargo test
        env:
          FERRFLOW_HMAC_SECRET: ${{ secrets.FERRFLOW_HMAC_SECRET }}

  build:
    name: Build Release Binary
    needs: test
    if: github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'chore(release):')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@nightly
      - uses: Swatinem/rust-cache@v2
      - name: Build ferrflow
        run: cargo build --release
        env:
          FERRFLOW_HMAC_SECRET: ${{ secrets.FERRFLOW_HMAC_SECRET }}
      - name: Upload binary
        uses: actions/upload-artifact@v7
        with:
          name: ferrflow-binary
          path: target/release/ferrflow
          retention-days: 1

  coverage:
    name: Coverage
    if: github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'chore(release):')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@nightly
      - uses: Swatinem/rust-cache@v2
      - name: Install cargo-tarpaulin
        run: cargo install cargo-tarpaulin
      - name: Generate coverage
        run: cargo tarpaulin --out xml --skip-clean
        env:
          FERRFLOW_HMAC_SECRET: ${{ secrets.FERRFLOW_HMAC_SECRET }}
      - uses: codecov/codecov-action@v6
        with:
          files: cobertura.xml
          token: ${{ secrets.CODECOV_TOKEN }}
          fail_ci_if_error: false

  fixture-generate:
    name: Generate Fixtures
    needs: test
    if: github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'chore(release):')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      - name: Cache generated fixtures
        id: fixture-cache
        uses: actions/cache@v5
        with:
          path: fixtures-generated
          key: fixtures-${{ hashFiles('tests/fixtures/definitions/**') }}

      - name: Generate fixtures
        if: steps.fixture-cache.outputs.cache-hit != 'true'
        uses: FerrLabs/Fixtures@v1
        with:
          definitions: tests/fixtures/definitions

      - name: Resolve generated path
        id: path
        run: |
          if [ -d "fixtures-generated" ]; then
            echo "dir=fixtures-generated" >> "$GITHUB_OUTPUT"
          else
            for d in /tmp/tmp.*/generated; do
              if [ -d "$d" ]; then
                cp -r "$d" fixtures-generated
                echo "dir=fixtures-generated" >> "$GITHUB_OUTPUT"
                break
              fi
            done
          fi

      - name: Upload generated fixtures
        uses: actions/upload-artifact@v7
        with:
          name: fixtures-generated
          path: fixtures-generated/
          include-hidden-files: true
          retention-days: 1

  fixture-monorepo:
    name: Fixtures — Monorepo
    needs: [build, fixture-generate]
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v6
      - uses: actions/download-artifact@v8
        with:
          name: ferrflow-binary
          path: bin/
      - uses: actions/download-artifact@v8
        with:
          name: fixtures-generated
          path: fixtures-generated/
      - name: Run monorepo fixture tests
        env:
          FERRFLOW_BIN: ./bin/ferrflow
          DIFF_DIR: fixture-diffs
        run: |
          chmod +x ./bin/ferrflow
          mkdir -p filtered-fixtures
          for d in fixtures-generated/monorepo-*; do
            [ -d "$d" ] && cp -r "$d" filtered-fixtures/
          done
          bash tests/fixtures/run-tests.sh filtered-fixtures

      - name: Upload snapshot diffs
        if: failure()
        uses: actions/upload-artifact@v7
        with:
          name: fixture-diffs-monorepo
          path: fixture-diffs/
          retention-days: 7
          if-no-files-found: ignore

  fixture-single:
    name: Fixtures — Single Package
    needs: [build, fixture-generate]
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v6
      - uses: actions/download-artifact@v8
        with:
          name: ferrflow-binary
          path: bin/
      - uses: actions/download-artifact@v8
        with:
          name: fixtures-generated
          path: fixtures-generated/
      - name: Run single-package fixture tests
        env:
          FERRFLOW_BIN: ./bin/ferrflow
          DIFF_DIR: fixture-diffs
        run: |
          chmod +x ./bin/ferrflow
          mkdir -p filtered-fixtures
          for d in fixtures-generated/single-* fixtures-generated/multiple-* fixtures-generated/no-tags-initial-* fixtures-generated/no-versioned-* fixtures-generated/version-*; do
            [ -d "$d" ] && cp -r "$d" filtered-fixtures/
          done
          bash tests/fixtures/run-tests.sh filtered-fixtures

      - name: Upload snapshot diffs
        if: failure()
        uses: actions/upload-artifact@v7
        with:
          name: fixture-diffs-single
          path: fixture-diffs/
          retention-days: 7
          if-no-files-found: ignore

  fixture-config:
    name: Fixtures — Config & Formats
    needs: [build, fixture-generate]
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v6
      - uses: actions/download-artifact@v8
        with:
          name: ferrflow-binary
          path: bin/
      - uses: actions/download-artifact@v8
        with:
          name: fixtures-generated
          path: fixtures-generated/
      - name: Run config fixture tests
        env:
          FERRFLOW_BIN: ./bin/ferrflow
          DIFF_DIR: fixture-diffs
        run: |
          chmod +x ./bin/ferrflow
          mkdir -p filtered-fixtures
          for d in fixtures-generated/config-* fixtures-generated/format-* fixtures-generated/multi-versioned-*; do
            [ -d "$d" ] && cp -r "$d" filtered-fixtures/
          done
          bash tests/fixtures/run-tests.sh filtered-fixtures

      - name: Upload snapshot diffs
        if: failure()
        uses: actions/upload-artifact@v7
        with:
          name: fixture-diffs-config
          path: fixture-diffs/
          retention-days: 7
          if-no-files-found: ignore

  fixture-advanced:
    name: Fixtures — Advanced Features
    needs: [build, fixture-generate]
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v6
      - uses: actions/download-artifact@v8
        with:
          name: ferrflow-binary
          path: bin/
      - uses: actions/download-artifact@v8
        with:
          name: fixtures-generated
          path: fixtures-generated/
      - name: Run advanced fixture tests
        env:
          FERRFLOW_BIN: ./bin/ferrflow
          DIFF_DIR: fixture-diffs
        run: |
          chmod +x ./bin/ferrflow
          mkdir -p filtered-fixtures
          for d in fixtures-generated/prerelease-* fixtures-generated/hooks-* fixtures-generated/floating-* \
                   fixtures-generated/tag-* fixtures-generated/changelog-* fixtures-generated/versioning-* \
                   fixtures-generated/orphaned-* fixtures-generated/recover-* fixtures-generated/release-* \
                   fixtures-generated/head-* fixtures-generated/merge-* fixtures-generated/commit-* \
                   fixtures-generated/skip-* fixtures-generated/no-tags-monorepo-*; do
            [ -d "$d" ] && cp -r "$d" filtered-fixtures/
          done
          bash tests/fixtures/run-tests.sh filtered-fixtures

      - name: Upload snapshot diffs
        if: failure()
        uses: actions/upload-artifact@v7
        with:
          name: fixture-diffs-advanced
          path: fixture-diffs/
          retention-days: 7
          if-no-files-found: ignore

  micro-bench:
    name: Micro Benchmark - ${{ matrix.group }}
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    continue-on-error: true
    strategy:
      fail-fast: false
      matrix:
        group:
          - commit_parsing
          - changelog
          - version_files
          - config_loading
          - git_commits
          - git_find_tag
          - git_collect_tags
          - git_changed_files
          - git_changed_since_tag
          - validate
          - full_check_flow
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0
      - uses: dtolnay/rust-toolchain@nightly
      - uses: Swatinem/rust-cache@v2
      - uses: FerrLabs/Benchmarks@v3
        with:
          type: micro
          group-filter: ${{ matrix.group }}
          definitions: benchmarks/fixtures/definitions
          ferrflow-token: ${{ secrets.GITHUB_TOKEN }}
          skip-competitors: true
          comment-on-pr: false
        env:
          FERRFLOW_HMAC_SECRET: ${{ secrets.FERRFLOW_HMAC_SECRET }}
      - uses: actions/upload-artifact@v7
        with:
          name: micro-partial-${{ matrix.group }}
          path: output.txt
          retention-days: 1

  micro-bench-aggregate:
    name: Micro Benchmark (aggregate)
    needs: micro-bench
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: actions/checkout@v6
      - uses: actions/download-artifact@v8
        with:
          pattern: micro-partial-*
          merge-multiple: true
          path: shards/
      - name: Merge partials
        run: |
          cat shards/* > output.txt
          echo "Merged bench rows: $(wc -l < output.txt)"
      - name: Find baseline artifact from main
        id: find-baseline
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          RUN_ID=$(gh api "repos/${{ github.repository }}/actions/artifacts?name=criterion-baseline&per_page=1" \
            --jq '.artifacts[0].workflow_run.id // empty')
          echo "run_id=${RUN_ID}" >> "$GITHUB_OUTPUT"
        continue-on-error: true
      - name: Download baseline
        if: steps.find-baseline.outputs.run_id
        uses: actions/download-artifact@v8
        with:
          name: criterion-baseline
          path: baseline/
          run-id: ${{ steps.find-baseline.outputs.run_id }}
          github-token: ${{ secrets.GITHUB_TOKEN }}
        continue-on-error: true
      - name: Ensure baseline file
        run: |
          if [[ ! -f baseline/benchmark-data.json ]]; then
            mkdir -p baseline
            echo '[]' > baseline/benchmark-data.json
          fi
      - uses: benchmark-action/github-action-benchmark@v1
        with:
          tool: cargo
          output-file-path: output.txt
          external-data-json-path: baseline/benchmark-data.json
          comment-on-alert: true
          alert-threshold: '120%'
          fail-on-alert: false
          github-token: ${{ secrets.GITHUB_TOKEN }}
          comment-always: true

  benchmark:
    name: Benchmark
    needs: test
    runs-on: ubuntu-latest
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@nightly
      - uses: Swatinem/rust-cache@v2
      - uses: actions/setup-node@v6
        with:
          node-version: '24'
      - uses: FerrLabs/Benchmarks@v3
        with:
          type: full
          definitions: benchmarks/fixtures/definitions
          ferrflow-token: ${{ secrets.GITHUB_TOKEN }}
          skip-competitors: true
        env:
          FERRFLOW_HMAC_SECRET: ${{ secrets.FERRFLOW_HMAC_SECRET }}

  release:
    name: Release
    needs: [test, fixture-monorepo, fixture-single, fixture-config, fixture-advanced, benchmark]
    runs-on: ubuntu-latest
    concurrency:
      group: release-${{ github.workflow }}-${{ github.ref }}
      cancel-in-progress: false
    if: |
      always() &&
      needs.test.result == 'success' &&
      needs.fixture-monorepo.result == 'success' &&
      needs.fixture-single.result == 'success' &&
      needs.fixture-config.result == 'success' &&
      needs.fixture-advanced.result == 'success' &&
      (needs.benchmark.result == 'success' || needs.benchmark.result == 'skipped') &&
      (
        (github.event_name == 'push' && github.ref == 'refs/heads/main') ||
        github.event_name == 'workflow_dispatch'
      )
    permissions:
      contents: write
      id-token: write
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0
          # Don't bake GITHUB_TOKEN into the git remote — ferrflow's OIDC
          # exchange yields an App installation token that authenticates as
          # ferrflow[bot]. Without this, every git push silently reverts
          # to GITHUB_TOKEN (i.e. github-actions[bot]) which isn't in the
          # branch-rule bypass list and can't push to main.
          persist-credentials: false
      - uses: dtolnay/rust-toolchain@nightly
      - uses: Swatinem/rust-cache@v2
      - name: Build ferrflow
        run: cargo build --release
        env:
          FERRFLOW_HMAC_SECRET: ${{ secrets.FERRFLOW_HMAC_SECRET }}
      - name: Configure git identity for ferrflow[bot]
        run: |
          git config user.name "ferrflow[bot]"
          git config user.email "278126555+ferrflow[bot]@users.noreply.github.com"
      - name: Run ferrflow release
        run: ./target/release/ferrflow ${{ inputs.dry_run == 'true' && '--dry-run' || '' }} release --draft
        env:
          FERRFLOW_BOT: "true"
      - name: Download benchmark summary
        if: needs.benchmark.result == 'success'
        uses: actions/download-artifact@v8
        with:
          name: benchmark-release-summary
          path: benchmark-summary/
        continue-on-error: true
      - name: Append benchmark results to draft release
        if: needs.benchmark.result == 'success'
        run: |
          BENCH_FILE="benchmark-summary/release-summary.md"
          if [[ ! -f "$BENCH_FILE" ]]; then
            echo "No benchmark summary found, skipping"
            exit 0
          fi
          TAG=$(./target/release/ferrflow tag --json 2>/dev/null | jq -r '.tag // empty')
          if [[ -z "$TAG" ]]; then
            echo "No tag found, skipping"
            exit 0
          fi
          CURRENT_BODY=$(gh release view "$TAG" --json body --jq '.body' 2>/dev/null || echo "")
          BENCH=$(cat "$BENCH_FILE")
          # Remove existing Performance section to avoid duplicates
          CLEAN_BODY=$(echo "$CURRENT_BODY" | sed '/^## Performance$/,$d')
          printf -v NEW_BODY '%s\n\n%s' "$CLEAN_BODY" "$BENCH"
          gh release edit "$TAG" --notes "$NEW_BODY"
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}