-
-
Notifications
You must be signed in to change notification settings - Fork 716
132 lines (117 loc) · 4.84 KB
/
fresh-install-tests.yml
File metadata and controls
132 lines (117 loc) · 4.84 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Fresh Install Tests
# Periodically tests BlockNote with the latest versions of its production
# dependencies (within declared semver ranges). This catches breakage when a
# new release of a dep like @tiptap/* or prosemirror-* ships and conflicts
# with BlockNote's declared ranges — the kind of failure a user would hit when
# running `npm install @blocknote/react` in a fresh project.
#
# Only production dependencies of published (non-private) packages are updated.
# DevDependencies (vitest, vite, typescript, etc.) stay pinned to the lockfile,
# so test tooling churn doesn't cause false positives.
on:
push:
branches:
- package-upgrades
schedule:
- cron: "0 2 * * *" # Daily at 02:00 UTC
workflow_dispatch: # Allow manual runs
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
pnpm_config_store_dir: ./node_modules/.pnpm-store
jobs:
fresh-install-unit-tests:
name: Unit Tests (Fresh Dep Resolution)
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- id: checkout
uses: actions/checkout@v6
- id: install_pnpm
name: Install pnpm
uses: pnpm/action-setup@v5
- id: setup_node
uses: actions/setup-node@v6
with:
node-version-file: ".nvmrc"
# Intentionally no pnpm cache — we want fresh prod dep resolution
- id: install_dependencies
name: Install dependencies
run: pnpm install
- id: update_prod_deps
name: Update prod deps of published packages
# Resolves production dependencies of every published (non-private)
# workspace package to the latest version within their declared semver
# ranges. This simulates what a user gets when running
# `npm install @blocknote/react` in a fresh project.
# DevDependencies are left at their lockfile versions.
run: |
FILTERS=$(node -e "
const fs = require('fs');
const path = require('path');
fs.readdirSync('packages').forEach(dir => {
try {
const pkg = JSON.parse(fs.readFileSync(path.join('packages', dir, 'package.json'), 'utf8'));
if (!pkg.private && pkg.name) process.stdout.write('--filter ' + pkg.name + ' ');
} catch {}
});
")
echo "Updating prod deps for: $FILTERS"
eval pnpm update --prod $FILTERS
- id: build_packages
name: Build packages
run: pnpm run build
env:
NX_SKIP_NX_CACHE: "true"
- id: run_unit_tests
name: Run unit tests
run: pnpm run test
env:
NX_SKIP_NX_CACHE: "true"
- name: Notify Slack on workflow failure
if: ${{ failure() }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
REPOSITORY: ${{ github.repository }}
WORKFLOW: ${{ github.workflow }}
RUN_ID: ${{ github.run_id }}
RUN_NUMBER: ${{ github.run_number }}
RUN_ATTEMPT: ${{ github.run_attempt }}
BRANCH: ${{ github.ref_name }}
run: |
if [ -z "$SLACK_WEBHOOK_URL" ]; then
echo "SLACK_WEBHOOK_URL is not configured; skipping Slack notification."
exit 0
fi
failed_step="Unknown step"
if [ "${{ steps.checkout.outcome }}" = "failure" ]; then
failed_step="Checkout repository"
elif [ "${{ steps.install_pnpm.outcome }}" = "failure" ]; then
failed_step="Install pnpm"
elif [ "${{ steps.setup_node.outcome }}" = "failure" ]; then
failed_step="Setup Node.js"
elif [ "${{ steps.install_dependencies.outcome }}" = "failure" ]; then
failed_step="Install dependencies"
elif [ "${{ steps.update_prod_deps.outcome }}" = "failure" ]; then
failed_step="Update prod deps of published packages"
elif [ "${{ steps.build_packages.outcome }}" = "failure" ]; then
failed_step="Build packages"
elif [ "${{ steps.run_unit_tests.outcome }}" = "failure" ]; then
failed_step="Run unit tests"
fi
run_url="https://github.com/${REPOSITORY}/actions/runs/${RUN_ID}"
message=$(printf '%s\n%s\n%s\n%s' \
":warning: Fresh Install Tests failed in *${REPOSITORY}* on branch *${BRANCH}*." \
"*Workflow:* ${WORKFLOW}" \
"*Run:* <${run_url}|#${RUN_NUMBER} (attempt ${RUN_ATTEMPT})>" \
"*Failed step:* ${failed_step}")
payload=$(jq --compact-output --null-input --arg text "$message" '{text: $text}')
curl -sS -X POST \
--fail \
--retry 4 \
--retry-all-errors \
--retry-max-time 60 \
--connect-timeout 10 \
--max-time 30 \
-H "Content-type: application/json" \
--data "$payload" \
"$SLACK_WEBHOOK_URL"