Skip to content

Commit 19048fd

Browse files
authored
Actions: Add checks to ensure clean extension build files
1 parent 38a05a0 commit 19048fd

2 files changed

Lines changed: 43 additions & 5 deletions

File tree

.github/workflows/node.js.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,48 @@ jobs:
3434
npm run env | grep npm_package_version >> $GITHUB_ENV
3535
- run: |
3636
echo Workflow triggered by event ${{ github.event_name }}
37+
- name: Install grep and find
38+
run: sudo apt-get install grep findutils
39+
40+
- name: Create non-minified js files
41+
run: npm run build:js -- --environment NO_MINIFY
42+
env:
43+
YT_API_KEY: ${{ secrets.YOUTUBE_KEY }}
44+
- name: Verify no debug artifacts
45+
run: |
46+
dev=$(grep --color=always "devClone\|devExport\|(()=>{})" $(find extension-dist -name "*.js") || echo "")
47+
if [ -n "$dev" ]; then
48+
echo "::group::Invalid statements"
49+
echo "$dev"
50+
echo "::endgroup::"
51+
echo "::error ::Found statements that shouldn't be in the production build!"
52+
exit 1
53+
fi
54+
shell: bash
3755

3856
- name: Build
3957
run: npm run build:all # does not run tests
4058
env:
4159
YT_API_KEY: ${{ secrets.YOUTUBE_KEY }}
60+
61+
- name: Verify directory structure
62+
run: |
63+
locales=$(find extension-dist/_locales -not -name "*.json" -type f)
64+
scripts=$(find extension-dist/scripts -not -name "*.js" -type f)
65+
styles=$(find extension-dist/styles -not -name "*.css" -type f)
66+
if [ -n "$locales" ] || [ -n "$scripts" ] || [ -n "$styles" ]; then
67+
echo "::group::Files found"
68+
echo -e "\nIn _locales"
69+
echo "$locales"
70+
echo -e "\nIn scripts"
71+
echo "$scripts"
72+
echo -e "\nIn styles"
73+
echo "$styles"
74+
echo "::endgroup::"
75+
echo "::error ::Found files that do not belong!"
76+
exit 1
77+
fi
78+
shell: bash
4279

4380
- name: Archive extension
4481
uses: actions/upload-artifact@v2

rollup.config.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ const question = q => new Promise(resolve => readline.question(q, answer => reso
4040
const jsreplace = (dev = !process.env.BUILD) => ({
4141
'__YT_API_KEY__': JSON.stringify(process.env.YT_API_KEY),
4242
'__DEV__': JSON.stringify(dev),
43-
'console.dev.log': dev ? 'console.log' : 'void',
44-
'console.dev.debug': dev ? 'console.debug' : 'void',
45-
'console.dev.warn': dev ? 'console.warn' : 'void',
46-
'console.dev.error': dev ? 'console.error' : 'void',
43+
'console.dev.log': dev ? 'console.log' : '(()=>{})',
44+
'console.dev.debug': dev ? 'console.debug' : '(()=>{})',
45+
'console.dev.warn': dev ? 'console.warn' : '(()=>{})',
46+
'console.dev.error': dev ? 'console.error' : '(()=>{})',
4747
'preventAssignment': true,
4848
});
4949
const jsplugins = () => [
@@ -206,7 +206,8 @@ function remove() {
206206
if (!bundle[prop].code) continue;
207207
if (bundle[prop].code === '\n' ||
208208
bundle[prop].code.trim() === 'var undefined$1 = undefined;\n\nexport default undefined$1;' ||
209-
bundle[prop].code.trim() === 'var undefined$1 = undefined;\n\nexport { undefined$1 as default };')
209+
bundle[prop].code.trim() === 'var undefined$1 = undefined;\n\nexport { undefined$1 as default };'
210+
)
210211
delete bundle[prop];
211212
}
212213
},

0 commit comments

Comments
 (0)