-
Notifications
You must be signed in to change notification settings - Fork 81
62 lines (57 loc) · 1.96 KB
/
check-tree-shakeability.yml
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
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@v4
- name: Setup Node.js with Yarn cache
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Build artifacts
run: yarn 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: Fail if cannot tree-shake
if: ${{ steps.agadoo.outputs.status == 'not tree-shakeable' }}
run: exit 1