Repository navigation
feat(runtime): warn in debug when an ES module passes a relative specifier to the global require #1089
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: | |
| pull_request: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| env: | |
| NPM_TAG: "pr" | |
| # Xcode 26 for its compilation cache (tools/ci-compilation-cache.xcconfig). | |
| XCODE_VERSION: "26.3" | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: macos-15 | |
| steps: | |
| - uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0 | |
| with: | |
| xcode-version: ${{env.XCODE_VERSION}} | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| submodules: true | |
| persist-credentials: false # disable to prevent leaking credentials to build scripts | |
| - name: LLVM cache | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ./llvm | |
| key: ${{ hashFiles('download_llvm.sh') }} | |
| - name: Xcode compilation cache | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ${{ runner.temp }}/xcode-cas | |
| # npm_release.yml saves this key from main (never restoring it there), so | |
| # a PR's first push starts warm. | |
| key: xcode-cas-${{ runner.os }}-${{ runner.arch }}-build-${{ github.sha }} | |
| restore-keys: xcode-cas-${{ runner.os }}-${{ runner.arch }}-build- | |
| - name: Enable Xcode compilation cache | |
| run: | | |
| echo "XCODE_XCCONFIG_FILE=$GITHUB_WORKSPACE/tools/ci-compilation-cache.xcconfig" >> "$GITHUB_ENV" | |
| echo "NS_COMPILATION_CACHE_DIR=$RUNNER_TEMP/xcode-cas" >> "$GITHUB_ENV" | |
| - uses: ./.github/actions/setup-build-env | |
| with: | |
| ccache: "true" | |
| - name: Get Current Version | |
| run: | | |
| echo NPM_VERSION=$(node -e "console.log(require('./package.json').version);") >> $GITHUB_ENV | |
| - name: Bump version for PR release | |
| run: | | |
| NPM_VERSION=$(node ./scripts/get-next-version.js) | |
| echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV | |
| npm version $NPM_VERSION --no-git-tag-version | |
| - name: Build | |
| # Default (embedded) SwiftPM mode: the xcframework zips ship inside the | |
| # package, so the artifact below is self-contained — download it and | |
| # use it directly with `ns platform add ios --framework-path=<tgz>`. | |
| run: npm run build-ios | |
| - name: Xcode compilation cache size | |
| if: ${{ !cancelled() }} | |
| run: du -sh "$NS_COMPILATION_CACHE_DIR" || true | |
| - name: ccache stats | |
| if: ${{ !cancelled() }} | |
| run: ccache --show-stats || true | |
| - name: Upload npm package artifact | |
| uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 | |
| with: | |
| name: npm-package | |
| path: dist/nativescript-ios-${{env.NPM_VERSION}}.tgz | |
| - name: Upload SwiftPM artifacts (xcframework zips + checksums) | |
| uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 | |
| with: | |
| name: spm-artifacts | |
| path: dist/artifacts/* | |
| - name: Upload dSYMs artifact | |
| uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 | |
| with: | |
| name: NativeScript-dSYMs | |
| path: dist/dSYMs | |
| test: | |
| name: ${{ matrix.name }} | |
| runs-on: macos-15 | |
| needs: build | |
| strategy: | |
| # The two variants answer different questions; one failing must not | |
| # cancel the other. | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # wrapper-lifetime-pass: "<mode>:<scope>" to run the suite a second | |
| # time, on the same build, under that wrapper lifetime mode. | |
| - name: Test | |
| xcodebuild-args: "" | |
| artifact-suffix: "" | |
| cache-variant: default | |
| wrapper-lifetime-pass: "canary:all" | |
| # Only code compiled here is instrumented: the runtime and the test | |
| # fixtures, not the prebuilt V8 archives. | |
| - name: Test (ASan) | |
| xcodebuild-args: "-enableAddressSanitizer YES" | |
| artifact-suffix: "-asan" | |
| cache-variant: asan | |
| wrapper-lifetime-pass: "" | |
| env: | |
| # Must match the simulator named in "Wait for the test simulator". | |
| TEST_DESTINATION: "platform=iOS Simulator,OS=latest,name=iPhone 16 Pro" | |
| steps: | |
| - uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0 | |
| with: | |
| xcode-version: ${{env.XCODE_VERSION}} | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| submodules: true | |
| persist-credentials: false # disable to prevent leaking credentials to build scripts | |
| - name: LLVM cache | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ./llvm | |
| key: ${{ hashFiles('download_llvm.sh') }} | |
| - name: Xcode compilation cache | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ${{ runner.temp }}/xcode-cas | |
| # A distinct segment per variant: a bare prefix of one would also match | |
| # the other's keys. npm_release.yml saves the "default" variant from main. | |
| key: xcode-cas-${{ runner.os }}-${{ runner.arch }}-test-${{ matrix.cache-variant }}-${{ github.sha }} | |
| restore-keys: xcode-cas-${{ runner.os }}-${{ runner.arch }}-test-${{ matrix.cache-variant }}- | |
| - name: Enable Xcode compilation cache | |
| run: | | |
| echo "XCODE_XCCONFIG_FILE=$GITHUB_WORKSPACE/tools/ci-compilation-cache.xcconfig" >> "$GITHUB_ENV" | |
| echo "NS_COMPILATION_CACHE_DIR=$RUNNER_TEMP/xcode-cas" >> "$GITHUB_ENV" | |
| - uses: ./.github/actions/setup-build-env | |
| with: | |
| install-test-tools: "true" | |
| - name: Prepare test folder | |
| id: prepare-test-folder | |
| run: | | |
| mkdir -p dist-test | |
| echo TEST_FOLDER=$(pwd)/dist-test >> $GITHUB_ENV | |
| # Must match the simulator named in TEST_DESTINATION. | |
| # --boot leaves the simulator booting in the background, so the boot | |
| # overlaps build-for-testing instead of delaying the first test run. | |
| - name: Wait for the test simulator | |
| run: ./scripts/wait-for-simulator.sh --name "iPhone 16 Pro" --boot | |
| - name: Build for testing | |
| id: build-for-testing | |
| run: set -o pipefail && xcodebuild -project v8ios.xcodeproj -scheme TestRunner -destination "$TEST_DESTINATION" ${{ matrix.xcodebuild-args }} build-for-testing | xcpretty | |
| - name: Xcode Tests | |
| uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0 | |
| # try to run the tests with xcpretty. If it fails then try again without xcpretty twice for better log output | |
| # the xcode tests are a bit flaky and they should never fail on this step, as this step only collects the JS test results as junit xml | |
| with: | |
| # The runtime suite's report-wait alone can take 10m (see | |
| # TestRunnerTests.swift), plus app install and launch. | |
| timeout_minutes: 25 | |
| max_attempts: 2 | |
| command: set -o pipefail && xcodebuild -project v8ios.xcodeproj -scheme TestRunner -resultBundlePath $TEST_FOLDER/test_results -destination "$TEST_DESTINATION" ${{ matrix.xcodebuild-args }} test-without-building | xcpretty | |
| # Keep the failed attempt's bundle — it holds the diagnostics of the | |
| # failure being retried. Everything else at the result path must go | |
| # (including extensionless staging leftovers), or the retry dies with | |
| # "Existing file at -resultBundlePath". | |
| on_retry_command: rm -rf $TEST_FOLDER/test_results_attempt1.xcresult; mv $TEST_FOLDER/test_results.xcresult $TEST_FOLDER/test_results_attempt1.xcresult 2>/dev/null; for f in $TEST_FOLDER/test_results*; do [ "$f" = "$TEST_FOLDER/test_results_attempt1.xcresult" ] || rm -rf "$f"; done; xcrun simctl shutdown all | |
| new_command_on_retry: xcodebuild -project v8ios.xcodeproj -scheme TestRunner -resultBundlePath $TEST_FOLDER/test_results -destination "$TEST_DESTINATION" ${{ matrix.xcodebuild-args }} test-without-building | |
| - name: Xcode compilation cache size | |
| if: ${{ !cancelled() }} | |
| run: du -sh "$NS_COMPILATION_CACHE_DIR" || true | |
| - name: Extract test results | |
| # Runs even when the test step failed: the xcresult usually still | |
| # carries the JS suite's junit attachments for the report step below. | |
| if: ${{ !cancelled() }} | |
| run: | | |
| if [ -d "$TEST_FOLDER/test_results.xcresult" ]; then | |
| ./scripts/export-test-attachments.sh --result "$TEST_FOLDER/test_results.xcresult" --output "$TEST_FOLDER/test-out" | |
| fi | |
| - name: Test report summary | |
| if: ${{ !cancelled() }} | |
| # annotate_only keeps this usable from fork PRs: it reports via workflow | |
| # commands and the step summary, so no checks:write token is needed | |
| uses: mikepenz/action-junit-report@6ef3fdcfcd5f0b5d14df3e659ef19b8c6820f93d # v6.6.1 | |
| with: | |
| report_paths: dist-test/test-out/*junit*.xml | |
| annotate_only: true | |
| detailed_summary: true | |
| - name: Validate Test Results | |
| run: | | |
| # JS spec results only reach CI through these reports, and xargs runs | |
| # nothing on empty input, so a missing report must fail here. | |
| ls "$TEST_FOLDER"/test-out/*junit*.xml > /dev/null 2>&1 || { echo "::error::No JUnit report in $TEST_FOLDER/test-out"; exit 1; } | |
| find $TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx junit-cli-report-viewer | |
| find $TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx verify-junit-xml | |
| # Second pass: the same build with "wrapperLifetime" set in the built | |
| # app's package.json. It runs whatever the first pass's outcome, so a | |
| # default-mode failure still yields this pass's results and diagnostics. | |
| # test-without-building runs no build phases, so the rewrite stands. | |
| - name: Configure the built app for the wrapper lifetime pass | |
| id: wrapper-lifetime-app | |
| if: ${{ !cancelled() && matrix.wrapper-lifetime-pass != '' && steps.build-for-testing.outcome == 'success' }} | |
| env: | |
| WRAPPER_LIFETIME: ${{ matrix.wrapper-lifetime-pass }} | |
| run: | | |
| APP="$(find build -maxdepth 2 -type d -path 'build/*-iphonesimulator/TestRunner.app')" | |
| [ -n "$APP" ] && [ "$(printf '%s\n' "$APP" | wc -l)" -eq 1 ] || { echo "::error::Expected one built TestRunner.app under build/, found: ${APP:-none}"; exit 1; } | |
| node tools/apply-test-app-config.mjs --source TestRunner/app/package.json --out "$APP/app/package.json" --wrapper-lifetime "$WRAPPER_LIFETIME" | |
| # Rewriting a resource breaks the bundle's seal; re-seal it ad hoc, | |
| # keeping the build's entitlements. | |
| codesign --force --sign - --timestamp=none --preserve-metadata=entitlements "$APP" | |
| echo "WL_TEST_FOLDER=$TEST_FOLDER/wrapper-lifetime" >> "$GITHUB_ENV" | |
| mkdir -p "$TEST_FOLDER/wrapper-lifetime" | |
| - name: Xcode Tests (wrapper lifetime ${{ matrix.wrapper-lifetime-pass }}) | |
| if: ${{ !cancelled() && steps.wrapper-lifetime-app.outcome == 'success' }} | |
| uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0 | |
| with: | |
| timeout_minutes: 25 | |
| max_attempts: 2 | |
| command: set -o pipefail && xcodebuild -project v8ios.xcodeproj -scheme TestRunner -resultBundlePath $WL_TEST_FOLDER/test_results -destination "$TEST_DESTINATION" ${{ matrix.xcodebuild-args }} test-without-building | xcpretty | |
| on_retry_command: rm -rf $WL_TEST_FOLDER/test_results_attempt1.xcresult; mv $WL_TEST_FOLDER/test_results.xcresult $WL_TEST_FOLDER/test_results_attempt1.xcresult 2>/dev/null; for f in $WL_TEST_FOLDER/test_results*; do [ "$f" = "$WL_TEST_FOLDER/test_results_attempt1.xcresult" ] || rm -rf "$f"; done; xcrun simctl shutdown all | |
| new_command_on_retry: xcodebuild -project v8ios.xcodeproj -scheme TestRunner -resultBundlePath $WL_TEST_FOLDER/test_results -destination "$TEST_DESTINATION" ${{ matrix.xcodebuild-args }} test-without-building | |
| - name: Extract test results (wrapper lifetime) | |
| if: ${{ !cancelled() && steps.wrapper-lifetime-app.outcome == 'success' }} | |
| run: | | |
| if [ -d "$WL_TEST_FOLDER/test_results.xcresult" ]; then | |
| ./scripts/export-test-attachments.sh --result "$WL_TEST_FOLDER/test_results.xcresult" --output "$WL_TEST_FOLDER/test-out" | |
| fi | |
| - name: Test report summary (wrapper lifetime) | |
| if: ${{ !cancelled() && steps.wrapper-lifetime-app.outcome == 'success' }} | |
| uses: mikepenz/action-junit-report@6ef3fdcfcd5f0b5d14df3e659ef19b8c6820f93d # v6.6.1 | |
| with: | |
| check_name: JUnit Test Report (wrapper lifetime ${{ matrix.wrapper-lifetime-pass }}) | |
| report_paths: dist-test/wrapper-lifetime/test-out/*junit*.xml | |
| annotate_only: true | |
| detailed_summary: true | |
| - name: Validate Test Results (wrapper lifetime) | |
| if: ${{ !cancelled() && steps.wrapper-lifetime-app.outcome == 'success' }} | |
| env: | |
| WRAPPER_LIFETIME: ${{ matrix.wrapper-lifetime-pass }} | |
| run: | | |
| ls "$WL_TEST_FOLDER"/test-out/*junit*.xml > /dev/null 2>&1 || { echo "::error::No JUnit report in $WL_TEST_FOLDER/test-out"; exit 1; } | |
| find $WL_TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx junit-cli-report-viewer | |
| find $WL_TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx verify-junit-xml | |
| ./scripts/check-wrapper-lifetime-report.sh --reports "$WL_TEST_FOLDER/test-out" --expect "$(printf '%s' "$WRAPPER_LIFETIME" | tr ':' '/')" | |
| - name: Collect test diagnostics | |
| if: failure() | |
| uses: ./.github/actions/collect-test-diagnostics | |
| with: | |
| test-folder: ${{env.TEST_FOLDER}} | |
| artifact-name: test-diagnostics${{ matrix.artifact-suffix }} | |
| - name: Archive Test Result Data | |
| if: always() | |
| uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 | |
| with: | |
| name: test-results${{ matrix.artifact-suffix }} | |
| path: | | |
| ${{env.TEST_FOLDER}}/test_results.xcresult | |
| ${{env.TEST_FOLDER}}/test_results_attempt1.xcresult | |
| ${{env.TEST_FOLDER}}/wrapper-lifetime/test_results.xcresult | |
| ${{env.TEST_FOLDER}}/wrapper-lifetime/test_results_attempt1.xcresult | |
| test-catalyst: | |
| name: Test (Mac Catalyst) | |
| runs-on: macos-15 | |
| needs: build | |
| steps: | |
| - uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0 | |
| with: | |
| xcode-version: ${{env.XCODE_VERSION}} | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| submodules: true | |
| persist-credentials: false # disable to prevent leaking credentials to build scripts | |
| - name: LLVM cache | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ./llvm | |
| key: ${{ hashFiles('download_llvm.sh') }} | |
| - uses: ./.github/actions/setup-build-env | |
| with: | |
| install-test-tools: "true" | |
| - name: Prepare test folder | |
| run: echo TEST_FOLDER=$(pwd)/build/tests/catalyst >> $GITHUB_ENV | |
| - name: Xcode Tests | |
| uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0 | |
| with: | |
| timeout_minutes: 40 | |
| max_attempts: 2 | |
| command: ./run_tests.sh --catalyst | |
| # run_tests.sh empties its results folder, so move the failed | |
| # attempt's bundle out of it first. | |
| on_retry_command: rm -rf $TEST_FOLDER-attempt1; mv $TEST_FOLDER $TEST_FOLDER-attempt1 2>/dev/null || true | |
| - name: Extract test results | |
| # run_tests.sh extracts the report itself; extracting again would collide. | |
| if: ${{ !cancelled() }} | |
| run: | | |
| if [ -d "$TEST_FOLDER/test_results.xcresult" ] && ! ls "$TEST_FOLDER"/test-out/*junit*.xml >/dev/null 2>&1; then | |
| ./scripts/export-test-attachments.sh --result "$TEST_FOLDER/test_results.xcresult" --output "$TEST_FOLDER/test-out" | |
| fi | |
| - name: Test report summary | |
| if: ${{ !cancelled() }} | |
| uses: mikepenz/action-junit-report@6ef3fdcfcd5f0b5d14df3e659ef19b8c6820f93d # v6.6.1 | |
| with: | |
| report_paths: build/tests/catalyst/test-out/*junit*.xml | |
| annotate_only: true | |
| detailed_summary: true | |
| - name: Validate Test Results | |
| run: | | |
| # JS spec results only reach CI through these reports, and xargs runs | |
| # nothing on empty input, so a missing report must fail here. | |
| ls "$TEST_FOLDER"/test-out/*junit*.xml > /dev/null 2>&1 || { echo "::error::No JUnit report in $TEST_FOLDER/test-out"; exit 1; } | |
| find $TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx junit-cli-report-viewer | |
| find $TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx verify-junit-xml | |
| - name: Collect test diagnostics | |
| if: failure() | |
| uses: ./.github/actions/collect-test-diagnostics | |
| with: | |
| test-folder: ${{env.TEST_FOLDER}} | |
| artifact-name: test-diagnostics-catalyst | |
| host-process-log: "true" | |
| - name: Archive Test Result Data | |
| if: always() | |
| uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 | |
| with: | |
| name: test-results-catalyst | |
| path: | | |
| ${{env.TEST_FOLDER}}/test_results.xcresult | |
| ${{env.TEST_FOLDER}}-attempt1/test_results.xcresult |