diff --git a/.github/workflows/cli_tests.yml b/.github/workflows/cli_tests.yml index 47fd73c8ea..83287db39f 100644 --- a/.github/workflows/cli_tests.yml +++ b/.github/workflows/cli_tests.yml @@ -7,6 +7,11 @@ on: required: false type: string default: '' + run: + description: 'Whether to actually run the build and tests. When false the matrix jobs are skipped (reported as success to required checks).' + required: false + type: boolean + default: true secrets: E2B_API_KEY: required: true @@ -16,6 +21,7 @@ permissions: jobs: test: + if: ${{ inputs.run }} defaults: run: working-directory: ./packages/cli diff --git a/.github/workflows/generated_files.yml b/.github/workflows/generated_files.yml index ff06ad5c23..20d5e99410 100644 --- a/.github/workflows/generated_files.yml +++ b/.github/workflows/generated_files.yml @@ -7,8 +7,35 @@ permissions: contents: read jobs: + changes: + name: Detect changes + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + outputs: + generated: ${{ steps.filter.outputs.generated }} + steps: + - name: Filter changed paths + uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + generated: + - 'spec/**' + - 'codegen.Dockerfile' + - 'Makefile' + - 'packages/**' + - 'pnpm-lock.yaml' + - 'pnpm-workspace.yaml' + - 'package.json' + - '.tool-versions' + - '.github/workflows/generated_files.yml' + check-generated: name: Generated files + needs: changes + if: ${{ needs.changes.outputs.generated == 'true' }} runs-on: ubuntu-latest steps: diff --git a/.github/workflows/js_sdk_tests.yml b/.github/workflows/js_sdk_tests.yml index e235b9b221..a5e4000800 100644 --- a/.github/workflows/js_sdk_tests.yml +++ b/.github/workflows/js_sdk_tests.yml @@ -7,6 +7,11 @@ on: required: false type: string default: '' + run: + description: 'Whether to actually run the build and tests. When false the matrix jobs are skipped (reported as success to required checks).' + required: false + type: boolean + default: true secrets: E2B_API_KEY: required: true @@ -16,6 +21,7 @@ permissions: jobs: test: + if: ${{ inputs.run }} defaults: run: working-directory: ./packages/js-sdk diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bcce93ac69..21e6dca8fd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -6,8 +6,37 @@ on: pull_request: jobs: + changes: + name: Detect changes + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + outputs: + code: ${{ steps.filter.outputs.code }} + steps: + - name: Filter changed paths + uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + code: + - 'packages/**' + - 'spec/**' + - '.eslintrc.cjs' + - '.prettierrc' + - '.prettierignore' + - '.editorconfig' + - 'pnpm-lock.yaml' + - 'pnpm-workspace.yaml' + - 'package.json' + - '.tool-versions' + - '.github/workflows/lint.yml' + lint: name: Lint + needs: changes + if: ${{ needs.changes.outputs.code == 'true' }} runs-on: ubuntu-latest steps: diff --git a/.github/workflows/python_sdk_tests.yml b/.github/workflows/python_sdk_tests.yml index 6c74f777b7..a4b1be8366 100644 --- a/.github/workflows/python_sdk_tests.yml +++ b/.github/workflows/python_sdk_tests.yml @@ -7,6 +7,11 @@ on: required: false type: string default: '' + run: + description: 'Whether to actually run the build and tests. When false the matrix jobs are skipped (reported as success to required checks).' + required: false + type: boolean + default: true secrets: E2B_API_KEY: required: true @@ -16,6 +21,7 @@ permissions: jobs: test: + if: ${{ inputs.run }} defaults: run: working-directory: ./packages/python-sdk diff --git a/.github/workflows/sdk_tests.yml b/.github/workflows/sdk_tests.yml index 6e26cd1b85..cacc1fe978 100644 --- a/.github/workflows/sdk_tests.yml +++ b/.github/workflows/sdk_tests.yml @@ -10,44 +10,101 @@ permissions: contents: read jobs: + changes: + name: Detect changes + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + outputs: + js: ${{ steps.filter.outputs.js }} + python: ${{ steps.filter.outputs.python }} + cli: ${{ steps.filter.outputs.cli }} + steps: + - name: Filter changed paths + # On workflow_dispatch there is no PR diff and paths-filter would fall + # back to git (failing without a checkout); the run inputs below force a + # full run for that event instead, so we only filter on pull_request. + if: github.event_name == 'pull_request' + uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + shared: &shared + - '.github/workflows/sdk_tests.yml' + - 'spec/**' + - 'pnpm-lock.yaml' + - 'pnpm-workspace.yaml' + - 'package.json' + - '.tool-versions' + js: + - *shared + - '.github/workflows/js_sdk_tests.yml' + - 'packages/js-sdk/**' + python: + - *shared + - '.github/workflows/python_sdk_tests.yml' + - 'packages/python-sdk/**' + - 'packages/connect-python/**' + cli: + - *shared + - '.github/workflows/cli_tests.yml' + - 'packages/cli/**' + - 'packages/js-sdk/**' + js-tests: name: Production / JS SDK Tests + needs: changes uses: ./.github/workflows/js_sdk_tests.yml + with: + run: ${{ needs.changes.outputs.js == 'true' || github.event_name == 'workflow_dispatch' }} secrets: E2B_API_KEY: ${{ secrets.E2B_API_KEY }} python-tests: name: Production / Python SDK Tests + needs: changes uses: ./.github/workflows/python_sdk_tests.yml + with: + run: ${{ needs.changes.outputs.python == 'true' || github.event_name == 'workflow_dispatch' }} secrets: E2B_API_KEY: ${{ secrets.E2B_API_KEY }} cli-tests: name: Production / CLI Tests + needs: changes uses: ./.github/workflows/cli_tests.yml + with: + run: ${{ needs.changes.outputs.cli == 'true' || github.event_name == 'workflow_dispatch' }} secrets: E2B_API_KEY: ${{ secrets.E2B_API_KEY }} js-tests-staging: name: Staging / JS SDK Tests + needs: changes uses: ./.github/workflows/js_sdk_tests.yml with: E2B_DOMAIN: ${{ vars.E2B_DOMAIN_STAGING }} + run: ${{ needs.changes.outputs.js == 'true' || github.event_name == 'workflow_dispatch' }} secrets: E2B_API_KEY: ${{ secrets.E2B_API_KEY_STAGING }} python-tests-staging: name: Staging / Python SDK Tests + needs: changes uses: ./.github/workflows/python_sdk_tests.yml with: E2B_DOMAIN: ${{ vars.E2B_DOMAIN_STAGING }} + run: ${{ needs.changes.outputs.python == 'true' || github.event_name == 'workflow_dispatch' }} secrets: E2B_API_KEY: ${{ secrets.E2B_API_KEY_STAGING }} cli-tests-staging: name: Staging / CLI Tests + needs: changes uses: ./.github/workflows/cli_tests.yml with: E2B_DOMAIN: ${{ vars.E2B_DOMAIN_STAGING }} + run: ${{ needs.changes.outputs.cli == 'true' || github.event_name == 'workflow_dispatch' }} secrets: E2B_API_KEY: ${{ secrets.E2B_API_KEY_STAGING }} diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml index 09e33d32cd..277b3966b5 100644 --- a/.github/workflows/typecheck.yml +++ b/.github/workflows/typecheck.yml @@ -4,8 +4,33 @@ on: pull_request: jobs: + changes: + name: Detect changes + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + outputs: + code: ${{ steps.filter.outputs.code }} + steps: + - name: Filter changed paths + uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + code: + - 'packages/**' + - 'spec/**' + - 'pnpm-lock.yaml' + - 'pnpm-workspace.yaml' + - 'package.json' + - '.tool-versions' + - '.github/workflows/typecheck.yml' + typecheck: name: Typecheck + needs: changes + if: ${{ needs.changes.outputs.code == 'true' }} runs-on: ubuntu-latest permissions: contents: read