diff --git a/.github/workflows/periphery.yml b/.github/workflows/periphery.yml index 8ce31d4..ca121d6 100644 --- a/.github/workflows/periphery.yml +++ b/.github/workflows/periphery.yml @@ -1,12 +1,20 @@ -# Weekly unused-code scan (Periphery). A copy of the suite's template; edit it there. -# Builds the package and its tests, scans with --retain-public (a kit's public API is used by the apps), and keeps one -# open issue, "Periphery weekly scan", up to date with the findings. Findings are for triage; nothing is deleted here. +# Unused-code scan (Periphery). A copy of the suite's template; edit it there. +# Weekly: builds the package and its tests, scans with --retain-public (a kit's public API is used by the apps), and keeps +# one open issue, "Periphery weekly scan", up to date with the findings. Findings are for triage; nothing is deleted here. +# On a pull request that touches Swift: the same scan without the findings .periphery-baseline.json records (triaged and +# kept) and without Codable properties (test fixtures). A finding that is left is new: it is annotated on the PR as a +# warning and the job stays green. Delete the code or, for a false positive, write the baseline again in the same PR: +# swift build --build-system native --build-tests +# periphery scan --retain-public --retain-codable-properties --skip-build \ +# --index-store-path .build/debug/index/store --write-baseline .periphery-baseline.json name: Periphery on: schedule: - cron: "17 3 * * 0" workflow_dispatch: + pull_request: + paths: ["**.swift", ".periphery-baseline.json", ".github/workflows/periphery.yml"] permissions: contents: read @@ -14,6 +22,7 @@ permissions: jobs: scan: + if: github.event_name != 'pull_request' runs-on: macos-26 timeout-minutes: 60 steps: @@ -43,3 +52,23 @@ jobs: cat periphery.csv n=$(gh issue list --state open --search "in:title \"$title\"" --json number,title -q ".[] | select(.title == \"$title\") | .number" | head -1) if [ -n "$n" ]; then gh issue edit "$n" --body-file body.md; else gh issue create --title "$title" --body-file body.md; fi + + new-findings: + name: New unused code (warning only) + if: github.event_name == 'pull_request' + runs-on: macos-26 + timeout-minutes: 30 + permissions: + contents: read + steps: + - uses: actions/checkout@v7 + - name: Install Periphery + run: brew install periphery && periphery version + - name: Build with the index store + run: swift build --build-system native --build-tests + - name: Scan against the baseline + run: | + periphery scan --retain-public --retain-codable-properties --skip-build --index-store-path .build/debug/index/store \ + --baseline .periphery-baseline.json --format github-actions --relative-results | tee periphery.txt + count=$(grep -c '^::warning' periphery.txt || true) + echo "Periphery: ${count} new finding(s) against .periphery-baseline.json" >> "$GITHUB_STEP_SUMMARY" diff --git a/.periphery-baseline.json b/.periphery-baseline.json new file mode 100644 index 0000000..52883df --- /dev/null +++ b/.periphery-baseline.json @@ -0,0 +1 @@ +{"v1":{"usrs":["param-as-load(_:as:)-s:21SpectroKitParityTests017SpectrumToolsPinsD0V4load_2asxSS_xmtKSeRzlFZ","param-method-geometry(_:_:)-s:10SpectroEDX16PooledQuantifierO8geometryys6ResultOyAA20FourDetectorGeometryVAA21QuantificationRefusalVGAA0J6MethodV_0A4Core21SpectrumImageMetadataVtFZ","param-name-make(_:_:)-s:16SpectroEELSTests13ModelFixturesO4makeyAA0C4CaseVSS_SDySSypGtKFZ","s:10SpectroEDX11FitSettingsV20defaultUpperLimitKeVSdvpZ","s:10SpectroEDX12EDSLineModelV10beamEnergySdvp","s:10SpectroEDX12EDSLineModelV11escapePeaksSbvp","s:10SpectroEDX12LineNetCountV7elementSSvp","s:10SpectroEDX14WindowConflictV11otherEnergySdvp","s:10SpectroEDX14WindowConflictV4lineSSvp","s:10SpectroEDX15ElementProposerV9ResultBox33_8776142654DD4C6484699C7265ED759FLLV6bufferSrys0E0OyAC4PassAELLVs5Error_pGSgGvp","s:10SpectroEDX16QuantElementDataO5EntryV6symbolSSvp","s:10SpectroEDX19FitRangeSensitivityV4MoveV5groupSSvp","s:10SpectroEDX20PooledQuantificationV16rangeSensitivityAA08FitRangeF0VSgvp","s:10SpectroEDX20PooledQuantificationV3RowV11weightTerms0A4Core05SigmaG0VSgvp","s:10SpectroEDX20PooledQuantificationV8fileAxis0A4Core06EnergyF0Vvp","s:11SpectroCore12PoissonMLFitO8SolutionV11kktResidualSdvp","s:11SpectroCore12PoissonMLFitO8SolutionV15clampedChannelsSivp","s:11SpectroCore12PoissonMLFitO8SolutionV8devianceSdvp","s:11SpectroCore18NormalisedQuantityV4unitSSvp","s:11SpectroCore21SpectrumImageMetadataV18partialFramePixelsSivp","s:11SpectroEELS13EELSEdgeBasisV13lowLossPixelsSivp","s:11SpectroEELS13EELSEdgeBasisV6groupsSivp","s:11SpectroEELS16EdgeCrossSectionV13beamEnergyKeVSdvp","s:11SpectroEELS22SavitzkyGolayEdgeTableV10halfLengthSivp","s:11SpectroEELS28SavitzkyGolayFirstDerivativeV15polynomialOrderSivp","s:11SpectroEELS28SavitzkyGolayFirstDerivativeV5deltaSdvp","s:16SpectroEELSTests13EELSMLLSTestsV7PlantedV7mastersSaySSGvp","s:16SpectroEELSTests14EdgeTruthTestsV3SetV6prefixSSvp","s:18SpectroTestSupport5MgRunV2lcSdvp","s:18SpectroTestSupport5MgRunV9sigmaZeroSdvp","s:21SpectroKitParityTests08MLLSPinsD0V4CaseV7mastersSaySSGvp","s:21SpectroKitParityTests09ModelPinsD0V4CaseV7mastersSaySSGvp"]}} \ No newline at end of file