diff --git a/.circleci/config.yml b/.circleci/config.yml index 7aa07b2dc..4c2454f85 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -66,23 +66,6 @@ commands: paths: - $GITHUB_WORKSPACE key: repos-<> - fetch-verified-codemods: - steps: - - run: - command: | - uv run --frozen python -m tests.shared.codemod.commands fetch-verified-codemods --cli-api-key ${PROD_CLI_API_KEY} - cache-verified-codemod-repos: - steps: - - restore_cache: - keys: - - v1-verified-codemod-repos-{{ checksum "tests/integration/verified_codemods/codemod_data/repo_commits.json" }}-{{.Environment.CIRCLE_NODE_INDEX}}-{{.Environment.CIRCLE_NODE_TOTAL}} - - run: - command: | - uv run --frozen python -m tests.shared.codemod.commands clone-repos --verified-codemod-repos --token ${CODEGEN_BOT_GHE_TOKEN} - - save_cache: - paths: - - $GITHUB_WORKSPACE - key: v1-verified-codemod-repos-{{ checksum "tests/integration/verified_codemods/codemod_data/repo_commits.json" }}-{{.Environment.CIRCLE_NODE_INDEX}}-{{.Environment.CIRCLE_NODE_TOTAL}} build-wheels: steps: - install-uv @@ -192,54 +175,6 @@ commands: # Define a job to be invoked later in a workflow. # See: https://circleci.com/docs/jobs-steps/#jobs-overview & https://circleci.com/docs/configuration-reference/#jobs jobs: - unit-tests: - parallelism: 8 - executor: default_image - resource_class: "xlarge" - steps: - - setup-uv - - node/install: - use-nvm-cache: true - - run_ats: - default_tests: "tests/unit" - collect_args: --timeout 50 - integration-tests: - executor: default_image - resource_class: "large" - steps: - - setup-uv - - run: - command: | - uv run --frozen pytest -o junit_suite_name="${CIRCLE_JOB}" -n auto tests/integration/codegen - - upload-tests - doctests: - executor: default_image - steps: - - setup-uv - - run: - command: | - uv run --frozen pytest -o junit_suite_name="${CIRCLE_JOB}" -n auto docs - - upload-tests - codemod-tests: - parallelism: 8 - executor: default_vm - resource_class: "2xlarge+" - steps: - - install-uv - - setup-uv - - fetch-verified-codemods - - cache-verified-codemod-repos - - run_ats: - default_tests: "tests/integration/codemod/test_verified_codemods.py" - codecov_flags: "smart-tests-codemod" - collect_args: --cli-api-key ${PROD_CLI_API_KEY} --token ${CODEGEN_BOT_GHE_TOKEN} - ats_collect_args: --cli-api-key=${PROD_CLI_API_KEY},--token=${CODEGEN_BOT_GHE_TOKEN}, - split_tests: false - - slack/notify: - event: fail - branch_pattern: "develop" - channel: "alerts-codemod-tests" - template: basic_fail_1 oss-codemod-tests: parameters: sync_graph: @@ -372,10 +307,6 @@ jobs: channel: "release" template: success_tagged_deploy_1 workflows: - pr_checks: - jobs: - - unit-tests - - integration-tests publish-packages: jobs: - linux-wheels: diff --git a/.gitattributes b/.gitattributes index ef04dbf41..f91c3e563 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,6 @@ -**/expected_diff.txt filter=lfs diff=lfs merge=lfs -text tests/integration/codemod/repos/extra/*.json filter=lfs diff=lfs merge=lfs -text -**/expected_diff.patch filter=lfs diff=lfs merge=lfs -text +**/test_codegen/expected_diff.patch filter=lfs diff=lfs merge=lfs -text +**/test_codegen/expected_diff.patch.skip filter=lfs diff=lfs merge=lfs -text tests/integration/codemod/repos/repos.json filter=lfs diff=lfs merge=lfs -text tests/integration/verified_codemods/** filter=lfs diff=lfs merge=lfs -text .github/disallowed-words.txt filter=lfs diff=lfs merge=lfs -text diff --git a/.github/actions/report/action.yml b/.github/actions/report/action.yml new file mode 100644 index 000000000..e9a72af19 --- /dev/null +++ b/.github/actions/report/action.yml @@ -0,0 +1,27 @@ +name: report +description: "Publish Test Reports" +inputs: + flag: + required: true + description: "Relevant codecov flag" + codecov_token: + required: true + description: "Codecov token" +runs: + using: "composite" + steps: + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ inputs.codecov_token }} + files: build/test-results/test/TEST.xml + - name: Upload coverage reports to Codecov + if: (success() || failure()) # always upload coverage reports even if the tests fail + continue-on-error: true + uses: codecov/codecov-action@v5.1.2 + with: + token: ${{ inputs.codecov_token }} + files: coverage.xml + flags: ${{ inputs.flag }} + plugins: pycoverage,compress-pycoverage diff --git a/.github/actions/run_ats/action.yml b/.github/actions/run_ats/action.yml new file mode 100644 index 000000000..ef090c553 --- /dev/null +++ b/.github/actions/run_ats/action.yml @@ -0,0 +1,61 @@ +name: 'Run ATS' +description: 'Run Automated Test Selection to determine which tests to run' + +inputs: + default_tests: + description: 'Default test path to run' + required: true + codecov_static_token: + description: 'Codecov static token' + required: true + codecov_token: + description: 'Codecov token' + required: true + collect_args: + description: 'Additional arguments for test collection' + required: false + default: '' + ats_collect_args: + description: 'Additional arguments for ATS collection' + required: false + default: '' + codecov_flags: + description: 'Flags for codecov upload' + required: false + default: 'smart-tests' + +runs: + using: "composite" + steps: + - name: Run ATS + shell: bash + env: + BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} + DEFAULT_TESTS: ${{ inputs.default_tests }} + CODECOV_STATIC_TOKEN: ${{ inputs.codecov_static_token }} + CODECOV_TOKEN: ${{ inputs.codecov_token }} + COLLECT_ARGS: ${{ inputs.collect_args }} + ATS_COLLECT_ARGS: ${{ inputs.ats_collect_args }} + run: | + uv run codecovcli create-commit -t ${{ inputs.codecov_token }} + uv run codecovcli create-report -t ${{ inputs.codecov_token }} + bash ./.circleci/ats.sh + + - name: Run tests + shell: bash + run: | + echo "pwd: $(pwd)" # FIXME: for debugging + TESTS_TO_RUN=$(cat codecov_ats/tests_to_run.txt) + echo $TESTS_TO_RUN | xargs uv run pytest --cov \ + -o junit_suite_name="${{ github.job }}" \ + -n auto \ + -vv \ + --cov \ + --cov-append \ + --cov-report=xml \ + ${{ inputs.collect_args }} + + - uses: ./.github/actions/report + with: + flag: ${{ inputs.codecov_flags }} + codecov_token: ${{ inputs.codecov_token }} diff --git a/.github/actions/setup-backend/action.yml b/.github/actions/setup-backend/action.yml index 269ee76ed..d258d96e5 100644 --- a/.github/actions/setup-backend/action.yml +++ b/.github/actions/setup-backend/action.yml @@ -21,7 +21,7 @@ runs: enable-cache: true prune-cache: false python-version: ${{ inputs.python-version }} - version: '0.5.20' + version: '0.5.24' cache-suffix: ${{inputs.python-version}} - name: Install dependencies shell: bash @@ -31,6 +31,7 @@ runs: shell: bash run: | uv tool install codecov-cli --python 3.10 + uv tool update-shell # - name: Configure AWS Credentials # if: env.skip == '1' # uses: aws-actions/configure-aws-credentials@v2 diff --git a/.github/actions/setup-oss-repos/action.yml b/.github/actions/setup-oss-repos/action.yml new file mode 100644 index 000000000..4ec25be83 --- /dev/null +++ b/.github/actions/setup-oss-repos/action.yml @@ -0,0 +1,23 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-action.json +name: "Setup OSS repos" +description: "Setup OSS repos" +# TODO: add size filter +runs: + using: "composite" + steps: + - name: Cache oss-repos + id: cache-oss-repos + uses: actions/cache@v4 + with: + path: oss_repos + key: ${{ runner.os }}-repo-cache-2-${{hashFiles('codegen-backend/codegen_tests/graph_sitter/codemod/repos/open_source/*.json')}} + - name: Populate oss-repos if the cache is empty + if: steps.cache-oss-repos.outputs.cache-hit != 'true' + shell: bash + run: | + uv run --frozen python -m tests.shared.codemod.commands clone-repos --clean-cache + env: + GITHUB_WORKSPACE: $GITHUB_WORKSPACE + - name: Verify cache contents + shell: bash + run: ls -la $GITHUB_WORKSPACE/oss_repos/ diff --git a/.github/codecov.yml b/.github/codecov.yml index defec98ab..6ca52bcc7 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -55,6 +55,12 @@ flag_management: statuses: - type: 'project' - type: 'patch' + - name: smart-tests-integration-tests + carryforward: true + carryforward_mode: 'labels' + statuses: + - type: 'project' + - type: 'patch' comment: layout: "condensed_header, condensed_files" hide_project_coverage: true diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml new file mode 100644 index 000000000..d35187f41 --- /dev/null +++ b/.github/workflows/mypy.yml @@ -0,0 +1,48 @@ +name: Mypy Checks + +on: + pull_request: + branches: + - "develop" + +concurrency: + group: ${{ github.workflow_ref }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + mypy: + runs-on: ubuntu-latest + timeout-minutes: 20 + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup backend + uses: ./.github/actions/setup-backend + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v45.0.6 + + - name: Filter Python files + id: filter-python + run: | + python_files=() + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + if [[ $file == *.py ]]; then + python_files+=("${file}") + fi + done + echo "python_files=${python_files[*]}" >> $GITHUB_ENV + + - name: Add MyPy annotator + uses: pr-annotators/mypy-pr-annotator@v1.0.0 + + - name: Run mypy + if: ${{ env.python_files != '' }} + run: | + echo "Running mypy on changed files: ${{ env.python_files }}" + uv run mypy --no-pretty --show-absolute-path ${{ env.python_files }} diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index e5ed8252d..935ff52f4 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -4,6 +4,9 @@ on: pull_request: branches: - "develop" + push: + branches: + - "develop" jobs: pre-commit: @@ -23,10 +26,8 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} token: ${{ secrets.REPO_SCOPED_TOKEN }} - - name: Setup backend uses: ./.github/actions/setup-backend - - name: Setup-pre-commit run: uv tool install pre-commit --with pre-commit-uv --force-reinstall @@ -34,15 +35,14 @@ jobs: with: path: ~/.cache/pre-commit key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} - - - run: uv run --frozen pre-commit run --show-diff-on-failure --color=always --all-files --source ${{ github.event.pull_request.base.sha }} --origin ${{github.event.pull_request.head.sha }} --show-diff-on-failure --color=always + restore-keys: pre-commit + - run: uv run --frozen pre-commit run --show-diff-on-failure --color=always --all-files --source ${{ github.event.pull_request.base.sha }} --origin ${{github.event.pull_request.head.sha }} shell: bash env: - SKIP: disallowed-words-check + SKIP: disallowed-words-check,circleci_validate - # TODO: add back in - # - uses: stefanzweifel/git-auto-commit-action@v5 - # # Always commit changes even if pre-commit failed - # if: always() - # with: - # commit_message: "Automated pre-commit update" + - uses: stefanzweifel/git-auto-commit-action@v5 + # Always commit changes even if pre-commit failed + if: always() + with: + commit_message: "Automated pre-commit update" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 70ca3ee5a..bc1b60035 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,45 +3,54 @@ name: Upload Python Package on: push: tags: - - v* + - v*.** + branches: + - develop + pull_request: + branches: + - develop + - legacy/.* workflow_dispatch: + permissions: contents: read jobs: - build: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest-8, macos-latest] - python: [3.12, 3.13 ] - runs-on: ${{ matrix.os }} + os: [ubuntu-latest-8, macos-latest] + steps: - uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.ref || github.ref }} + - name: Setup backend uses: ./.github/actions/setup-backend with: - python-version: ${{ matrix.python }} + python-version: "3.12" + - name: Get history and tags for SCM versioning to work run: | git branch git fetch --depth=1 origin +refs/tags/*:refs/tags/* - - name: Build release distributions - run: | - uv build --wheel + - name: Build wheels + uses: pypa/cibuildwheel@v2.22.0 env: HATCH_BUILD_HOOKS_ENABLE: true - - name: Upload distributions - uses: actions/upload-artifact@v4 + + - uses: actions/upload-artifact@v4 with: - name: wheels-${{ matrix.os }}-${{ matrix.python }} - path: dist/ + name: wheels-${{ matrix.os }} + path: ./wheelhouse/*.whl release: - needs: build + needs: build_wheels runs-on: ubuntu-latest-8 permissions: contents: write @@ -50,12 +59,27 @@ jobs: - uses: actions/checkout@v4 - name: Setup backend uses: ./.github/actions/setup-backend + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-1 - name: Download All Artifacts uses: actions/download-artifact@v4 with: path: dist merge-multiple: true pattern: wheels-* + - name: Release to AWS codeartifact + run: | + export UV_PUBLISH_PASSWORD="$(aws codeartifact get-authorization-token --domain codegen --domain-owner 922078275900 --region us-east-1 --query authorizationToken --output text)" + export UV_PUBLISH_USERNAME=aws + uv publish + # - name: Release to pypi + # if: startsWith(github.ref, 'refs/tags/') + # run: | + # uv publish --trusted-publishing always --publish-url https://upload.pypi.org/legacy/ --keyring-provider disabled - name: Make github release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 000000000..cc8b62b1e --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,190 @@ +name: Unit Tests + +on: + push: + branches: + - "develop" + pull_request: + types: [ opened, synchronize, reopened, labeled ] + branches: + - "develop" + workflow_dispatch: + +jobs: + unit-tests: + # changing the following value will significantly affect github's cost. Be careful and consult with the team before changing it. + runs-on: ubuntu-latest-32 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup backend + uses: ./.github/actions/setup-backend + - name: Run ATS and Tests + uses: ./.github/actions/run_ats + with: + default_tests: "tests/unit" + codecov_static_token: ${{ secrets.CODECOV_STATIC_TOKEN }} + codecov_token: ${{ secrets.CODECOV_TOKEN }} + collect_args: "--timeout 5" + codecov_flags: smart-tests + test_codemods: + # changing the following value will significantly affect github's cost. Be careful and consult with the team before changing it. + runs-on: ubuntu-latest-32 + strategy: + matrix: + sync_graph: [ true, false ] + size: [ small, large ] + exclude: + # Exclude large codemod tests when not needed + - size: ${{(contains(github.event.pull_request.labels.*.name, 'big-codemod-tests') || github.event_name == 'push' || github.event_name == 'workflow_dispatch') && 'kevin' || 'large'}} + - size: large + sync_graph: true + concurrency: + group: ${{ github.workflow }}-${{github.ref}}-${{matrix.sync_graph}}-${{matrix.size}}-${{github.event_name == 'push'&& github.sha}} + cancel-in-progress: true + name: "Codemod tests ${{matrix.size}}: Sync Graph=${{matrix.sync_graph}}" + steps: + - uses: actions/checkout@v4 + - name: Setup backend + uses: ./.github/actions/setup-backend + - name: Cache oss-repos + uses: ./.github/actions/setup-oss-repos + - name: Run ATS and Tests + uses: ./.github/actions/run_ats + with: + default_tests: "tests/integration/codemod/test_codemods.py" + codecov_static_token: ${{ secrets.CODECOV_STATIC_TOKEN }} + codecov_token: ${{ secrets.CODECOV_TOKEN }} + collect_args: "--size=${{matrix.size}} --sync-graph=${{matrix.sync_graph}}" + ats_collect_args: "--size=${{matrix.size}},--sync-graph=${{matrix.sync_graph}}," + codecov_flags: smart-tests-codemod-tests-${{matrix.size}}-${{matrix.sync_graph}} + env: + GITHUB_WORKSPACE: $GITHUB_WORKSPACE + + # test_verified_codemods: + # # changing the following value will significantly affect github's cost. Be careful and consult with the team before changing it. + # if: false + # runs-on: ubuntu-latest-32 + # environment: testing + # concurrency: + # group: ${{ github.workflow }}-${{github.ref}}-${{github.event_name == 'push'&& github.sha}} + # cancel-in-progress: true + # name: "Verified Codemod tests: Sync Graph=false" + # steps: + # - uses: actions/checkout@v4 + # - name: Setup backend + # uses: ./.github/actions/setup-backend + # - name: Run ATS and Tests + # uses: ./.github/actions/run_ats + # with: + # default_tests: "tests/integration/codemod/test_verified_codemods.py" + # codecov_static_token: ${{ secrets.CODECOV_STATIC_TOKEN }} + # codecov_token: ${{ secrets.CODECOV_TOKEN }} + # collect_args: "--cli-api-key ${{ secrets.PROD_CLI_API_KEY }} --token ${{ secrets.CODEGEN_BOT_GHE_TOKEN }}" + # ats_collect_args: "--cli-api-key=${{ secrets.PROD_CLI_API_KEY }},--token=${{ secrets.CODEGEN_BOT_GHE_TOKEN }}," + # base_sha: ${{github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before}} + # job_name: ${{ github.job }} + # codecov_flags: smart-tests-verified-codemod-tests + # env: + # CODEGEN_BOT_GHE_TOKEN: ${{ secrets.CODEGEN_BOT_GHE_TOKEN }} + # GITHUB_WORKSPACE: $GITHUB_WORKSPACE + + parse-tests: + # changing the following value will significantly affect github's cost. Be careful and consult with the team before changing it. + runs-on: ubuntu-latest-32 + if: contains(github.event.pull_request.labels.*.name, 'extra-parse') || github.event_name == 'push' || github.event_name == 'workflow_dispatch' + + steps: + - uses: actions/checkout@v4 + - name: Setup backend + uses: ./.github/actions/setup-backend + + - name: Cache oss-repos + uses: ./.github/actions/setup-oss-repos + + - name: Install yarn and pnpm + run: | + npm install -g yarn & + npm install -g pnpm + + - name: Test with pytest + timeout-minutes: 15 + env: + GITHUB_WORKSPACE: $GITHUB_WORKSPACE + run: | + uv run pytest \ + -n auto \ + -o junit_suite_name="${{github.job}}" \ + tests/codemod/test_parse.py + - uses: ./.github/actions/report + with: + flag: no-flag + codecov_token: ${{ secrets.CODECOV_TOKEN }} + # test_codemod_diffs: + # # changing the following value will significantly affect github's cost. Be careful and consult with the team before changing it. + # runs-on: ubuntu-latest-16 + # + # steps: + # - uses: actions/checkout@v4 + # - name: Setup backend + # uses: ./.github/actions/setup-backend + # - name: Cache oss-repos + # uses: ./.github/actions/setup-oss-repos + # with: + # CODEGEN_BOT_GHE_TOKEN: ${{ secrets.CODEGEN_BOT_GHE_TOKEN }} + # - name: Test with pytest + # timeout-minutes: 10 + # run: | + # ENV=local \ + # uv run pytest \ + # -n auto \ + # -vv \ + # --token $CODEGEN_BOT_GHE_TOKEN \ + # tests/codemod/test_diffs.py + # env: + # CODEGEN_BOT_GHE_TOKEN: ${{ secrets.CODEGEN_BOT_GHE_TOKEN }} + # GITHUB_WORKSPACE: $GITHUB_WORKSPACE + # + # - name: Publish Test Report (Verify diffs) + # uses: mikepenz/action-junit-report@v4 + # if: (success() || failure()) # always publish report even if the tests fail + # continue-on-error: true + # with: + # report_paths: "**/build/test-results/test/TEST.xml" + # detailed_summary: true + # annotate_only: true + + # # Codecov is a required check but won't pass without a coverage report + # # Wwhen there are no changes in the backend (ex: frontend only change) we do an empty upload to force the check to pass + # - name: Upload empty coverage report to Codecov + # if: env.skip == '0' + # continue-on-error: true + # env: + # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + # run: | + # cd codegen-backend + # pip install codecov-cli + # codecovcli create-commit -C ${{ github.event.pull_request.head.sha }} + # codecovcli create-report -C ${{ github.event.pull_request.head.sha }} + # codecovcli do-upload --disable-search --file empty_coverage.xml -C ${{ github.event.pull_request.head.sha }} + # codecovcli empty-upload --force -C ${{ github.event.pull_request.head.sha }} + integration-tests: + runs-on: ubuntu-latest-16 + steps: + - uses: actions/checkout@v4 + - name: Setup backend + uses: ./.github/actions/setup-backend + - name: Test with pytest + timeout-minutes: 5 + env: + GITHUB_WORKSPACE: $GITHUB_WORKSPACE + run: | + uv run pytest \ + -n auto \ + -o junit_suite_name="${{github.job}}" \ + tests/integration/codegen + - uses: ./.github/actions/report + with: + flag: smart-tests-integration-tests + codecov_token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3ad614403..31fdf95fc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ default_language_version: - python: python3.12 + python: python3.13 fail_fast: true repos: diff --git a/tests/unit/codegen/sdk/code_generation/test_api_doc_generation.py b/tests/integration/codegen/sdk/code_generation/test_api_doc_generation.py similarity index 100% rename from tests/unit/codegen/sdk/code_generation/test_api_doc_generation.py rename to tests/integration/codegen/sdk/code_generation/test_api_doc_generation.py diff --git a/tests/unit/codegen/sdk/typescript/language_engine/test_node_engine.py b/tests/integration/codegen/sdk/typescript/language_engine/test_node_engine.py similarity index 97% rename from tests/unit/codegen/sdk/typescript/language_engine/test_node_engine.py rename to tests/integration/codegen/sdk/typescript/language_engine/test_node_engine.py index 19c868a45..7a23d7144 100644 --- a/tests/unit/codegen/sdk/typescript/language_engine/test_node_engine.py +++ b/tests/integration/codegen/sdk/typescript/language_engine/test_node_engine.py @@ -1,3 +1,5 @@ +import os + from codegen.sdk.codebase.factory.get_session import get_codebase_session from codegen.sdk.enums import ProgrammingLanguage @@ -50,6 +52,7 @@ def test_node_engine(tmpdir) -> None: return calculateArea(size, size); } """ + os.chdir(tmpdir) # TODO: CG-10643 with get_codebase_session(tmpdir=tmpdir, files={"tsconfig.json": ts_config, "file1.ts": content1}, programming_language=ProgrammingLanguage.TYPESCRIPT) as codebase: file = codebase.get_file("file1.ts") diff --git a/tests/unit/codegen/sdk/typescript/react/test_ts_declassify.py b/tests/integration/codegen/sdk/typescript/react/test_ts_declassify.py similarity index 97% rename from tests/unit/codegen/sdk/typescript/react/test_ts_declassify.py rename to tests/integration/codegen/sdk/typescript/react/test_ts_declassify.py index dc4f975a1..0b7acbd89 100644 --- a/tests/unit/codegen/sdk/typescript/react/test_ts_declassify.py +++ b/tests/integration/codegen/sdk/typescript/react/test_ts_declassify.py @@ -1,3 +1,4 @@ +import os from typing import TYPE_CHECKING from codegen.sdk.codebase.factory.get_session import get_codebase_session @@ -48,6 +49,8 @@ def test_declassify_class_component(tmpdir): } } """ + os.chdir(tmpdir) # TODO: CG-10643 + with get_codebase_session(tmpdir=tmpdir, files={"dir/file1.tsx": content}, programming_language=ProgrammingLanguage.TYPESCRIPT) as codebase: file: TSFile = codebase.get_file("dir/file1.tsx") component = file.get_class("C") diff --git a/tests/integration/codegen/test_imports.py b/tests/integration/codegen/test_imports.py index e2af00f64..6004c3ffc 100644 --- a/tests/integration/codegen/test_imports.py +++ b/tests/integration/codegen/test_imports.py @@ -1,5 +1,8 @@ +import os + import codegen from codegen import Codebase +from codegen.sdk.code_generation.current_code_codebase import get_graphsitter_repo_path def test_codegen_imports(): @@ -11,6 +14,6 @@ def run(codebase): # Test class cls = codegen.Function assert cls is not None - + os.chdir(get_graphsitter_repo_path()) # TODO: CG-10643 codebase = Codebase("./") assert codebase is not None