Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#9429 Initializing npm workspace for extension application #9444

Merged
merged 14 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
directory: /applications/browser-extension/
schedule:
interval: weekly
day: sunday
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/beta-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
ref: release/${{ github.event.inputs.version }}
- uses: actions/setup-node@v4
with:
node-version-file: package.json
node-version-file: applications/browser-extension/package.json
cache: npm
- run: npm ci
- run: npm run build
Expand All @@ -51,21 +51,21 @@ jobs:
AWS_DEFAULT_REGION: "us-east-2"
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
- name: Delete local sourcemaps
run: find dist -name '*.map' -delete
run: find applications/browser-extension/dist -name '*.map' -delete
- name: Save store extension
uses: actions/upload-artifact@v4
with:
name: build-for-store-beta
path: dist
path: applications/browser-extension/dist
retention-days: 30
if-no-files-found: error
- name: Create production version
run: npx [email protected] dist/manifest.json key '${{ env.CHROME_MANIFEST_KEY }}'
run: npx [email protected] applications/browser-extension/dist/manifest.json key '${{ env.CHROME_MANIFEST_KEY }}'
- name: Save production extension
uses: actions/upload-artifact@v4
with:
name: build-production-beta
path: dist
path: applications/browser-extension/dist
retention-days: 30
if-no-files-found: error

Expand Down
56 changes: 28 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
node-version-file: applications/browser-extension/package.json
cache: npm
- run: npm ci
- run: npm run test -- --coverage
- run: npm run test -ws -- --coverage
grahamlangford marked this conversation as resolved.
Show resolved Hide resolved
- uses: actions/upload-artifact@v4
with:
name: extension-test-coverage
path: coverage/coverage-final.json
path: applications/browser-extension/coverage/coverage-final.json

upload-to-codecov:
needs: test
Expand Down Expand Up @@ -77,10 +77,10 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
node-version-file: applications/browser-extension/package.json
cache: npm
- run: npm ci
- run: npm run build:webpack
- run: npm run build:webpack --workspace=applications/browser-extension
env:
MV: 3
RELEASE_CHANNEL: stable
Expand All @@ -97,27 +97,27 @@ jobs:
with:
name: build-staging
path: |
dist
!dist/**/*.map
applications/browser-extension/dist
!applications/browser-extension/dist/**/*.map
retention-days: 5
if-no-files-found: error

# The polyfill cannot be used outside the extension context
- run: "! grep 'loaded in a browser extension' dist/pageScript.js --files-with-matches"
- run: "! grep 'loaded in a browser extension' applications/browser-extension/dist/pageScript.js --files-with-matches"
name: Detect browser-polyfill in pageScript.js

# The messenger cannot be executed twice; only load it in contentScriptCore
# https://github.com/pixiebrix/webext-messenger/issues/88
# - contentScript.js can't have it because the file could be injected multiple times, guarding contentScriptCore
# - loadActivationEnhancements.js can't have it because it's always loaded alongside contentScript.js
- run: "! grep '__getTabData' dist/loadActivationEnhancements.js dist/contentScript.js dist/setExtensionIdInApp.js --files-with-matches"
- run: "! grep '__getTabData' applications/browser-extension/dist/loadActivationEnhancements.js applications/browser-extension/dist/contentScript.js applications/browser-extension/dist/setExtensionIdInApp.js --files-with-matches"
name: Detect webext-messenger unwanted bundles

- uses: actions/upload-artifact@v4
name: Save report.html
with:
name: build-staging-bundle-dependency-report
path: report.html
path: applications/browser-extension/report.html
retention-days: 5
if-no-files-found: error

Expand All @@ -128,15 +128,15 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
node-version-file: applications/browser-extension/package.json
cache: npm
- run: npm ci
- run: npm run generate:headers
- run: npm run generate:headers --workspace=applications/browser-extension
- uses: actions/upload-artifact@v4
name: Save headers.json
with:
name: brick-headers
path: headers.json
path: applications/browser-extension/headers.json
retention-days: 5
if-no-files-found: error

Expand All @@ -148,10 +148,10 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
node-version-file: applications/browser-extension/package.json
cache: npm
- run: npm ci
- run: npm run build:typescript
- run: npm run build:typescript --workspace=applications/browser-extension

