Prioritize Unused Chromium Includes #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Prioritize Unused Chromium Includes | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 18 * * *' | |
| permissions: {} | |
| jobs: | |
| prioritize_unused_chromium_includes: | |
| name: Prioritize Unused Chromium Includes | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| repository: dsanders11/chromium-include-cleanup | |
| - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | |
| with: | |
| python-version: '3.12' | |
| cache: 'pip' | |
| - name: Install Dependencies | |
| run: pip install -r requirements.txt | |
| - name: Download Unused Includes Output | |
| run: | | |
| curl https://gist.githubusercontent.com/dsanders11/ccf3505dcbb35492cbadade1ceb663b6/raw/e626ce38df7f212d17b8dccce4caa2551a576fdb/unused-includes.csv > unused-includes.csv | |
| - name: Download Include Analysis Output | |
| run: | | |
| curl https://commondatastorage.googleapis.com/chromium-browser-clang/include-analysis.js > include-analysis.js | |
| - name: Find Priority Unused Includes | |
| run: | | |
| python set_edge_weights.py unused-includes.csv include-analysis.js --config chromium --filter-third-party > weighted-unused-includes.csv | |
| python filter_include_changes.py weighted-unused-includes.csv --config chromium --weight-threshold 15000000 > priority-unused-includes.csv | |
| - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: weighted-unused-includes | |
| path: weighted-unused-includes.csv | |
| - run: npm install @actions/cache | |
| - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
| with: | |
| script: | | |
| const fs = require('node:fs'); | |
| const cache = require('@actions/cache'); | |
| const data = fs.readFileSync('./priority-unused-includes.csv', 'utf8').trim(); | |
| const unusedIncludes = await Promise.all(data.split('\n').map(async (line) => { | |
| const [,, filename, include, added_size] = line.trim().split(','); | |
| let status = ':eyes: New'; | |
| // Check if this is known from a previous run | |
| const cacheKey = `prioritize-unused-chromium-${filename}-${include}`; | |
| const cacheHit = | |
| (await cache.restoreCache(['/dev/null'], cacheKey, undefined, { | |
| lookupOnly: true, | |
| })) !== undefined; | |
| if (cacheHit) { | |
| status = ''; // It's somewhat nicer visually to leave this blank | |
| } else { | |
| // Create a cache entry (only the name matters) to keep track of | |
| // includes we've seen from previous runs to mark them as stale | |
| await cache.saveCache(['/dev/null'], cacheKey); | |
| } | |
| return [`${filename} --> ${include}`, parseInt(added_size), status]; | |
| })); | |
| if (unusedIncludes.length > 0) { | |
| core.summary.addHeading('✂️ Priority Unused Chromium Includes'); | |
| core.summary.addTable([ | |
| [ | |
| { data: 'Include Edge', header: true }, | |
| { data: 'Added Size', header: true }, | |
| { data: 'Status', header: true }, | |
| ], | |
| // Sort by added size, then convert it back to string or it won't render | |
| ...unusedIncludes | |
| .sort((a, b) => b[1] - a[1]) | |
| .map(([edge, added_size, status]) => [edge, added_size.toLocaleString(), status]), | |
| ]); | |
| } else { | |
| core.summary.addRaw('🎉 No priority unused Chromium includes'); | |
| } | |
| await core.summary.write(); |