diff --git a/WORKFLOWS_SETUP.md b/WORKFLOWS_SETUP.md index 239eb8e..d93c831 100644 --- a/WORKFLOWS_SETUP.md +++ b/WORKFLOWS_SETUP.md @@ -54,6 +54,6 @@ Target URL: https://pydevices.github.io/pdwidgets/ ### CI tests workflow -Copy `ci/github-workflows/tests.yml` → `.github/workflows/tests.yml` after PR #4 +(Workflows live only in `.github/workflows/` — do not keep a parallel `ci/` tree.) (checks out a shallow `pydisplay` dep tree for import tests). Requires `workflow` scope on the pushing PAT. diff --git a/ci/github-workflows/deploy-pages.yml b/ci/github-workflows/deploy-pages.yml deleted file mode 100644 index 708c42d..0000000 --- a/ci/github-workflows/deploy-pages.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Deploy Pages site - -on: - push: - branches: [main] - paths: - - 'web/**' - - '.github/workflows/deploy-pages.yml' - workflow_dispatch: - -permissions: - contents: write - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Assemble GitHub Pages site - run: | - mkdir -p _site - cp -r web/* _site/ - touch _site/.nojekyll - - name: Deploy to gh-pages - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: _site - publish_branch: gh-pages diff --git a/ci/github-workflows/docs.yml b/ci/github-workflows/docs.yml deleted file mode 100644 index 9bf316c..0000000 --- a/ci/github-workflows/docs.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Documentation - -on: - push: - branches: [main] - paths: - - 'docs/**' - - 'mkdocs.yml' - - 'scripts/mkdocs_gen_ref_pages.py' - - 'lib/**' - pull_request: - paths: - - 'docs/**' - - 'mkdocs.yml' - - 'scripts/mkdocs_gen_ref_pages.py' - - 'lib/**' - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.13' - - name: Install MkDocs dependencies - run: pip install -r docs/requirements.txt - - name: Build documentation - run: mkdocs build diff --git a/ci/github-workflows/publish-micropython-lib.yml b/ci/github-workflows/publish-micropython-lib.yml deleted file mode 100644 index e45dab7..0000000 --- a/ci/github-workflows/publish-micropython-lib.yml +++ /dev/null @@ -1,158 +0,0 @@ -# Publish pdwidgets to micropython-lib, MIP index, and TestPyPI. -# -# Release trigger: push tag vX.Y.Z (see scripts/publish_release_tag.sh). -# -# Secrets: -# MICROPYTHON_LIB_DEPLOY_TOKEN — PAT with contents:write on PyDevices/micropython-lib -# TESTPYPI_API_TOKEN — TestPyPI API token - -name: Publish micropython-lib - -on: - push: - tags: - - 'v*.*.*' - workflow_dispatch: - inputs: - version: - description: Semver X.Y.Z - type: string - required: false - sync_sources: - description: Sync pdwidgets into micropython-lib - type: boolean - default: true - upload_testpypi: - description: Upload wheels to TestPyPI - type: boolean - default: false - publish_mip_index: - description: Rebuild mip/PyDevices and push gh-pages - type: boolean - default: true - commit_message: - description: micropython-lib commit message - type: string - required: false - -permissions: - contents: read - -# Sibling repos also push to micropython-lib; scripts rebase-retry on conflict. -concurrency: - group: publish-micropython-lib-${{ github.repository }} - cancel-in-progress: false - -jobs: - publish: - runs-on: ubuntu-latest - if: github.repository == 'PyDevices/pdwidgets' - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Resolve release version - id: version - env: - INPUT_VERSION: ${{ inputs.version }} - run: | - set -euo pipefail - normalize() { - local v="${1#v}" - v="$(echo "$v" | tr -d '[:space:]')" - if [[ ! "$v" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then - echo "Invalid semver: $1" >&2 - exit 1 - fi - echo "$v" - } - if [[ "${{ github.event_name }}" == "push" ]]; then - VERSION="$(normalize "${GITHUB_REF_NAME}")" - elif [[ -n "${INPUT_VERSION:-}" ]]; then - VERSION="$(normalize "$INPUT_VERSION")" - else - TAG="$(git describe --tags --exact-match 2>/dev/null || true)" - if [[ -z "$TAG" ]]; then - echo "Set version input or run from a vX.Y.Z tag." >&2 - exit 1 - fi - VERSION="$(normalize "$TAG")" - fi - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - echo "Publishing pdwidgets release $VERSION" - - - name: Verify publish secrets - env: - DEPLOY_TOKEN: ${{ secrets.MICROPYTHON_LIB_DEPLOY_TOKEN }} - TESTPYPI_TOKEN: ${{ secrets.TESTPYPI_API_TOKEN }} - run: | - set -euo pipefail - missing=() - if [[ -z "${DEPLOY_TOKEN}" ]]; then - missing+=("MICROPYTHON_LIB_DEPLOY_TOKEN") - fi - if [[ "${{ github.event_name }}" == "push" || "${{ inputs.upload_testpypi }}" == "true" ]]; then - if [[ -z "${TESTPYPI_TOKEN}" ]]; then - missing+=("TESTPYPI_API_TOKEN") - fi - fi - if [[ ${#missing[@]} -gt 0 ]]; then - echo "::error::GitHub did not supply secrets to PyDevices/pdwidgets: ${missing[*]}" - echo "Org secrets named correctly still fail when this repository is not on the secret's access list." - echo "Org Settings → Secrets and variables → Actions → each secret → Repository access → include pdwidgets." - echo "Repo Settings → Secrets and variables → Actions: remove empty repo secrets that override org values." - exit 1 - fi - - - uses: actions/checkout@v4 - with: - repository: PyDevices/micropython-lib - ref: PyDevices - path: micropython-lib - token: ${{ secrets.MICROPYTHON_LIB_DEPLOY_TOKEN }} - - - uses: actions/setup-python@v5 - with: - python-version: '3.13' - - - name: Install publish tools - if: github.event_name == 'push' || inputs.upload_testpypi == true - run: pip install hatch twine - - - name: Configure micropython-lib git - run: | - git -C micropython-lib config user.name 'github-actions[bot]' - git -C micropython-lib config user.email 'github-actions[bot]@users.noreply.github.com' - git -C micropython-lib remote set-url origin \ - "https://x-access-token:${{ secrets.MICROPYTHON_LIB_DEPLOY_TOKEN }}@github.com/PyDevices/micropython-lib.git" - - - name: Sync pdwidgets into micropython-lib - if: github.event_name == 'push' || inputs.sync_sources == true - env: - MICROPYTHON_LIB_DIR: ${{ github.workspace }}/micropython-lib - PDWIDGETS_VERSION: ${{ steps.version.outputs.version }} - TESTPYPI_API_TOKEN: ${{ secrets.TESTPYPI_API_TOKEN }} - run: | - VERSION="${{ steps.version.outputs.version }}" - MSG="${{ inputs.commit_message }}" - if [[ -z "$MSG" ]]; then - MSG="pdwidgets: Release v${VERSION} (${GITHUB_SHA::7})." - fi - EXTRA=(--commit-message "$MSG" --push) - if [[ "${{ github.event_name }}" != "push" && "${{ inputs.upload_testpypi }}" != "true" ]]; then - EXTRA=(--skip-pypi --commit-message "$MSG" --push) - fi - chmod +x scripts/publish_micropython_lib.sh - ./scripts/publish_micropython_lib.sh "${EXTRA[@]}" - - - name: Publish MIP index to gh-pages - if: github.event_name == 'push' || inputs.publish_mip_index == true - env: - MICROPYTHON_LIB_DIR: ${{ github.workspace }}/micropython-lib - PDWIDGETS_DIR: ${{ github.workspace }} - MICROPYTHON_DIR: /tmp/micropython - MIP_INDEX_OUTPUT: /tmp/mip-index - run: | - chmod +x scripts/publish_mip_ghpages.sh - ./scripts/publish_mip_ghpages.sh diff --git a/ci/github-workflows/tests.yml b/ci/github-workflows/tests.yml deleted file mode 100644 index fd6512e..0000000 --- a/ci/github-workflows/tests.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Unit tests - -on: - push: - branches: [main] - paths: - - 'lib/**' - - 'tests/**' - - 'scripts/**' - pull_request: - paths: - - 'lib/**' - - 'tests/**' - - 'scripts/**' - workflow_dispatch: - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/checkout@v4 - with: - repository: PyDevices/pydisplay - path: pydisplay - sparse-checkout: | - src/lib - sparse-checkout-cone-mode: false - - uses: actions/checkout@v4 - with: - repository: PyDevices/graphics - path: graphics - sparse-checkout: | - lib/graphics - sparse-checkout-cone-mode: false - - uses: actions/checkout@v4 - with: - repository: PyDevices/palettes - path: palettes - sparse-checkout: | - lib/palettes - sparse-checkout-cone-mode: false - - uses: actions/setup-python@v5 - with: - python-version: '3.13' - - name: Install ruff - run: pip install ruff - - name: Ruff - run: ruff check lib tests scripts - - name: Unit tests - env: - PYTHONPATH: lib:tests/stubs:pydisplay/src/lib:graphics/lib:palettes/lib - run: python -m unittest discover -s tests diff --git a/tests/stubs/micropython/__init__.py b/tests/stubs/micropython/__init__.py index 0bd3b90..18cbf3e 100644 --- a/tests/stubs/micropython/__init__.py +++ b/tests/stubs/micropython/__init__.py @@ -3,7 +3,7 @@ """Minimal CPython shim for ``from micropython import const`` in unit tests. pydisplay deps (``graphics``, ``palettes``, ``framebuf``) come from the CI -sparse checkout; see ``ci/github-workflows/tests.yml``. +sparse checkout; see ``.github/workflows/tests.yml``. """