lint:
runs-on: ubuntu-latest
Expand All @@ -160,10 +160,10 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
node-version-file: applications/browser-extension/package.json
cache: npm
- run: npm ci
- run: npm run lint:full
- run: npm run lint:full --workspace=applications/browser-extension

dead-code:
runs-on: ubuntu-latest
Expand All @@ -172,15 +172,15 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
node-version-file: applications/browser-extension/package.json
cache: npm
- run: npm ci
# Detect dead code with enforced rules
- run: npm run dead-code
- run: npm run dead-code --workspace=applications/browser-extension
# Detect dead code that is only used by tests
- run: npm run dead-code:prod
- run: npm run dead-code:prod --workspace=applications/browser-extension
# Also run the remaining "warn" rules
- run: npm run dead-code:base -- --no-exit-code
- run: npm run dead-code:base --workspace=applications/browser-extension -- --no-exit-code

# https://pre-commit.com/#usage-in-continuous-integration
prettier:
Expand Down Expand Up @@ -210,43 +210,43 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
node-version-file: applications/browser-extension/package.json
cache: npm
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
path: 7z-blob-reports
path: applications/browser-extension/7z-blob-reports
pattern: end-to-end-tests-report-*
merge-multiple: true
- name: Unzip password protected Playwright reports
if: always()
shell: bash
env:
ARTIFACT_ZIP_PASSWORD: ${{ secrets.ARTIFACT_ZIP_PASSWORD }}
run: 7z -y x -p"$ARTIFACT_ZIP_PASSWORD" -o./blob-reports "./7z-blob-reports/*.7z"
run: 7z -y x -p"$ARTIFACT_ZIP_PASSWORD" -o./applications/browser-extension/blob-reports "./applications/browser-extension/7z-blob-reports/*.7z"
- name: Merge blob reports
run: PLAYWRIGHT_JSON_OUTPUT_NAME=./playwright-report/results.json npx playwright merge-reports --reporter=html,json ./blob-reports
run: PLAYWRIGHT_JSON_OUTPUT_NAME=./applications/browser-extension/playwright-report/results.json npx playwright merge-reports --reporter=html,json ./applications/browser-extension/blob-reports
- name: Password protect merged Playwright report
if: always()
shell: bash
env:
ARTIFACT_ZIP_PASSWORD: ${{ secrets.ARTIFACT_ZIP_PASSWORD }}
run: 7z a ./playwright-report.7z ./playwright-report/* -p"$ARTIFACT_ZIP_PASSWORD"
run: 7z a ./applications/browser-extension/playwright-report.7z ./applications/browser-extension/playwright-report/* -p"$ARTIFACT_ZIP_PASSWORD"
- name: Upload zipped merged Playwright Report to GitHub Actions Artifacts
id: upload-merged-playwright-report-step
if: always()
uses: actions/upload-artifact@v4
with:
name: end-to-end-tests-report
path: ./playwright-report.7z
path: applications/browser-extension/playwright-report.7z
retention-days: 5
compression-level: 0 # already compressed with 7z
- name: Create report comment
id: report-summary
uses: daun/playwright-report-summary@v3
with:
comment-title: "Playwright test results"
report-file: ./playwright-report/results.json
report-file: ./applications/browser-extension/playwright-report/results.json
report-url: ${{ steps.upload-merged-playwright-report-step.outputs.artifact-url }}
custom-info: "For more information on how to debug and view this report, [see our readme](https://github.com/pixiebrix/pixiebrix-extension/blob/main/end-to-end-tests/README.md#github-ci-integration)"

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
ref: ${{ github.event.inputs.checkout-ref }}
- uses: actions/setup-node@v4
with:
node-version-file: package.json
node-version-file: applications/browser-extension/package.json
cache: npm
- name: Install dependencies
run: npm ci
Expand All @@ -68,22 +68,22 @@ jobs:
attempt_delay: 15000
attempt_limit: 40
- name: Build the extension
run: npm run build:webpack
run: npm run build:webpack --workspace=applications/browser-extension
- name: Run end to end tests
# Xvfb is required to run the tests in headed mode. Headed mode is required to run tests for browser extensions
# in Playwright, see https://playwright.dev/docs/ci#running-headed
run: xvfb-run npm run test:e2e -- --project=${{ matrix.project }}* --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
run: xvfb-run npm run test:e2e --workspace=applications/browser-extension -- --project=${{ matrix.project }}* --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- name: Password protect Playwright reports
if: always()
shell: bash
env:
ARTIFACT_ZIP_PASSWORD: ${{ secrets.ARTIFACT_ZIP_PASSWORD }}
run: 7z a ./end-to-end-tests/blob-report-${{ matrix.project }}-${{ matrix.shardIndex }}.7z ./end-to-end-tests/.blob-report/* -p"$ARTIFACT_ZIP_PASSWORD"
run: 7z a ./applications/browser-extension/end-to-end-tests/blob-report-${{ matrix.project }}-${{ matrix.shardIndex }}.7z ./applications/browser-extension/end-to-end-tests/.blob-report/* -p"$ARTIFACT_ZIP_PASSWORD"
- name: Upload zipped Playwright Report to GitHub Actions Artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: end-to-end-tests-report-${{ matrix.project }}-${{ matrix.shardIndex }}
path: end-to-end-tests/blob-report-${{ matrix.project }}-${{ matrix.shardIndex }}.7z
path: applications/browser-extension/end-to-end-tests/blob-report-${{ matrix.project }}-${{ matrix.shardIndex }}.7z
retention-days: 5
compression-level: 0 # already compressed with 7z
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
id: changedfiles
uses: tj-actions/changed-files@v45
with:
files: "src/vendors/**/*.*"
files: "applications/browser-extension/src/vendors/**/*.*"
- name: Leave annotations
if: steps.changedfiles.outputs.any_changed == 'true'
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rainforestqa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
node-version-file: applications/browser-extension/package.json
cache: npm

