diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a6aabf1c1..b7e45ba99 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -6,6 +6,12 @@ on: branches: "*" workflow_dispatch: +permissions: + contents: read + pages: write + id-token: write + pull-requests: write + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -76,6 +82,13 @@ jobs: run: pnpm install --frozen-lockfile - name: Install the project run: uv sync --all-extras --dev + - name: Patch version for TestPyPI + if: github.event_name == 'pull_request' + run: | + BASE=$(grep -Po '^version = "\K[^"]+' pyproject.toml) + DEV="${BASE}.dev${{ github.run_id }}" + sed -i "s/^version = \".*\"/version = \"${DEV}\"/" pyproject.toml + echo "Published version: ${DEV}" - name: Build JS extension + Python wheel run: ./scripts/full_build.sh - name: Upload build artifacts @@ -88,6 +101,74 @@ jobs: ./packages/buckaroo-js-core/dist/ ./packages/buckaroo-widget/dist/ + PublishTestPyPI: + name: Publish to TestPyPI + if: >- + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name == github.repository + needs: [BuildWheel] + runs-on: depot-ubuntu-latest + timeout-minutes: 5 + environment: testpypi + permissions: + id-token: write + pull-requests: write + steps: + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: buckaroo-build + path: artifacts + - name: Publish to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + packages-dir: artifacts/dist/ + - name: Comment on PR with install command + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const distFiles = fs.readdirSync('artifacts/dist'); + const wheel = distFiles.find(f => f.endsWith('.whl')); + const version = wheel.match(/buckaroo-(.+?)-/)[1]; + const body = [ + '## :package: TestPyPI package published', + '', + '```bash', + `pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo==${version}`, + '```', + '', + 'or with uv:', + '', + '```bash', + `uv pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo==${version}`, + '```', + ].join('\n'); + + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + const marker = '## :package: TestPyPI package published'; + const existing = comments.find(c => c.body.startsWith(marker)); + if (existing) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existing.id, + body, + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body, + }); + } + # --------------------------------------------------------------------------- # Source-level tests — operate on the codebase, no wheel needed # --------------------------------------------------------------------------- @@ -316,6 +397,44 @@ jobs: - name: Run WASM Marimo Playwright Tests run: bash scripts/test_playwright_wasm_marimo.sh + # --------------------------------------------------------------------------- + # Deploy Storybook to GitHub Pages (main only) + # --------------------------------------------------------------------------- + + DeployStorybook: + name: Deploy Storybook + if: github.ref == 'refs/heads/main' + needs: [TestStorybook] + runs-on: depot-ubuntu-latest + timeout-minutes: 10 + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - uses: actions/checkout@v4 + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.10.0 + - name: Setup Node.js with pnpm cache + uses: actions/setup-node@v4 + with: + cache: 'pnpm' + cache-dependency-path: 'packages/pnpm-lock.yaml' + - name: Install pnpm dependencies + working-directory: packages + run: pnpm install --frozen-lockfile + - name: Build Storybook + working-directory: packages/buckaroo-js-core + run: pnpm build-storybook + - name: Upload Pages artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./packages/buckaroo-js-core/dist/storybook + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 + # --------------------------------------------------------------------------- # Docs — build documentation and check links # --------------------------------------------------------------------------- diff --git a/.github/workflows/deploy-ghpage.yml b/.github/workflows/deploy-ghpage.yml deleted file mode 100644 index 21f6559f4..000000000 --- a/.github/workflows/deploy-ghpage.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Build and Deploy - -on: - push: - branches: - - main - pull_request: - branches: -# - 'none-never' - - '*' - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v4 - with: - run_install: true - package_json_file: packages/package.json - - uses: astral-sh/setup-uv@v6 - - name: Run tests - working-directory: ./packages/buckaroo-js-core - run: | - pnpm build-storybook - # - name: Setup Python - # uses: actions/setup-python@v5 - # with: - # python-version: '3.12' - - # - name: Install mamba - # uses: mamba-org/setup-micromamba@v1 - # with: - # micromamba-version: '1.5.8-0' - # environment-file: docs/build-environment.yml - # cache-environment: true - - # - name: Build the JupyterLite site - # shell: bash -l {0} - # run: | - # cd docs - # jupyter lite build --contents ./example-notebooks --output-dir ./_output - - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - path: ./packages/buckaroo-js-core/dist/storybook - - deploy: - needs: build - if: github.ref == 'refs/heads/main' - permissions: - pages: write - id-token: write - - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - - runs-on: ubuntu-latest - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 diff --git a/.github/workflows/publish-storybook.yml b/.github/workflows/publish-storybook.yml deleted file mode 100644 index d8fb40f8d..000000000 --- a/.github/workflows/publish-storybook.yml +++ /dev/null @@ -1,68 +0,0 @@ -# Workflow name -name: Build and Publish Storybook to GitHub Pages - -on: - push: - branches: - - main - - pull_request: - branches: "*" - - -permissions: - contents: read - pages: write - id-token: write - -# List of jobs -jobs: - TestPython: - name: Python / Test - permissions: - contents: write - runs-on: depot-ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v4 - with: - run_install: true - package_json_file: packages/package.json - - uses: astral-sh/setup-uv@v6 - - name: Run tests - working-directory: ./packages/buckaroo-js-core - run: | - pnpm build-storybook - - name: Deploy - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./packages/buckaroo-js-core/dist/storybook - # - name: Setup Pages - # uses: actions/configure-pages@v3 - # - name: Upload Artifact - # if: github.ref == 'refs/heads/main' - # uses: actions/upload-pages-artifact@v1 - # with: - # # location of the coverage artifacts - # path: "./coverage" - # Upload: - # name: Upload2 - # runs-on: ubuntu-latest - # steps: - # - name: Upload3 - # uses: actions/upload-pages-artifact@v3 - # path: packages/buckaroo-js-core/dist/storybook - # - id: deploy - # name: Deploy to GitHub Pages - # uses: actions/deploy-pages@v4 - # with: - # token: ${{ github.token }} - - # #👇 Add Storybook build and deploy to GitHub Pages as a step in the workflow - # - uses: bitovi/github-actions-storybook-to-github-pages@v1.0.3 - # with: - # install_command: cd packages/buckaroo-js-core; pnpm install # default: npm ci - # build_command: cd packages/buckaroo-js-core; pnpm build-storybook # default: npm run build-storybook - # path: packages/buckaroo-js-core/dist/storybook # default: dist/storybook - # checkout: true # default: true