Skip to content
Open
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
67 changes: 67 additions & 0 deletions .buildkite/commands/run-unit-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash -eu

# Runs unit tests and generates a coverage report that's displayed in the buildkite UI

if [ "$BUILDKITE_PULL_REQUEST" != "false" ]; then
echo "--- :git: Getting changed files"
CHANGED_FILES=$(git diff --name-only origin/$BUILDKITE_PULL_REQUEST_BASE_BRANCH...HEAD | grep -E '\.(ts|tsx)$' | grep -v 'node_modules' || true)
echo "Changed files:"
echo "$CHANGED_FILES"

if [ -n "$CHANGED_FILES" ]; then
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

echo "--- :git: Getting base branch coverage"
git checkout origin/$BUILDKITE_PULL_REQUEST_BASE_BRANCH
npm test -- --coverage --coverageReporters="json-summary"
cp coverage/coverage-summary.json base-coverage-summary.json

git checkout $CURRENT_BRANCH
fi
fi

echo "--- :npm: Run Unit Tests"
npm test -- --coverage --coverageReporters="json-summary"

if [ "$BUILDKITE_PULL_REQUEST" != "false" ] && [ -n "$CHANGED_FILES" ]; then
echo "--- :memo: Generating coverage report"

echo "### Coverage for Changed Files" > coverage-report.md
echo "" >> coverage-report.md
echo "| File | Current | Previous | Change |" >> coverage-report.md
echo "|------|---------|----------|--------|" >> coverage-report.md

for FILE in $CHANGED_FILES; do
# Skip files that don't have coverage data
if ! jq -e ".[\"$PWD/$FILE\"]" coverage/coverage-summary.json > /dev/null 2>&1; then
echo "| \`$FILE\` | No data | - | - |" >> coverage-report.md
continue
fi

# Get current file coverage
CURRENT_FILE_COVERAGE=$(jq -r ".[\"$PWD/$FILE\"].statements.pct" coverage/coverage-summary.json)

# Check if we have base coverage for comparison
if [ -f "base-coverage-summary.json" ] && jq -e ".[\"$PWD/$FILE\"]" base-coverage-summary.json > /dev/null 2>&1; then
# Get base coverage for the file
BASE_FILE_COVERAGE=$(jq -r ".[\"$PWD/$FILE\"].statements.pct" base-coverage-summary.json)

# Compare coverage values (using simple integer comparison)
if [ "$CURRENT_FILE_COVERAGE" -gt "$BASE_FILE_COVERAGE" ]; then
CHANGE="⬆️ (improved)"
elif [ "$CURRENT_FILE_COVERAGE" -lt "$BASE_FILE_COVERAGE" ]; then
CHANGE="⬇️ (decreased)"
else
CHANGE="No change"
fi

echo "| \`$FILE\` | $CURRENT_FILE_COVERAGE% | $BASE_FILE_COVERAGE% | $CHANGE |" >> coverage-report.md
else
# No previous coverage data
echo "| \`$FILE\` | $CURRENT_FILE_COVERAGE% | No data | New file |" >> coverage-report.md
fi
done

echo "--- :github: Commenting on PR"
buildkite-agent annotate --style info --context coverage-report < coverage-report.md
fi
12 changes: 5 additions & 7 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
---

# IMAGE_ID is an env var that only macOS agents need.
# Defining it at the root level propagates it too all agents, which can seem unnecessary but is a the same time convenient and DRY.
env:
Expand All @@ -27,8 +26,7 @@ steps:
key: unit_tests
command: |
.buildkite/commands/install-node-dependencies.sh
echo '--- :npm: Run Unit Tests'
npm run test
.buildkite/commands/run-unit-tests.sh
plugins: [$CI_TOOLKIT_PLUGIN, $NVM_PLUGIN]
notify:
- github_commit_status:
Expand Down Expand Up @@ -64,10 +62,10 @@ steps:
- test-results/**/*.zip
plugins: [$CI_TOOLKIT_PLUGIN, $NVM_PLUGIN]
agents:
queue: "{{matrix}}"
queue: '{{matrix}}'
env:
# See https://playwright.dev/docs/ci#debugging-browser-launches
DEBUG: "pw:browser"
DEBUG: 'pw:browser'
matrix:
- mac
#- windows
Expand Down Expand Up @@ -148,7 +146,7 @@ steps:
- github_commit_status:
context: Windows Dev Build

- label: ":rocket: Distribute Dev Builds"
- label: ':rocket: Distribute Dev Builds'
command: |
echo "--- :node: Downloading Binaries"
buildkite-agent artifact download "*.app.zip" .
Expand Down Expand Up @@ -254,7 +252,7 @@ steps:
- github_commit_status:
context: Windows Release Build

- label: ":rocket: Publish Release Builds"
- label: ':rocket: Publish Release Builds'
command: |
echo "--- :node: Downloading Binaries"
buildkite-agent artifact download "*.zip" .
Expand Down
9 changes: 9 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ module.exports = {
globalSetup: '<rootDir>/jest-global-setup.ts',
setupFilesAfterEnv: [ '<rootDir>/jest-setup.ts' ],
watchPlugins: [ 'jest-watch-typeahead/filename', 'jest-watch-typeahead/testname' ],
coverageDirectory: 'coverage',
coverageReporters: [ 'json-summary', 'lcov' ],
coveragePathIgnorePatterns: [
'/node_modules/',
'/tests/',
'/vendor/',
'jest-global-setup.ts',
'jest-setup.ts',
],
};
1 change: 1 addition & 0 deletions src/modules/user-settings/components/editor-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const EditorPicker = ( { value, onChange, disabled }: EditorPickerProps )
uninstalledEditors: selectUninstalledEditors( result.data ),
} ),
} );
console.log( 'installedApps', installedEditors );

return (
<SettingsFormField label={ __( 'Code editor' ) }>
Expand Down
1 change: 1 addition & 0 deletions src/modules/user-settings/components/terminal-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const TerminalPicker = ( { value, onChange }: TerminalPickerProps ) => {
uninstalledTerminals: selectUninstalledTerminals( result.data ),
} ),
} );
console.log( 'installedTerminals', installedTerminals );

return (
<SettingsFormField label={ __( 'Terminal application' ) }>
Expand Down

This file was deleted.

Loading