- run: npm ci
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
ref_name: ${{ github.ref_name }}

- name: Upload Extension
run: bash scripts/upload-extension.sh ${{ env.BUILD_PATH }}
run: bash applications/browser-extension/scripts/upload-extension.sh ${{ env.BUILD_PATH }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.SOURCEMAP_USER_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.SOURCEMAP_USER_KEY }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/upload-mixpanel-lexicon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
run: npm ci
- name: Compile TypeScript
# Explicitly specify the TypeScript environment because tsconfig.json is ignored when input files are specified
run: npx tsc scripts/uploadMixpanelLexicon.ts --esModuleInterop --lib esnext
run: npx tsc applications/browser-extension/scripts/uploadMixpanelLexicon.ts --esModuleInterop --lib esnext
- name: Upload Lexicon
if: github.ref_name == 'main'
run: node scripts/uploadMixpanelLexicon.js
run: node applications/browser-extension/scripts/uploadMixpanelLexicon.js
env:
MIXPANEL_PROJECT_ID: ${{ secrets.MIXPANEL_PROJECT_ID }}
MIXPANEL_SERVICE_ACCOUNT_USERNAME: ${{ secrets.MIXPANEL_SERVICE_ACCOUNT_USERNAME }}
Expand Down
17 changes: 10 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ node_modules
db.sqlite3
.env
.env.*
!.env.example
!applications/browser-extension/.env.example
staticfiles
.vscode

Expand Down Expand Up @@ -45,7 +45,10 @@ web-ext-artifacts

# Other artifacts
artifacts
/scripts/bin/
/applications/browser-extension/scripts/bin/
/applications/browser-extension/scripts/uploadMixpanelLexicon.js
/applications/browser-extension/src/telemetry/events.js
/applications/browser-extension/src/telemetry/lexicon.js
headers.json
report.html
pixiebrix-extension-*.zip
Expand All @@ -54,11 +57,11 @@ pixiebrix-extension-*.zip
storybook-static

# Playwright
/end-to-end-tests/.output/
/end-to-end-tests/.report/
/end-to-end-tests/.blob-report/
/end-to-end-tests/.auth/
/applications/browser-extension/end-to-end-tests/.output/
/applications/browser-extension/end-to-end-tests/.report/
/applications/browser-extension/end-to-end-tests/.blob-report/
/applications/browser-extension/end-to-end-tests/.auth/
/playwright/.cache/
/end-to-end-tests/blob-report.7z
/applications/browser-extension/end-to-end-tests/blob-report.7z
/playwright-report/
.playwright-report/
47 changes: 47 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading