Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add treeshake check #96

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/treeshake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Check tree-shakeability
on: [ pull_request ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
pull-requests: write
concurrency: ci-treeshake-${{ github.ref }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 16

- name: Installing dependencies
run: npm ci

- name: Build artifacts
run: npm run build

- name: Run agadoo
id: agadoo
run: |
# Run Agadoo and store the output for further usage
# We store the process stdout and stderr to tmp files
STDOUT_F=$(mktemp)
STDERR_F=$(mktemp)
# Run agadoo and capture errors without breaking the workflow
$(npx agadoo 2> $STDERR_F > $STDOUT_F) && true
# Infer the result from the first word of the last line
RET="$(cat $STDERR_F | tail -1 | cut -d' ' -f 1)"
# In order to be used in GH actions `echo "::set-output` the
# multi-line output must be escaped.
STDOUT="$(cat $STDOUT_F)"
STDOUT="${STDOUT//'%'/%25}"
STDOUT="${STDOUT//$'\n'/%0A}"
STDOUT="${STDOUT//$'\r'/%0D}"
STDERR="$(cat $STDERR_F)"
STDERR="${STDERR//'%'/%25}"
STDERR="${STDERR//$'\n'/%0A}"
STDERR="${STDERR//$'\r'/%0D}"
echo "::set-output name=stdout::$STDOUT"
echo "::set-output name=stderr::$STDERR"
if [[ $RET == 'Success!' ]]; then
echo "::set-output name=status::tree-shakeable"
else
echo "::set-output name=status::not tree-shakeable"
fi
echo "$STDOUT"
echo ""
echo "$STDERR"
# Clean-up
rm $STDOUT_F
rm $STDERR_F
exit 0
- name: comment PR
uses: unsplash/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: |
**Check tree-shakeability** for ${{ github.sha }}: ${{ steps.agadoo.outputs.status == 'tree-shakeable' && ':deciduous_tree:' || ':x:' }} ${{ steps.agadoo.outputs.status }}
<details>
<summary>Agadoo stdout</summary>
```javascript
${{ steps.agadoo.outputs.stdout }}
```
</details>
<details>
<summary>Agadoo stderr</summary>
```javascript
${{ steps.agadoo.outputs.stderr }}
```
</details>
check_for_duplicate_msg: false
delete_prev_regex_msg: ^\*\*Check tree-shakeability\*\*
- name: Fail if cannot tree-shake
if: ${{ steps.agadoo.outputs.status == 'not tree-shakeable' }}
run: exit 1