diff --git a/.github/actions/build-vscode-extension/action.yml b/.github/actions/build-vscode-extension/action.yml index d3a7bbcae..fb17816f2 100644 --- a/.github/actions/build-vscode-extension/action.yml +++ b/.github/actions/build-vscode-extension/action.yml @@ -32,6 +32,10 @@ outputs: runs: using: 'composite' steps: + - uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + - name: Set target variable id: set-target shell: bash diff --git a/.github/actions/run-jetbrains-tests/action.yml b/.github/actions/run-jetbrains-tests/action.yml new file mode 100644 index 000000000..b66b294e2 --- /dev/null +++ b/.github/actions/run-jetbrains-tests/action.yml @@ -0,0 +1,131 @@ +name: 'Run JetBrains Tests' +description: 'Setup and run JetBrains IntelliJ tests with all dependencies' + +runs: + using: 'composite' + steps: + - uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - uses: actions/cache@v4 + with: + path: core/node_modules + key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }} + + - name: Build packages and install core dependencies + shell: bash + run: | + node ./scripts/build-packages.js + cd core + npm ci + + - name: Setup Java + uses: actions/setup-java@v4.5.0 + with: + distribution: zulu + java-version: 17 + + - name: Setup FFmpeg + uses: AnimMouse/setup-ffmpeg@v1 + with: + token: ${{ env.GITHUB_TOKEN }} + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - uses: actions/cache@v4 + with: + path: ~/.npm + key: ${{ runner.os }}-npm-cache-jetbrains-${{ hashFiles('extensions/vscode/package-lock.json') }} + + - uses: actions/cache@v4 + id: vscode-extension-cache + with: + path: extensions/vscode/node_modules + key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }} + + - uses: actions/cache@v4 + id: gui-cache + with: + path: gui/node_modules + key: ${{ runner.os }}-gui-node-modules-${{ hashFiles('gui/package-lock.json') }} + + # Cache prepackaged extension build to share with other jobs + - uses: actions/cache@v4 + id: vscode-prepackage-cache + with: + path: extensions/vscode/build + key: ${{ runner.os }}-vscode-prepackage-${{ hashFiles('extensions/vscode/package-lock.json', 'extensions/vscode/**/*.ts', 'extensions/vscode/**/*.json') }} + + # Only run prepackage if not cached - saves ~1 minute + - name: Run prepackage script + if: steps.vscode-prepackage-cache.outputs.cache-hit != 'true' + shell: bash + run: | + cd extensions/vscode + if [ "${{ steps.vscode-extension-cache.outputs.cache-hit }}" != "true" ]; then + npm ci + fi + npm run prepackage + env: + # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333 + GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }} + + - uses: actions/cache@v4 + id: binary-cache + with: + path: binary/node_modules + key: ${{ runner.os }}-binary-node-modules-${{ hashFiles('binary/package-lock.json') }} + + - name: Build the binaries + shell: bash + run: | + cd binary + npm run build + + - name: Start test IDE + shell: bash + run: | + cd extensions/intellij + export DISPLAY=:99.0 + Xvfb -ac :99 -screen 0 1920x1080x24 & + sleep 10 + mkdir -p build/reports + ./gradlew runIdeForUiTests & + + - name: Wait for JB connection + uses: jtalk/url-health-check-action@v3 + with: + url: http://127.0.0.1:8082 + max-attempts: 15 + retry-delay: 30s + + - name: Run tests + shell: bash + run: | + cd extensions/intellij + export DISPLAY=:99.0 + ./gradlew test + + - name: Move video + if: ${{ failure() }} + shell: bash + run: | + cd extensions/intellij + mv video build/reports + + - name: Copy logs + if: ${{ failure() }} + shell: bash + run: | + cd extensions/intellij + mv build/idea-sandbox/system/log/ build/reports + + - name: Save fails report + if: ${{ failure() }} + uses: actions/upload-artifact@v4 + with: + name: jb-failure-report + path: | + ${{ github.workspace }}/extensions/intellij/build/reports \ No newline at end of file diff --git a/.github/actions/setup-component/action.yml b/.github/actions/setup-component/action.yml index fbc4eb273..d05de3bfb 100644 --- a/.github/actions/setup-component/action.yml +++ b/.github/actions/setup-component/action.yml @@ -16,6 +16,9 @@ inputs: runs: using: 'composite' steps: + - uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" - uses: actions/cache@v4 with: path: ~/.npm diff --git a/.github/actions/setup-packages/action.yml b/.github/actions/setup-packages/action.yml index dc0462d70..264cfe023 100644 --- a/.github/actions/setup-packages/action.yml +++ b/.github/actions/setup-packages/action.yml @@ -4,6 +4,9 @@ description: 'Cache and build packages with npm caching' runs: using: 'composite' steps: + - uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" - uses: actions/cache@v4 with: path: ~/.npm diff --git a/.github/actions/setup-vscode-e2e/action.yml b/.github/actions/setup-vscode-e2e/action.yml new file mode 100644 index 000000000..a0d720adf --- /dev/null +++ b/.github/actions/setup-vscode-e2e/action.yml @@ -0,0 +1,90 @@ +name: 'Setup VS Code E2E' +description: 'Build Linux extension and generate test matrix for E2E tests' +inputs: + is_fork: + description: 'Whether this is a fork (affects SSH tests)' + required: false + default: 'false' +outputs: + test_file_matrix: + description: 'JSON array of test files' + value: ${{ steps.get-test-files.outputs.test_file_matrix }} + +runs: + using: 'composite' + steps: + - uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + # Build the Linux extension first + - name: Build VS Code extension + uses: ./.github/actions/build-vscode-extension + with: + platform: linux + arch: x64 + npm_config_arch: x64 + pre-release: false + commit-sha: ${{ github.sha }} + env: + GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }} + + # Cache for test matrix generation + - name: Cache npm + uses: actions/cache@v4 + with: + path: ~/.npm + key: ${{ runner.os }}-npm-cache-matrix-${{ hashFiles('core/package-lock.json', 'extensions/vscode/package-lock.json') }} + + - name: Cache packages node_modules + uses: actions/cache@v4 + with: + path: | + packages/*/node_modules + key: ${{ runner.os }}-packages-node-modules-${{ hashFiles('packages/*/package-lock.json') }} + + - name: Cache core node modules + uses: actions/cache@v4 + with: + path: core/node_modules + key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }} + + - name: Cache vscode extension node modules + uses: actions/cache@v4 + id: vscode-cache + with: + path: extensions/vscode/node_modules + key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }} + + # Generate test matrix + - name: Build packages and get test files + id: get-test-files + shell: bash + run: | + node ./scripts/build-packages.js + if [ "${{ steps.vscode-cache.outputs.cache-hit }}" != "true" ]; then + cd core + npm ci + cd ../extensions/vscode + npm ci + fi + cd extensions/vscode + npm run e2e:compile + if [[ "${{ inputs.is_fork }}" == "true" ]]; then + # Exclude SSH tests for forks + FILES=$(ls -1 e2e/_output/tests/*.test.js | grep -v "SSH" | jq -R . | jq -s .) + else + # Include all tests for non-forks + FILES=$(ls -1 e2e/_output/tests/*.test.js | jq -R . | jq -s .) + fi + echo "test_file_matrix<> $GITHUB_OUTPUT + echo "$FILES" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + env: + # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333 + GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }} + + - name: Debug Outputs + shell: bash + run: | + echo "Test files: ${{ steps.get-test-files.outputs.test_file_matrix }}" \ No newline at end of file diff --git a/.github/workflows/pr-build-upload-vsix.yaml b/.github/workflows/pr-build-upload-vsix.yaml new file mode 100644 index 000000000..c629e5cb8 --- /dev/null +++ b/.github/workflows/pr-build-upload-vsix.yaml @@ -0,0 +1,52 @@ +name: PR Build Upload VSIX + +# Builds and uploads VSIX artifacts for the `oneper` script across Linux, Windows, and macOS ARM platforms +on: + pull_request: + branches: + - main + +jobs: + build-and-upload-vsix: + runs-on: ${{ matrix.runner }} + timeout-minutes: 10 + strategy: + matrix: + include: + - platform: linux + arch: x64 + runner: ubuntu-latest + - platform: win32 + arch: x64 + runner: windows-latest + - platform: darwin + arch: arm64 + runner: macos-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Build VS Code extension + uses: ./.github/actions/build-vscode-extension + with: + platform: ${{ matrix.platform }} + arch: ${{ matrix.arch }} + npm_config_arch: ${{ matrix.arch }} + pre-release: false + commit-sha: ${{ github.sha }} + env: + GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: vscode-extension-build-${{ matrix.platform }}-${{ matrix.arch }} + path: extensions/vscode/build + + - name: Upload .vsix artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.platform }}-${{ matrix.arch }}-vsix + path: "extensions/vscode/*.vsix" diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml new file mode 100644 index 000000000..720630397 --- /dev/null +++ b/.github/workflows/pr-checks.yaml @@ -0,0 +1,266 @@ +name: PR checks + +# PR Checks run on all PRs to the main branch and must pass before merging. +on: + pull_request: + branches: + - main + + push: + branches: + - main + +jobs: + prettier-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - uses: actions/cache@v4 + id: root-cache + with: + path: node_modules + key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }} + + - name: Install root dependencies + if: steps.root-cache.outputs.cache-hit != 'true' + run: npm ci + + - name: Check code formatting with Prettier + run: npx prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}" --ignore-path .gitignore --ignore-path .prettierignore + + core-checks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup packages + uses: ./.github/actions/setup-packages + - name: Setup core component + uses: ./.github/actions/setup-component + with: + component: core + include-root: true + + - name: Type check and lint + run: | + cd core + npx tsc --noEmit + npm run lint + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + + - name: Run tests + run: | + cd core + npm test + npm run vitest + env: + IGNORE_API_KEY_TESTS: ${{ github.event.pull_request.head.repo.fork == true || github.actor == 'dependabot[bot]' }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} + MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }} + AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} + AZURE_FOUNDRY_CODESTRAL_API_KEY: ${{ secrets.AZURE_FOUNDRY_CODESTRAL_API_KEY }} + AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY: ${{ secrets.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY }} + AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }} + + gui-checks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup packages + uses: ./.github/actions/setup-packages + - name: Setup core component + uses: ./.github/actions/setup-component + with: + component: core + include-root: true + - name: Setup gui component + uses: ./.github/actions/setup-component + with: + component: gui + include-packages: false + env: + GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} + + - name: Type check and lint + run: | + cd gui + npx tsc --noEmit + npm run lint + + - name: Run tests + run: | + cd gui + npm test + + binary-checks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup packages + uses: ./.github/actions/setup-packages + - name: Setup core component + uses: ./.github/actions/setup-component + with: + component: core + include-root: true + - name: Setup binary component + uses: ./.github/actions/setup-component + with: + component: binary + include-packages: false + + - name: Type check + run: | + cd binary + npx tsc --noEmit + + vscode-checks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup packages + uses: ./.github/actions/setup-packages + - name: Setup core component + uses: ./.github/actions/setup-component + with: + component: core + include-root: true + - name: Setup vscode component + uses: ./.github/actions/setup-component + with: + component: vscode + include-packages: false + env: + GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} + + - name: Type check and lint + run: | + cd extensions/vscode + npm run write-build-timestamp + npx tsc --noEmit + npm run lint + + - name: Run vitest tests + run: | + cd extensions/vscode + npm run vitest + + get-packages-matrix: + runs-on: ubuntu-latest + outputs: + packages: ${{ steps.get-packages.outputs.packages }} + steps: + - uses: actions/checkout@v4 + - name: Get package list + id: get-packages + run: | + packages=$(find packages/ -maxdepth 1 -type d -not -path packages/ -exec basename {} \; | sort | jq -R -s -c 'split("\n")[:-1]') + echo "packages=$packages" >> $GITHUB_OUTPUT + echo "Found packages: $packages" + + packages-checks: + needs: get-packages-matrix + runs-on: ubuntu-latest + strategy: + matrix: + package: ${{ fromJson(needs.get-packages-matrix.outputs.packages) }} + steps: + - uses: actions/checkout@v4 + - name: Setup packages + uses: ./.github/actions/setup-packages + + - name: Test and check ${{ matrix.package }} + run: | + cd packages/${{ matrix.package }} + npm test + env: + IGNORE_API_KEY_TESTS: ${{ github.event.pull_request.head.repo.fork == true || github.actor == 'dependabot[bot]' }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} + MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }} + AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} + AZURE_FOUNDRY_CODESTRAL_API_KEY: ${{ secrets.AZURE_FOUNDRY_CODESTRAL_API_KEY }} + AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY: ${{ secrets.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY }} + AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }} + VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }} + + vscode-e2e-setup: + runs-on: ubuntu-latest + timeout-minutes: 15 + outputs: + test_file_matrix: ${{ steps.setup.outputs.test_file_matrix }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup E2E tests and build extension + id: setup + uses: ./.github/actions/setup-vscode-e2e + with: + is_fork: ${{ github.event.pull_request.head.repo.fork == true || github.actor == 'dependabot[bot]' }} + env: + GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} + + vscode-e2e-tests: + name: ${{ matrix.test_file || 'unknown' }} (${{ matrix.command }}) + needs: vscode-e2e-setup + runs-on: ubuntu-latest + timeout-minutes: 15 + # Tests requiring secrets need approval from maintainers + strategy: + fail-fast: false + matrix: + test_file: ${{ fromJson(needs.vscode-e2e-setup.outputs.test_file_matrix) }} + command: ["e2e:ci:run", "e2e:ci:run-yaml"] + steps: + - uses: actions/checkout@v4 + - name: Run VS Code E2E test + uses: ./.github/actions/run-vscode-e2e-test + with: + test_file: ${{ matrix.test_file }} + command: ${{ matrix.command }} + ssh_key: ${{ secrets.GH_ACTIONS_SSH_TEST_KEY_PEM }} + ssh_host: ${{ secrets.GH_ACTIONS_SSH_TEST_DNS_NAME }} + is_fork: ${{ github.event.pull_request.head.repo.fork == true || github.actor == 'dependabot[bot]' }} + + jetbrains-tests: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - name: Run JetBrains tests + uses: ./.github/actions/run-jetbrains-tests + env: + GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} + + # GitHub does not have a way of requiring that all checks pass (you must manually select each job) + # This action at least lets us manage the list of required tests via source control + # so that creators of new jobs can add them to this list + require-all-checks-to-pass: + if: always() + runs-on: ubuntu-latest + needs: + - prettier-check + - core-checks + - gui-checks + - binary-checks + - vscode-checks + - get-packages-matrix + - packages-checks + - vscode-e2e-setup + - vscode-e2e-tests + - jetbrains-tests + + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml deleted file mode 100644 index b31890e4a..000000000 --- a/.github/workflows/pr_checks.yaml +++ /dev/null @@ -1,516 +0,0 @@ -name: PR checks - -# PR Checks run on all PRs to the main branch and must pass before merging. -on: - pull_request: - branches: - - main - - push: - branches: - - main - -jobs: - prettier-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: ".nvmrc" - - - uses: actions/cache@v4 - id: root-cache - with: - path: node_modules - key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }} - - - name: Install root dependencies - if: steps.root-cache.outputs.cache-hit != 'true' - run: npm ci - - - name: Check code formatting with Prettier - run: npx prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}" --ignore-path .gitignore --ignore-path .prettierignore - - core-checks: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: ".nvmrc" - - name: Setup packages - uses: ./.github/actions/setup-packages - - name: Setup core component - uses: ./.github/actions/setup-component - with: - component: core - include-root: true - - - name: Type check and lint - run: | - cd core - npx tsc --noEmit - npm run lint - env: - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - - - name: Run tests - run: | - cd core - npm test - npm run vitest - env: - IGNORE_API_KEY_TESTS: ${{ github.event.pull_request.head.repo.fork == true || github.actor == 'dependabot[bot]' }} - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} - GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} - MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }} - AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} - AZURE_FOUNDRY_CODESTRAL_API_KEY: ${{ secrets.AZURE_FOUNDRY_CODESTRAL_API_KEY }} - AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY: ${{ secrets.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY }} - AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }} - - gui-checks: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: ".nvmrc" - - name: Setup packages - uses: ./.github/actions/setup-packages - - name: Setup core component - uses: ./.github/actions/setup-component - with: - component: core - include-root: true - - name: Setup gui component - uses: ./.github/actions/setup-component - with: - component: gui - include-packages: false - env: - GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} - - - name: Type check and lint - run: | - cd gui - npx tsc --noEmit - npm run lint - - - name: Run tests - run: | - cd gui - npm test - - binary-checks: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: ".nvmrc" - - name: Setup packages - uses: ./.github/actions/setup-packages - - name: Setup core component - uses: ./.github/actions/setup-component - with: - component: core - include-root: true - - name: Setup binary component - uses: ./.github/actions/setup-component - with: - component: binary - include-packages: false - - - name: Type check - run: | - cd binary - npx tsc --noEmit - - vscode-checks: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: ".nvmrc" - - name: Setup packages - uses: ./.github/actions/setup-packages - - name: Setup core component - uses: ./.github/actions/setup-component - with: - component: core - include-root: true - - name: Setup vscode component - uses: ./.github/actions/setup-component - with: - component: vscode - include-packages: false - env: - GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} - - - name: Type check and lint - run: | - cd extensions/vscode - npm run write-build-timestamp - npx tsc --noEmit - npm run lint - - - name: Run vitest tests - run: | - cd extensions/vscode - npm run vitest - - get-packages-matrix: - runs-on: ubuntu-latest - outputs: - packages: ${{ steps.get-packages.outputs.packages }} - steps: - - uses: actions/checkout@v4 - - name: Get package list - id: get-packages - run: | - packages=$(find packages/ -maxdepth 1 -type d -not -path packages/ -exec basename {} \; | sort | jq -R -s -c 'split("\n")[:-1]') - echo "packages=$packages" >> $GITHUB_OUTPUT - echo "Found packages: $packages" - - packages-checks: - needs: get-packages-matrix - runs-on: ubuntu-latest - strategy: - matrix: - package: ${{ fromJson(needs.get-packages-matrix.outputs.packages) }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: ".nvmrc" - - name: Setup packages - uses: ./.github/actions/setup-packages - - - name: Test and check ${{ matrix.package }} - run: | - cd packages/${{ matrix.package }} - npm test - env: - IGNORE_API_KEY_TESTS: ${{ github.event.pull_request.head.repo.fork == true || github.actor == 'dependabot[bot]' }} - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} - GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} - MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }} - AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} - AZURE_FOUNDRY_CODESTRAL_API_KEY: ${{ secrets.AZURE_FOUNDRY_CODESTRAL_API_KEY }} - AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY: ${{ secrets.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY }} - AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }} - VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }} - - vscode-get-test-file-matrix: - runs-on: ubuntu-latest - outputs: - test_file_matrix: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }} - steps: - - uses: actions/checkout@v4 - - - name: Cache npm - uses: actions/cache@v4 - with: - path: ~/.npm - key: ${{ runner.os }}-npm-cache-matrix-${{ hashFiles('core/package-lock.json', 'extensions/vscode/package-lock.json') }} - - - name: Cache packages node_modules - uses: actions/cache@v4 - with: - path: | - packages/*/node_modules - key: ${{ runner.os }}-packages-node-modules-${{ hashFiles('packages/*/package-lock.json') }} - - - name: Cache core node modules - uses: actions/cache@v4 - with: - path: core/node_modules - key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }} - - - name: Cache vscode extension node modules - uses: actions/cache@v4 - id: vscode-cache - with: - path: extensions/vscode/node_modules - key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }} - - - name: Build packages and get test files - id: vscode-get-test-file-matrix - run: | - node ./scripts/build-packages.js - if [ "${{ steps.vscode-cache.outputs.cache-hit }}" != "true" ]; then - cd core - npm ci - cd ../extensions/vscode - npm ci - fi - cd extensions/vscode - npm run e2e:compile - if [[ "${{ github.event.pull_request.head.repo.fork }}" == "true" || "${{ github.actor }}" == "dependabot[bot]" ]]; then - # Exclude SSH tests for forks - FILES=$(ls -1 e2e/_output/tests/*.test.js | grep -v "SSH" | jq -R . | jq -s .) - else - # Include all tests for non-forks - FILES=$(ls -1 e2e/_output/tests/*.test.js | jq -R . | jq -s .) - fi - echo "test_file_matrix<> $GITHUB_OUTPUT - echo "$FILES" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - env: - # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333 - GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} - - - name: Debug Outputs - run: | - echo "Test files: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }}" - - vscode-package-extension-linux: - runs-on: ubuntu-latest - timeout-minutes: 15 - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: actions/setup-node@v4 - with: - node-version-file: ".nvmrc" - - - name: Build VS Code extension - uses: ./.github/actions/build-vscode-extension - with: - platform: linux - arch: x64 - npm_config_arch: x64 - pre-release: false - commit-sha: ${{ github.sha }} - env: - GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} - - - name: Upload build artifact - uses: actions/upload-artifact@v4 - with: - name: vscode-extension-build-Linux - path: extensions/vscode/build - - - name: Upload .vsix artifact - uses: actions/upload-artifact@v4 - with: - name: linux-x64-vsix - path: "extensions/vscode/*.vsix" - - vscode-package-extension-macos: - runs-on: macos-13 - timeout-minutes: 15 - continue-on-error: true - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: actions/setup-node@v4 - with: - node-version-file: ".nvmrc" - - - name: Build VS Code extension - uses: ./.github/actions/build-vscode-extension - with: - platform: darwin - arch: x64 - npm_config_arch: x64 - pre-release: false - commit-sha: ${{ github.sha }} - env: - GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} - - - name: Upload build artifact - uses: actions/upload-artifact@v4 - with: - name: vscode-extension-build-macOS - path: extensions/vscode/build - - - name: Upload .vsix artifact - uses: actions/upload-artifact@v4 - with: - name: darwin-x64-vsix - path: "extensions/vscode/*.vsix" - - vscode-e2e-tests: - name: ${{ matrix.test_file || 'unknown' }} (${{ matrix.command }}) - needs: [vscode-get-test-file-matrix, vscode-package-extension-linux] - runs-on: ubuntu-latest - timeout-minutes: 15 - # Tests requiring secrets need approval from maintainers - strategy: - fail-fast: false - matrix: - test_file: ${{ fromJson(needs.vscode-get-test-file-matrix.outputs.test_file_matrix) }} - command: ["e2e:ci:run", "e2e:ci:run-yaml"] - steps: - - uses: actions/checkout@v4 - - name: Run VS Code E2E test - uses: ./.github/actions/run-vscode-e2e-test - with: - test_file: ${{ matrix.test_file }} - command: ${{ matrix.command }} - ssh_key: ${{ secrets.GH_ACTIONS_SSH_TEST_KEY_PEM }} - ssh_host: ${{ secrets.GH_ACTIONS_SSH_TEST_DNS_NAME }} - is_fork: ${{ github.event.pull_request.head.repo.fork == true || github.actor == 'dependabot[bot]' }} - - jetbrains-tests: - runs-on: ubuntu-latest - timeout-minutes: 20 - steps: - - uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: core/node_modules - key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }} - - - name: Build packages and install core dependencies - run: | - node ./scripts/build-packages.js - cd core - npm ci - - - name: Setup Java - uses: actions/setup-java@v4.5.0 - with: - distribution: zulu - java-version: 17 - - - name: Setup FFmpeg - uses: AnimMouse/setup-ffmpeg@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 - - - name: Use Node.js from .nvmrc - uses: actions/setup-node@v4 - with: - node-version-file: ".nvmrc" - - - uses: actions/cache@v4 - with: - path: ~/.npm - key: ${{ runner.os }}-npm-cache-jetbrains-${{ hashFiles('extensions/vscode/package-lock.json') }} - - - uses: actions/cache@v4 - id: vscode-extension-cache - with: - path: extensions/vscode/node_modules - key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }} - - - uses: actions/cache@v4 - id: gui-cache - with: - path: gui/node_modules - key: ${{ runner.os }}-gui-node-modules-${{ hashFiles('gui/package-lock.json') }} - - # Cache prepackaged extension build to share with other jobs - - uses: actions/cache@v4 - id: vscode-prepackage-cache - with: - path: extensions/vscode/build - key: ${{ runner.os }}-vscode-prepackage-${{ hashFiles('extensions/vscode/package-lock.json', 'extensions/vscode/**/*.ts', 'extensions/vscode/**/*.json') }} - - # Only run prepackage if not cached - saves ~1 minute - - name: Run prepackage script - if: steps.vscode-prepackage-cache.outputs.cache-hit != 'true' - run: | - cd extensions/vscode - if [ "${{ steps.vscode-extension-cache.outputs.cache-hit }}" != "true" ]; then - npm ci - fi - npm run prepackage - env: - # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333 - GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} - - - uses: actions/cache@v4 - id: binary-cache - with: - path: binary/node_modules - key: ${{ runner.os }}-binary-node-modules-${{ hashFiles('binary/package-lock.json') }} - - - name: Build the binaries - run: | - cd binary - npm run build - - - name: Start test IDE - run: | - cd extensions/intellij - export DISPLAY=:99.0 - Xvfb -ac :99 -screen 0 1920x1080x24 & - sleep 10 - mkdir -p build/reports - ./gradlew runIdeForUiTests & - - - name: Wait for JB connection - uses: jtalk/url-health-check-action@v3 - with: - url: http://127.0.0.1:8082 - max-attempts: 15 - retry-delay: 30s - - - name: Run tests - run: | - cd extensions/intellij - export DISPLAY=:99.0 - ./gradlew test - - - name: Move video - if: ${{ failure() }} - run: | - cd extensions/intellij - mv video build/reports - - - name: Copy logs - if: ${{ failure() }} - run: | - cd extensions/intellij - mv build/idea-sandbox/system/log/ build/reports - - - name: Save fails report - if: ${{ failure() }} - uses: actions/upload-artifact@v4 - with: - name: jb-failure-report - path: | - ${{ github.workspace }}/extensions/intellij/build/reports - - # GitHub does not have a way of requiring that all checks pass (you must manually select each job) - # This action at least lets us manage the list of required tests via source control - # so that creators of new jobs can add them to this list - require-all-checks-to-pass: - if: always() - runs-on: ubuntu-latest - needs: - - prettier-check - - core-checks - - gui-checks - - binary-checks - - vscode-checks - - get-packages-matrix - - packages-checks - - vscode-get-test-file-matrix - - vscode-package-extension-linux - - vscode-package-extension-macos - - vscode-e2e-tests - - jetbrains-tests - - steps: - - name: Decide whether the needed jobs succeeded or failed - uses: re-actors/alls-green@release/v1 - with: - jobs: ${{ toJSON(needs) }} - ## Currently we only use `vscode-package-extension-macos` for publishing build artifacts for `oneper` script - allowed-failures: vscode-package-extension-macos diff --git a/scripts/oneper b/scripts/oneper index 003d72df1..e68ad0a6e 100755 --- a/scripts/oneper +++ b/scripts/oneper @@ -200,14 +200,14 @@ install_from_pr() { exit 1 fi - # Map platform names to GitHub runner OS names - local artifact_suffix + # Map platform names to artifact names for the new workflow + local artifact_name case "$platform" in "macos") - artifact_suffix="macOS" + artifact_name="darwin-arm64-vsix" ;; "linux") - artifact_suffix="Linux" + artifact_name="linux-x64-vsix" ;; *) echo "❌ Unknown platform: $platform" @@ -231,7 +231,7 @@ install_from_pr() { # Get the latest successful workflow run for the branch local run_id=$(gh run list \ --repo "$REPO" \ - --workflow="pr_checks.yaml" \ + --workflow="pr-build-upload-vsix.yaml" \ --branch="$branch_name" \ --json databaseId,status,conclusion \ --jq ".[] | select(.status == \"completed\" and .conclusion == \"success\") | .databaseId" \ @@ -244,7 +244,7 @@ install_from_pr() { fi echo "✅ Found workflow run: $run_id" - echo "📥 Downloading vscode-extension-build-$artifact_suffix artifact..." + echo "📥 Downloading $artifact_name artifact..." # Create temporary directory for download local temp_dir=$(mktemp -d) @@ -252,9 +252,9 @@ install_from_pr() { # Download the artifact if ! gh run download "$run_id" \ --repo "$REPO" \ - --name "vscode-extension-build-$artifact_suffix" \ + --name "$artifact_name" \ --dir "$temp_dir"; then - echo "❌ Failed to download artifact vscode-extension-build-$artifact_suffix" + echo "❌ Failed to download artifact $artifact_name" echo " Make sure the workflow run completed successfully for $platform" rm -rf "$temp_dir" exit 1