diff --git a/.github/actions/zimic-setup/action.yaml b/.github/actions/zimic-setup/action.yaml index fd825ae8..44dd083e 100644 --- a/.github/actions/zimic-setup/action.yaml +++ b/.github/actions/zimic-setup/action.yaml @@ -69,8 +69,6 @@ runs: id: install-dependencies shell: bash run: | - workspaceRootInstallFlag='--filter zimic-root' - function composeFilterOptions() { filterEntries=${*} filterOptions=() @@ -82,13 +80,25 @@ runs: echo "${filterOptions[@]}" } - partialInstallFlag="$(composeFilterOptions ${{ inputs.install }})" - installFlag="$workspaceRootInstallFlag $partialInstallFlag" - echo "install-filters=$installFlag" >> $GITHUB_OUTPUT + if [[ '${{ inputs.install }}' == '' ]]; then + workspaceRootInstallFlag='' + partialInstallFlag='' + installFlag='' + else + workspaceRootInstallFlag='--filter zimic-root' + partialInstallFlag="$(composeFilterOptions ${{ inputs.install }})" + installFlag="$workspaceRootInstallFlag $partialInstallFlag" + fi + echo "install-filters=$installFlag" >> $GITHUB_OUTPUT pnpm install --prefer-offline --frozen-lockfile --ignore-scripts $installFlag - buildFlag="$(composeFilterOptions ${{ inputs.build }})" + if [[ '${{ inputs.build }}' == '' ]]; then + buildFlag='' + else + buildFlag="$(composeFilterOptions ${{ inputs.build }})" + fi + echo "build-filters=$buildFlag" >> $GITHUB_OUTPUT NODE_ENV='${{ inputs.build-node-env }}' pnpm turbo build $buildFlag diff --git a/.github/workflows/cache.yaml b/.github/workflows/cache.yaml index d5ec17f6..8591a44c 100644 --- a/.github/workflows/cache.yaml +++ b/.github/workflows/cache.yaml @@ -27,6 +27,9 @@ jobs: - 18 - 20 + env: + NODE_VERSION: ${{ matrix.node-version }} + steps: - name: Checkout code uses: actions/checkout@v3 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f91df59e..e485f53e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,6 +14,8 @@ concurrency: env: CI: true + IS_PULL_REQUEST_TO_MAIN: + ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' && 'true' || 'false' }} TURBO_LOG_ORDER: stream TURBO_TOKEN: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') && @@ -28,20 +30,13 @@ env: "{./packages/*}[HEAD^1]..."' || './packages/*' }} jobs: - ci: - name: CI + ci-general: + name: CI General runs-on: ubuntu-latest - timeout-minutes: 12 - - strategy: - fail-fast: false - matrix: - node-version: - - 18 - - 20 + timeout-minutes: 10 env: - NODE_VERSION: ${{ matrix.node-version }} + NODE_VERSION: 20 steps: - name: Checkout code @@ -53,20 +48,18 @@ jobs: id: zimic-setup uses: ./.github/actions/zimic-setup with: - node-version: ${{ matrix.node-version }} + node-version: ${{ env.NODE_VERSION }} turbo-token: ${{ env.TURBO_TOKEN }} turbo-team: ${{ env.TURBO_TEAM }} install: ${{ env.INSTALL_OPTIONS }} build: ${{ env.BUILD_OPTIONS }} - build-node-env: - ${{ !(github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') && 'development' - || 'production' }} + build-node-env: ${{ env.IS_PULL_REQUEST_TO_MAIN == 'false' && 'development' || 'production' }} install-playwright-browsers: true - name: Check formatting style uses: ./.github/actions/zimic-style-check with: - node-version: ${{ matrix.node-version }} + node-version: ${{ env.NODE_VERSION }} - name: Lint code and check types run: | @@ -74,7 +67,40 @@ jobs: types:check lint:turbo \ --continue \ --concurrency 100% \ - ${{ !(github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') && steps.zimic-setup.outputs.install-filters || '' }} + ${{ steps.zimic-setup.outputs.install-filters }} + + ci-node: + name: CI Node.js + runs-on: ubuntu-latest + timeout-minutes: 10 + + strategy: + fail-fast: false + matrix: + node-version: + - 18 + - 20 + + env: + NODE_VERSION: ${{ matrix.node-version }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Setup Zimic + id: zimic-setup + uses: ./.github/actions/zimic-setup + with: + node-version: ${{ env.NODE_VERSION }} + turbo-token: ${{ env.TURBO_TOKEN }} + turbo-team: ${{ env.TURBO_TEAM }} + install: ${{ env.INSTALL_OPTIONS }} + build: ${{ env.BUILD_OPTIONS }} + build-node-env: ${{ env.IS_PULL_REQUEST_TO_MAIN == 'false' && 'development' || 'production' }} + install-playwright-browsers: true - name: Run tests run: | @@ -82,4 +108,63 @@ jobs: test:turbo \ --continue \ --concurrency 100% \ - ${{ !(github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') && steps.zimic-setup.outputs.install-filters || '' }} + ${{ steps.zimic-setup.outputs.install-filters }} + + ci-typescript: + name: CI TypeScript + runs-on: ubuntu-latest + timeout-minutes: 10 + + strategy: + fail-fast: false + matrix: + typescript-version: + - 4.7 + - 4.8 + - 4.9 + - 5.0 + - 5.1 + - 5.2 + - 5.3 + - 5.4 + + env: + NODE_VERSION: 20 + TYPESCRIPT_VERSION: ${{ matrix.typescript-version }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Setup Zimic + id: zimic-setup + uses: ./.github/actions/zimic-setup + with: + node-version: ${{ env.NODE_VERSION }} + turbo-token: ${{ env.TURBO_TOKEN }} + turbo-team: ${{ env.TURBO_TEAM }} + install: ${{ env.INSTALL_OPTIONS }} + build: ${{ env.BUILD_OPTIONS }} + build-node-env: ${{ env.IS_PULL_REQUEST_TO_MAIN == 'false' && 'development' || 'production' }} + install-playwright-browsers: false + + - name: Set TypeScript version + run: | + pnpm update \ + typescript@${{ matrix.typescript-version }} \ + --recursive \ + ${{ steps.zimic-setup.outputs.install-filters }} \ + --filter !zimic \ + --filter !@zimic/* + + - name: Check types + run: | + pnpm turbo \ + types:check \ + --continue \ + --concurrency 100% \ + ${{ steps.zimic-setup.outputs.install-filters }} \ + --filter !zimic \ + --filter !@zimic/* diff --git a/apps/zimic-test-client/tests/v0/interceptor/thirdParty/superagent/utils.ts b/apps/zimic-test-client/tests/v0/interceptor/thirdParty/superagent/utils.ts index 5f5caf43..c2d62cce 100644 --- a/apps/zimic-test-client/tests/v0/interceptor/thirdParty/superagent/utils.ts +++ b/apps/zimic-test-client/tests/v0/interceptor/thirdParty/superagent/utils.ts @@ -22,7 +22,7 @@ export async function superagentAsFetch(request: Request): Promise { throw error; } - const superagentResponse = error.response as SuperagentResponse; + const { response: superagentResponse } = error as Error & { response: SuperagentResponse }; return new Response(superagentResponse.text, { status: superagentResponse.status, diff --git a/examples/package.json b/examples/package.json index a950d8ac..45c7c4ca 100644 --- a/examples/package.json +++ b/examples/package.json @@ -15,7 +15,6 @@ "devDependencies": { "@zimic/eslint-config-node": "workspace:*", "@zimic/lint-staged-config": "workspace:*", - "@zimic/tsconfig": "workspace:*", - "typescript": "^5.4.3" + "@zimic/tsconfig": "workspace:*" } } diff --git a/examples/with-jest-node/package.json b/examples/with-jest-node/package.json index 4260686c..78c9d2e1 100644 --- a/examples/with-jest-node/package.json +++ b/examples/with-jest-node/package.json @@ -8,7 +8,7 @@ "types:check": "tsc --noEmit" }, "dependencies": { - "fastify": "^4.26.1", + "fastify": "4.23.2", "zimic": "latest", "zod": "^3.22.4" }, diff --git a/examples/with-vitest-node/package.json b/examples/with-vitest-node/package.json index 18d0ddd3..e31292fe 100644 --- a/examples/with-vitest-node/package.json +++ b/examples/with-vitest-node/package.json @@ -8,7 +8,7 @@ "types:check": "tsc --noEmit" }, "dependencies": { - "fastify": "^4.26.1", + "fastify": "4.23.2", "zimic": "latest", "zod": "^3.22.4" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7544c842..191c727c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -100,9 +100,6 @@ importers: '@zimic/tsconfig': specifier: workspace:* version: link:../packages/tsconfig - typescript: - specifier: ^5.4.3 - version: 5.4.3 examples/with-jest-jsdom: dependencies: @@ -141,8 +138,8 @@ importers: examples/with-jest-node: dependencies: fastify: - specifier: ^4.26.1 - version: 4.26.1 + specifier: 4.23.2 + version: 4.23.2 zimic: specifier: latest version: link:../../packages/zimic @@ -225,8 +222,8 @@ importers: examples/with-vitest-node: dependencies: fastify: - specifier: ^4.26.1 - version: 4.26.1 + specifier: 4.23.2 + version: 4.23.2 zimic: specifier: latest version: link:../../packages/zimic @@ -4418,8 +4415,8 @@ packages: resolution: {integrity: sha512-eel5UKGn369gGEWOqBShmFJWfq/xSJvsgDzgLYC845GneayWvXBf0lJCBn5qTABfewy1ZDPoaR5OZCP+kssfuw==} dev: false - /fastify@4.26.1: - resolution: {integrity: sha512-tznA/G55dsxzM5XChBfcvVSloG2ejeeotfPPJSFaWmHyCDVGMpvf3nRNbsCb/JTBF9RmQFBfuujWt3Nphjesng==} + /fastify@4.23.2: + resolution: {integrity: sha512-WFSxsHES115svC7NrerNqZwwM0UOxbC/P6toT9LRHgAAFvG7o2AN5W+H4ihCtOGuYXjZf4z+2jXC89rVEoPWOA==} dependencies: '@fastify/ajv-compiler': 3.5.0 '@fastify/error': 3.4.1 @@ -4428,14 +4425,14 @@ packages: avvio: 8.3.0 fast-content-type-parse: 1.1.0 fast-json-stringify: 5.12.0 - find-my-way: 8.1.0 + find-my-way: 7.7.0 light-my-request: 5.11.0 pino: 8.18.0 - process-warning: 3.0.0 + process-warning: 2.3.2 proxy-addr: 2.0.7 - rfdc: 1.3.0 + rfdc: 1.3.1 secure-json-parse: 2.7.0 - semver: 7.5.4 + semver: 7.6.0 toad-cache: 3.7.0 transitivePeerDependencies: - supports-color @@ -4486,8 +4483,8 @@ packages: dependencies: to-regex-range: 5.0.1 - /find-my-way@8.1.0: - resolution: {integrity: sha512-41QwjCGcVTODUmLLqTMeoHeiozbMXYMAE1CKFiDyi9zVZ2Vjh0yz3MF0WQZoIb+cmzP/XlbFjlF2NtJmvZHznA==} + /find-my-way@7.7.0: + resolution: {integrity: sha512-+SrHpvQ52Q6W9f3wJoJBbAQULJuNEEQwBvlvYwACDhBTLOTMiQ0HYWh4+vC3OivGP2ENcTI1oKlFA2OepJNjhQ==} engines: {node: '>=14'} dependencies: fast-deep-equal: 3.1.3 @@ -7076,7 +7073,6 @@ packages: /rfdc@1.3.1: resolution: {integrity: sha512-r5a3l5HzYlIC68TpmYKlxWjmOP6wiPJ1vWv2HeLhNsRZMrCkxeqxiHlQ21oXmQ4F3SiryXBHhAD7JZqvOJjFmg==} - dev: true /rimraf@3.0.2: resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} @@ -7202,6 +7198,7 @@ packages: hasBin: true dependencies: lru-cache: 6.0.0 + dev: true /semver@7.6.0: resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==} diff --git a/turbo.json b/turbo.json index 143d1968..23d9f861 100644 --- a/turbo.json +++ b/turbo.json @@ -1,6 +1,6 @@ { "$schema": "https://turbo.build/schema.json", - "globalEnv": ["NODE_ENV", "NODE_VERSION"], + "globalEnv": ["NODE_ENV", "NODE_VERSION", "TYPESCRIPT_VERSION"], "pipeline": { "dev": { "cache": false,