-
Notifications
You must be signed in to change notification settings - Fork 23
154 lines (142 loc) · 5.91 KB
/
pr.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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: PR
on: pull_request
jobs:
# TODO: remove after https://github.com/pixiebrix/pixiebrix-extension/issues/6526
strictNullMessenger:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: npm
- run: npm ci
- id: tsc
run: |
npm run build:strictNullChecks -- --explainFiles > LOG || {
if grep -q "keyof MessengerMethods" LOG; then
grep -Pazo "\nsrc/(background|contentScript)/messenger/api.ts(\n .+)+" LOG > REASON
cat REASON
{
echo 'reason<<EOF'
# Drop null character at the end caused by -z
cat REASON | sed 's/.$/\n/'
echo 'EOF'
} >> "$GITHUB_OUTPUT"
exit 1 # Make the job fail for visibility https://github.com/pixiebrix/pixiebrix-extension/pull/7700#issuecomment-1969527384
fi
}
- name: Hide previous comment if resolved
uses: marocchino/sticky-pull-request-comment@v2
with:
header: strictNullChecksMessenger # Unique identifier for the comment
hide: true
- name: Add comment with more info if failed
if: failure()
uses: marocchino/sticky-pull-request-comment@v2
with:
header: strictNullChecksMessenger # Unique identifier for the comment
recreate: true
message: |
It looks like one of the non-strict `messenger/api.ts` files ended up being imported by one of the strict files. Don't be fooled by "just a few type errors", this hides hundreds of type errors.
See details and solutions in: https://github.com/pixiebrix/pixiebrix-extension/issues/6526#issuecomment-1926391817
There might be further information about how the non-strict Messenger files are ending up in the strict config:
```
${{ steps.tsc.outputs.reason }}
```
strictNullChecks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get list of changed files
id: changedfiles
uses: tj-actions/changed-files@v44
with:
json: "true"
files: "src/**/*.{ts,tsx}"
- name: List all changed files
run: echo '${{ steps.changed-files.outputs.all_changed_files }}'
- name: Verify that new files in this PR appear in tsconfig.strictNullChecks.json
uses: actions/github-script@v7
with:
script: |
const tsconfigJson = require('./src/tsconfig.strictNullChecks.json');
const newFiles = JSON.parse('${{ steps.changedfiles.outputs.added_files }}')
if (newFiles.length === 0) {
console.log('No new files found');
return;
}
for (const newFile of newFiles) {
if (tsconfigJson.files.includes(newFile.replace('src', '.'))) {
console.log(`${newFile} is in tsconfig.strictNullChecks.json`);
continue;
}
core.error(`${newFile} was not found in tsconfig.strictNullChecks.json`, {
title: 'strictNullChecks',
file: newFile,
});
process.exitCode = 1;
}
lockfile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: package-lock.json
- name: Detect changes
id: stats
run: |
git fetch origin ${{ github.base_ref }}
STAT="$(git diff --numstat origin/${{ github.base_ref }}..HEAD -- package-lock.json)"
DELETED=$(echo $STAT | cut -d " " -f 1)
ADDED=$(echo $STAT | cut -d " " -f 2)
TOTAL_CHANGES=$((DELETED + ADDED))
echo "STAT=$STAT"
echo "DELETED=$DELETED"
echo "ADDED=$ADDED"
echo "TOTAL_CHANGES=$TOTAL_CHANGES"
echo "changes=$TOTAL_CHANGES" >> $GITHUB_OUTPUT
- if: steps.stats.outputs.changes <= 1000
uses: marocchino/sticky-pull-request-comment@v2
with:
header: lockfile # Unique identifier for the comment
hide: true
- if: steps.stats.outputs.changes > 1000
uses: marocchino/sticky-pull-request-comment@v2
with:
header: lockfile # Unique identifier for the comment
recreate: true
message: |
## ⚠️ Large diff for package-lock.json
There are ${{ steps.stats.outputs.changes }} line changes in package-lock.json. This should not happen unless you're updating a lot of dependencies at once. Regenerating the lockfile should not be necessary.
If you're seeing Vercel deployment failures, this is likely the cause.
Run these commands to reset these changes:
```sh
git checkout origin/main -- package-lock.json
npm install
```
You might want to click on "Update branch" first so that the results are accurate.
- if: steps.stats.outputs.changes > 1000
run: exit 1
vendors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get list of changed vendored files
id: changedfiles
uses: tj-actions/changed-files@v44
with:
files: "src/vendors/**/*.*"
- name: Leave annotations
if: steps.changedfiles.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.changedfiles.outputs.all_changed_files }}
run: |
for FILE in ${ALL_CHANGED_FILES}; do
echo "::warning file=$FILE,line=0::Vendored files should rarely change: https://github.com/pixiebrix/pixiebrix-extension/pull/7941"
done
exit 1 # Make the job fail for visibility https://github.com/pixiebrix/pixiebrix-extension/pull/7941#discussion_r1528517121