diff --git a/.changeset/plenty-countries-work.md b/.changeset/plenty-countries-work.md new file mode 100644 index 000000000..81d4d38bc --- /dev/null +++ b/.changeset/plenty-countries-work.md @@ -0,0 +1,5 @@ +--- +"@kubb/swagger-zod": patch +--- + +remove log diff --git a/.github/setup/action.yml b/.github/setup/action.yml new file mode 100644 index 000000000..46dc18c71 --- /dev/null +++ b/.github/setup/action.yml @@ -0,0 +1,37 @@ +name: "Setup" +description: "Sets up Node.js and runs install" + +runs: + using: composite + steps: + - uses: pnpm/action-setup@v2.2.4 + with: + version: + + - name: Setup Node.js environment + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'pnpm' + registry-url: 'https://registry.npmjs.org' + + - name: Install bun + uses: oven-sh/setup-bun@v1 + continue-on-error: true + + - name: Setup Git User + shell: bash + run: | + git config --global user.email "stijn@stijnvanhulle.be" + git config --global user.name "Stijn Van Hulle" + + - name: Install dependencies + shell: bash + run: pnpm install --prefer-offline + + - name: Setup Turbo + uses: dtinth/setup-github-actions-caching-for-turbo@v1 + continue-on-error: true + with: + # Set the prefix for the cache keys. + cache-prefix: kubb_ diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index c193a34e7..000000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,110 +0,0 @@ -name: ci - -on: - workflow_dispatch: - inputs: - tag: - description: override release tag - required: false - push: - branches: ['main', 'alpha', 'beta', 'rc'] - paths: - - 'packages/**' - -jobs: - build: - name: Build and Test - timeout-minutes: 15 - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - - uses: pnpm/action-setup@v2.2.4 - with: - version: 8 - - - name: Setup Node.js environment - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'pnpm' - registry-url: 'https://registry.npmjs.org' - - - name: Install bun - uses: oven-sh/setup-bun@v1 - - - name: Install dependencies - run: pnpm install --prefer-offline - - - uses: dtinth/setup-github-actions-caching-for-turbo@v1 - with: - # Set the prefix for the cache keys. - cache-prefix: kubb_ - - - name: Build - run: bun run build --concurrency=1 - - - name: Typecheck - run: bun run typecheck --concurrency=1 - - - name: Typecheck examples - run: bun run typecheck:examples --concurrency=1 - - - name: Test - run: bun run test - - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - - name: Publish - uses: changesets/action@v1 - id: publish - continue-on-error: true - if: ${{ success() && github.event.inputs.tag == '' && github.ref == 'refs/heads/main' && (github.event_name != 'pull_request' || github.event.action == 'closed' && github.event.pull_request.merged == true) }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - with: - publish: bun run release - - - name: Publish ${{ inputs.tag || 'canary' }} - continue-on-error: true - # if: ${{ steps.publish.outputs.published == 'false' || steps.publish.outcome == 'failure' || github.event.inputs.tag != '' }} - if: ${{ github.event.inputs.tag != '' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: | - bun run release:canary --tag ${{ inputs.tag || 'canary' }} - - - name: Send a discord notification - if: steps.publish.outputs.published == 'true' - uses: actions/github-script@v6 - env: - DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - fetch(process.env.DISCORD_WEBHOOK_URL, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - content: `A new release is available 🎉. \n [Read the changelog](https://github.com/kubb-project/kubb/releases)` - }), - }) - .then((res) => { - console.log('Sent discord notification', res) - }) - .catch((err) => { - console.error('Error sending discord notification', err) - }) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 159ac2882..35cb35f4d 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -19,7 +19,7 @@ on: jobs: build: - name: Build and Test + name: Build and test timeout-minutes: 30 strategy: fail-fast: true @@ -77,29 +77,8 @@ jobs: with: fetch-depth: 2 - - uses: pnpm/action-setup@v2.2.4 - with: - version: 8 - - - name: Setup Node.js(${{ matrix.node-version }}) environment - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'pnpm' - registry-url: 'https://registry.npmjs.org' - - - name: Install dependencies - run: pnpm install --prefer-offline - - - name: Install bun - if: ${{ matrix.os == 'ubuntu-latest' }} - uses: oven-sh/setup-bun@v1 - - - uses: dtinth/setup-github-actions-caching-for-turbo@v1 - if: ${{ matrix.os == 'ubuntu-latest' }} - with: - # Set the prefix for the cache keys. - cache-prefix: kubb_ + - name: Setup + uses: ./.github/setup - name: Build run: ${{ matrix.installer }} build diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml deleted file mode 100644 index 90fe0de42..000000000 --- a/.github/workflows/pr.yaml +++ /dev/null @@ -1,85 +0,0 @@ -name: pr - -on: - pull_request: - paths-ignore: - - "docs/**" - - "examples/**" - - "**/*.md" - -jobs: - build: - name: Build and Test - timeout-minutes: 15 - strategy: - fail-fast: true - matrix: - os: [ubuntu-latest] - node-version: [18] - experimental: [false] - ## comment out for support of node 19,20 - # include: - # - os: ubuntu-latest - # node-version: 19 - # experimental: true - # - os: ubuntu-latest - # node-version: 20 - # experimental: true - - runs-on: ${{ matrix.os || 'ubuntu-latest' }} - continue-on-error: ${{ matrix.experimental || false }} - - steps: - - name: Check out code - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - - uses: pnpm/action-setup@v2.2.4 - with: - version: 8 - - - name: Setup Node.js(${{ matrix.node-version }}) environment - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'pnpm' - registry-url: 'https://registry.npmjs.org' - - - name: Install bun - uses: oven-sh/setup-bun@v1 - - - name: Install dependencies - run: pnpm install --prefer-offline - - - uses: dtinth/setup-github-actions-caching-for-turbo@v1 - with: - # Set the prefix for the cache keys. - cache-prefix: kubb_ - - - name: Build - run: bun run build --concurrency=1 - - - name: Typecheck - run: bun run typecheck --concurrency=1 - - - name: Typecheck examples - run: bun run typecheck:examples --concurrency=1 - - - name: Linting - env: - NODE_OPTIONS: "--max_old_space_size=4096" - continue-on-error: true - run: bun run lint:ci - - - name: Test - run: bun run test - - - name: Test with Bun - continue-on-error: true - run: bun run test:bun --coverage - - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml new file mode 100644 index 000000000..ad568ef1b --- /dev/null +++ b/.github/workflows/quality.yml @@ -0,0 +1,94 @@ +name: Quality + +on: + workflow_dispatch: + pull_request: + branches: + - main + +jobs: + build: + name: Build + timeout-minutes: 15 + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Setup + uses: ./.github/setup + + - name: Build + run: bun run build --concurrency=1 + + typecheck: + name: Typecheck + timeout-minutes: 15 + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Setup + uses: ./.github/setup + + - name: Typecheck + run: bun run typecheck --concurrency=1 + + - name: Typecheck examples + run: bun run typecheck:examples --concurrency=1 + + tests: + name: Tests + timeout-minutes: 15 + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Setup + uses: ./.github/setup + + - name: Build + run: bun build + + - name: Test + run: bun run test + + - name: Test with Bun + continue-on-error: true + run: bun run test:bun --coverage + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + linting: + name: Linting + timeout-minutes: 15 + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Setup + uses: ./.github/setup + + - name: Linting + env: + NODE_OPTIONS: "--max_old_space_size=4096" + continue-on-error: true + run: bun run lint:ci diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 944106906..766d8bd6b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,13 +1,15 @@ -name: release +name: Release on: + workflow_dispatch: + inputs: + tag: + description: override release tag + required: false push: branches: ['main', 'alpha', 'beta', 'rc'] - paths-ignore: - - "docs/**" - - "examples/**" - - "**/*.md" - - workflow_dispatch: + paths: + - ".changeset/**" + - "packages/**" concurrency: ${{ github.workflow }}-${{ github.ref }} @@ -23,29 +25,55 @@ jobs: with: fetch-depth: 2 - - uses: pnpm/action-setup@v2.2.4 - with: - version: 8 - - - name: Setup Node.js environment - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'pnpm' - registry-url: 'https://registry.npmjs.org' - - - name: Install bun - uses: oven-sh/setup-bun@v1 + - name: Setup + uses: ./.github/setup - - name: Install dependencies - run: pnpm install --prefer-offline + - name: Build + run: bun run build --concurrency=1 - - uses: dtinth/setup-github-actions-caching-for-turbo@v1 + - name: Publish + id: changesets + uses: changesets/action@v1 + if: ${{ github.event.inputs.tag == '' }} with: - # Set the prefix for the cache keys. - cache-prefix: kubb_ + publish: bun release + commit: "ci(changesets): version packages" + setupGitUser: false + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Create Release Pull Request - uses: changesets/action@v1 + - name: Publish ${{ inputs.tag || 'canary' }} + if: steps.changesets.outputs.published != 'true' + run: | + git checkout main + bun version:canary + bun release:canary --tag ${{ inputs.tag || 'canary' }} env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Send a discord notification + if: steps.changesets.outputs.published == 'true' + uses: actions/github-script@v6 + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + fetch(process.env.DISCORD_WEBHOOK_URL, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + content: `A new release is available 🎉. \n [Read the changelog](https://github.com/kubb-project/kubb/releases)` + }), + }) + .then((res) => { + console.log('Sent discord notification', res) + }) + .catch((err) => { + console.error('Error sending discord notification', err) + }) diff --git a/package.json b/package.json index 10919c875..c0032ad47 100644 --- a/package.json +++ b/package.json @@ -39,8 +39,10 @@ "lint:ci": "ESLINT_USE_FLAT_CONFIG=true eslint --max-warnings 10 --format pretty ./packages/*", "lint:fix": "ESLINT_USE_FLAT_CONFIG=true eslint --fix --format pretty ./packages/* && bun run lint:case", "lint:turbo": "turbo run lint", - "release": "changeset version && changeset publish", - "release:canary": "changeset version --snapshot canary && changeset publish --no-git-tag --snapshot canary", + "version": "changeset version", + "release": "changeset publish", + "version:canary": "changeset version --snapshot canary", + "release:canary": "changeset publish --no-git-tag", "start": "turbo run start --filter=./packages/*", "test": "vitest run --config ./configs/vitest.config.ts --coverage", "test:bun": "bun test --preload ./configs/setup.ts", diff --git a/packages/swagger-zod/src/ZodGenerator.ts b/packages/swagger-zod/src/ZodGenerator.ts index 6b2dd88d5..1a628bbf4 100644 --- a/packages/swagger-zod/src/ZodGenerator.ts +++ b/packages/swagger-zod/src/ZodGenerator.ts @@ -138,7 +138,6 @@ export class ZodGenerator extends Generator