diff --git a/.github/ISSUE_TEMPLATE/issue.bug.yml b/.github/ISSUE_TEMPLATE/issue.bug.yml index 19ac8b2e..afc29039 100644 --- a/.github/ISSUE_TEMPLATE/issue.bug.yml +++ b/.github/ISSUE_TEMPLATE/issue.bug.yml @@ -1,17 +1,17 @@ name: 🐞 SDK Bug Report -description: Report an issue using Svelte Storyblok SDK +description: Report an issue using React Storyblok SDK labels: [pending-triage, pending-author] body: - type: markdown attributes: value: | - You're now going to fill out a bug report at the Svelte Storyblok SDK. Thanks a lot for taking the time and let's make Storyblok open source projects better together! + You're now going to fill out a bug report at the React Storyblok SDK. Thanks a lot for taking the time and let's make Storyblok open source projects better together! - type: textarea id: bug-description attributes: label: Describe the issue you're facing description: A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description so we can review it. Thanks in advance! - placeholder: My Svelte Storyblok SDK configuration is ... # # Expected behavior ... ## Current Behavior ... + placeholder: My React Storyblok SDK configuration is ... # # Expected behavior ... ## Current Behavior ... validations: required: true - type: input @@ -32,9 +32,9 @@ body: id: system-info attributes: label: System Info - description: Output of `npx envinfo --system --npmPackages '{ svelte, @storyblok/*}' --binaries --browsers` + description: Output of `npx envinfo --system --npmPackages '{ react, @storyblok/*}' --binaries --browsers` render: shell - placeholder: System, Binaries, Browsers, Svelte & Storyblok SDK version + placeholder: System, Binaries, Browsers, React & Storyblok SDK version validations: required: true - type: dropdown @@ -60,7 +60,7 @@ body: label: Validations description: Before submitting the issue, please make sure you do the following options: - - label: Follow our [Code of Conduct](https://www.storyblok.com/trust-center#code-of-conduct?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js-client) + - label: Follow our [Code of Conduct](https://www.storyblok.com/trust-center?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js-client#code-of-conduct) required: true - type: markdown attributes: diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 025b9f08..5d06d092 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,3 +9,15 @@ updates: prefix: fix prefix-development: chore include: scope + labels: + - dependabot + groups: + security-updates: + applies-to: security-updates + update-types: + - patch + ignore: + - dependency-name: '*' + update-types: + - version-update:semver-minor + - version-update:semver-major diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml new file mode 100644 index 00000000..122fb09c --- /dev/null +++ b/.github/workflows/commitlint.yml @@ -0,0 +1,31 @@ +name: CI + +on: [push, pull_request] + +env: + PNPM_CACHE_FOLDER: .pnpm-store + SKIP_INSTALL_SIMPLE_GIT_HOOKS: 1 # Skip installing simple-git-hooks + +jobs: + commitlint: + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup pnpm + uses: pnpm/action-setup@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: pnpm + - name: Install dependencies + run: pnpm install + - name: Validate current commit (last commit) with commitlint + if: github.event_name == 'push' + run: pnpm commitlint --last --verbose + - name: Validate PR commits with commitlint + if: github.event_name == 'pull_request' + run: pnpm commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml index 136c0c6a..bd044750 100644 --- a/.github/workflows/dependabot-automerge.yml +++ b/.github/workflows/dependabot-automerge.yml @@ -1,28 +1,28 @@ -# **** AUTOMERGE **** -# Merge automatically the PR that contain a minor or patch update on the dependency you define in env.DEPENDENCY -# - Inspiration: https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request - -name: Dependabot auto-merge +name: Dependabot auto-approve on: pull_request permissions: pull-requests: write - contents: write jobs: dependabot: runs-on: ubuntu-latest - if: ${{ github.actor == 'dependabot[bot]' }} + if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'storyblok/storyblok-react' steps: - name: Dependabot metadata id: metadata - uses: dependabot/fetch-metadata@v1.1.1 + uses: dependabot/fetch-metadata@v2 with: github-token: '${{ secrets.GITHUB_TOKEN }}' - - name: Enable auto-merge for Dependabot PRs - if: ${{contains(steps.metadata.outputs.dependency-names, env.DEPENDENCY) && (steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor')}} - run: gh pr merge --auto --merge "$PR_URL" + alert-lookup: true + - uses: actions/checkout@v4 + - name: Approve a PR if not already approved + run: | + gh pr checkout "$PR_URL" # sets the upstream metadata for `gh pr status` + if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ]; + then gh pr review --approve "$PR_URL" + else echo "PR already approved, skipping additional approvals to minimize emails/notification noise."; + fi env: - DEPENDENCY: '@storyblok/js' PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.DEPENDABOT_TOKEN}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..1eb2b194 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,28 @@ +name: Run linters +on: [push] + +env: + PNPM_CACHE_FOLDER: .pnpm-store + SKIP_INSTALL_SIMPLE_GIT_HOOKS: 1 # Skip installing simple-git-hooks + +jobs: + lint: + name: Lint + runs-on: ubuntu-24.04 + strategy: + matrix: + node-version: [20] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup pnpm + uses: pnpm/action-setup@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: pnpm + - name: Install dependencies + run: pnpm install + - name: Run Lint + run: pnpm run lint diff --git a/.github/workflows/pkg.pr.new.yml b/.github/workflows/pkg.pr.new.yml new file mode 100644 index 00000000..4120ec9b --- /dev/null +++ b/.github/workflows/pkg.pr.new.yml @@ -0,0 +1,38 @@ +name: Publish Any Commit +on: + push: + branches: + - '**' + tags: + - '!**' + +env: + PNPM_CACHE_FOLDER: .pnpm-store + SKIP_INSTALL_SIMPLE_GIT_HOOKS: 1 # Skip installing simple-git-hooks + +permissions: {} + +concurrency: + group: ${{ github.workflow }}-${{ github.event.number }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - run: corepack enable + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: pnpm + - name: Install dependencies + run: pnpm install + - name: Build + run: pnpm build + - run: pnpx pkg-pr-new publish --compact --pnpm diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4194e4ae..00c7b58b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,30 +2,36 @@ name: Release CI on: push: - branches: [main, v2-maintenance] + branches: [main] pull_request: - branches: [main, v2-maintenance] + branches: [main] + +env: + PNPM_CACHE_FOLDER: .pnpm-store + SKIP_INSTALL_SIMPLE_GIT_HOOKS: 1 # Skip installing simple-git-hooks jobs: release: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + strategy: + matrix: + node-version: [20] steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup Node + - name: Setup pnpm + uses: pnpm/action-setup@v4 + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: - node-version: '20' - cache: npm + node-version: ${{ matrix.node-version }} + cache: pnpm - name: Install dependencies - run: npm ci + run: pnpm install - name: Build lib - run: npm run build - - name: Jest run - run: npm run test:unit + run: pnpm build - name: Release - working-directory: lib env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npx semantic-release + run: pnpx semantic-release diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..448df4c2 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,53 @@ +name: Run tests + +on: [push] + +env: + PNPM_CACHE_FOLDER: .pnpm-store + SKIP_INSTALL_SIMPLE_GIT_HOOKS: 1 # Skip installing simple-git-hooks + +jobs: + tests: + runs-on: ubuntu-24.04 + strategy: + matrix: + node-version: [20] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: pnpm + + - name: Cache Cypress binary + uses: actions/cache@v4 + with: + path: ~/.cache/Cypress + key: cypress-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} + + - name: Install dependencies + run: pnpm install + + - name: Build Library + run: pnpm build + + - name: Vitest run + run: pnpm run test:unit:ci --silent + + - name: Cypress run + run: pnpm run test:e2e + + - name: Upload Cypress artifacts + if: failure() + uses: actions/upload-artifact@v4 + with: + name: cypress-artifacts + path: | + cypress/screenshots + cypress/videos