Ts native parser #137
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
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| - neo | |
| pull_request: | |
| branches: | |
| - develop | |
| - neo | |
| workflow_dispatch: | |
| jobs: | |
| ci-core: | |
| name: Run core tests on JDK ${{ matrix.jdk }} | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| jdk: [ 8, 11, 19 ] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: ${{ matrix.jdk }} | |
| distribution: 'zulu' | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| with: | |
| # Only write to the cache for builds on the specific branches. (Default is 'main' only.) | |
| # Builds on other branches will only read existing entries from the cache. | |
| cache-read-only: ${{ github.ref != 'refs/heads/develop' && github.ref != 'ref/heads/neo' }} | |
| - name: Build and run tests | |
| run: ./gradlew --scan build -x :jacodb-ets:build | |
| - name: Upload Gradle test results | |
| if: (!cancelled()) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gradle-test-results-${{ matrix.jdk }} | |
| path: "**/build/test-results/**/*.xml" | |
| - name: Upload Gradle reports | |
| if: (!cancelled()) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gradle-reports-jdk${{ matrix.jdk }} | |
| path: '**/build/reports/' | |
| ci-lifecycle: | |
| name: Run lifecycle tests | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 8 | |
| distribution: 'zulu' | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| with: | |
| # Only write to the cache for builds on the specific branches. (Default is 'main' only.) | |
| # Builds on other branches will only read existing entries from the cache. | |
| cache-read-only: ${{ github.ref != 'refs/heads/develop' && github.ref != 'refs/heads/neo' }} | |
| - name: Build and run lifecycle tests | |
| run: ./gradlew --scan lifecycleTest | |
| - name: Upload Gradle test results | |
| if: (!cancelled()) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gradle-test-results-lifecycle | |
| path: "**/build/test-results/**/*.xml" | |
| - name: Upload Gradle reports | |
| if: (!cancelled()) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gradle-reports-lifecycle | |
| path: '**/build/reports/' | |
| ci-ets: | |
| name: Run ETS tests | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 11 | |
| distribution: 'zulu' | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| with: | |
| # Only write to the cache for builds on the specific branches. (Default is 'main' only.) | |
| # Builds on other branches will only read existing entries from the cache. | |
| cache-read-only: ${{ github.ref != 'refs/heads/develop' && github.ref != 'ref/heads/neo' }} | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: jacodb-ets/ts-frontend/package-lock.json | |
| - name: Build and test ts-frontend | |
| working-directory: jacodb-ets/ts-frontend | |
| run: | | |
| npm ci | |
| npm run build | |
| npm test | |
| # The legacy ArkAnalyzer provider stays supported (selectable via | |
| # ETS_IR_PROVIDER=arkanalyzer); setting ARKANALYZER_DIR here enables | |
| # the provider-parity test in EtsTsFrontendTest. | |
| # | |
| # Best-effort: the default provider is the bundled ts-frontend, so a | |
| # broken upstream ArkAnalyzer must not fail the job — without | |
| # ARKANALYZER_DIR the parity test skips itself. | |
| - name: Set up ArkAnalyzer (legacy provider, best-effort) | |
| continue-on-error: true | |
| run: | | |
| REPO_URL="https://gitcode.com/Lipen/arkanalyzer" | |
| DEST_DIR="arkanalyzer" | |
| MAX_RETRIES=10 | |
| RETRY_DELAY=3 # Delay between retries in seconds | |
| BRANCH="neo/2025-09-03" | |
| for ((i=1; i<=MAX_RETRIES; i++)); do | |
| git clone --depth=1 --branch $BRANCH $REPO_URL $DEST_DIR && break | |
| echo "Clone failed, retrying in $RETRY_DELAY seconds..." | |
| sleep "$RETRY_DELAY" | |
| done | |
| if [[ $i -gt $MAX_RETRIES ]]; then | |
| echo "Failed to clone the repository after $MAX_RETRIES attempts." | |
| exit 1 | |
| else | |
| echo "Repository cloned successfully." | |
| fi | |
| cd $DEST_DIR | |
| # ArkAnalyzer's bundled TypeScript (ohos-typescript 4.9.5) cannot parse | |
| # the d.ts files of the latest floating @types/node (e.g. ffi.d.ts), so | |
| # pin a compatible major IN THE MANIFEST before the single `npm install`. | |
| # NB: do not run a second `npm install <pkg>` afterwards — it re-resolves | |
| # the tree and prunes ohos-typescript, which the postinstall script adds | |
| # with --no-save (i.e. it is absent from package.json). | |
| npm pkg set 'devDependencies.@types/node=18' | |
| npm install | |
| npm run build | |
| # Export only after a successful build so a broken checkout is never used. | |
| echo "ARKANALYZER_DIR=$(realpath .)" >> $GITHUB_ENV | |
| - name: Run ETS tests | |
| run: ./gradlew --scan :jacodb-ets:generateTestResources :jacodb-ets:test | |
| - name: Upload Gradle test results | |
| if: (!cancelled()) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gradle-test-results-ets | |
| path: "**/build/test-results/**/*.xml" | |
| - name: Upload Gradle reports | |
| if: (!cancelled()) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gradle-reports-ets | |
| path: '**/build/reports/' | |
| publish-test-results: | |
| name: "Publish test results" | |
| needs: [ ci-core, ci-lifecycle, ci-ets ] | |
| if: (!cancelled()) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| checks: write | |
| pull-requests: write | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Publish test results | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| with: | |
| files: "artifacts/gradle-test-results-*/**/*.xml" |