Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions .github/scripts/__tests__/validate-test-map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ describe('validate-test-map', () => {
expect(stdout).toContain('::error file=app/nonexistent-global.txt::Stale global');
});

// runAllWhenChanged entries may be globs — sniffler matches them as patterns,
// so an existsSync check would wrongly condemn every glob as stale.
it('accepts a runAllWhenChanged glob that matches at least one file', () => {
const { stdout } = runValidator('stale-global');
expect(stdout).not.toContain('file=patches/**');
});

it('flags a runAllWhenChanged glob that matches nothing on disk', () => {
const { status, stdout } = runValidator('stale-global');
expect(status).toBe(1);
expect(stdout).toContain('::error file=native/**::Stale global');
});

it('flags a decoupled gap: a saga file anchored in neither a dependsOn glob nor runAllWhenChanged', () => {
const { status, stdout } = runValidator('decoupled-gap');
expect(status).toBe(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tests": {
"runAllWhenChanged": ["app/nonexistent-global.txt"]
"runAllWhenChanged": ["app/nonexistent-global.txt", "patches/**", "native/**"]
}
}
Comment thread
diegolmello marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
placeholder
8 changes: 6 additions & 2 deletions .github/scripts/validate-test-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ for (const dir of uncovered) {
warnCount++;
}

// Stale runAllWhenChanged paths: missing on disk.
// Stale runAllWhenChanged paths: missing on disk. Entries may be globs (sniffler
// matches them as patterns), so a glob is fresh when it matches at least one file.
const runAll = config.tests?.runAllWhenChanged || [];
const staleGlobals = runAll.filter(p => !fs.existsSync(path.join(ROOT, p)));
const isGlob = p => /[*?[\]{}]/.test(p);
const staleGlobals = runAll.filter(p =>
isGlob(p) ? fg.sync(p, { cwd: ROOT, dot: true }).length === 0 : !fs.existsSync(path.join(ROOT, p))
);
for (const p of staleGlobals) {
ann('error', p, `Stale global: "${p}" in runAllWhenChanged does not exist — will silently never fire.`);
errorCount++;
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
permissions:
contents: read
pull-requests: read
runs-on: ubuntu-latest
outputs:
shards: ${{ steps.select.outputs.shards }}
Expand All @@ -94,10 +95,26 @@ jobs:
id: full
run: bash .github/scripts/assert-maestro-shards.sh

# Read labels live rather than from the event payload: the payload is frozen
# at push time (a label added afterwards, or a re-run, would never see it),
# and `contains()` over an array is an exact element match — it would miss
# the decorated label name ("💎 release").
- name: Detect release label
id: label
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
if gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name' | grep -qi 'release'; then
Comment thread
diegolmello marked this conversation as resolved.
echo "release=true" >>"$GITHUB_OUTPUT"
else
echo "release=false" >>"$GITHUB_OUTPUT"
fi
Comment thread
coderabbitai[bot] marked this conversation as resolved.

- name: Select impacted shards
id: select
env:
IS_RELEASE_LANE: ${{ github.event.pull_request.base.ref == 'master' || contains(github.event.pull_request.labels.*.name, 'release') }}
IS_RELEASE_LANE: ${{ github.event.pull_request.base.ref == 'master' || steps.label.outputs.release == 'true' }}
BASE_REF: ${{ github.event.pull_request.base.ref }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
FULL_SHARDS: ${{ steps.full.outputs.shards }}
Expand Down
12 changes: 12 additions & 0 deletions .sniffler/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
"runAllWhenChanged": [
"pnpm-lock.yaml",
"package.json",
"index.js",
"app.json",
"babel.config.js",
"metro.config.js",
"react-native.config.js",
"patches/**",
"android/**",
"ios/**",
".maestro/**",
".sniffler/**",
".github/workflows/**",
".github/scripts/**",
"app/index.tsx",
"app/lib/notifications/push.ts",
"app/lib/notifications/index.ts",
Expand Down
Loading