diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 00000000000..2e178927525 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,65 @@ +name: Bug Report +description: Create a report to help us improve +labels: ["type: bug", "needs-triage"] +body: + - type: markdown + attributes: + value: | + Thanks for helping PyScript! 🐍 + + Going through bugs and issues takes up a lot of time, so please be so kind and take a few minutes to fill out all the areas to the best of your ability. + + There will always be more issues than there is time to do them, and so we will need to selectively close issues that don't provide enough information, so we can focus our time on helping people like you who fill out the issue form completely. Thank you for your collaboration! + + There are also already a lot of open issues, so please take 2 minutes and search through existing ones to see if what you are experiencing already exists. + + Finally, if you are opening **a bug report related to PyScript.com** please [use this repository instead](https://github.com/anaconda/pyscript-dot-com-issues/issues/new/choose). + + Thanks for helping PyScript be amazing. We are nothing without people like you helping build a better community 💐! + - type: checkboxes + id: checks + attributes: + label: Checklist + description: Please confirm and check all the following options. + options: + - label: I added a descriptive title + required: true + - label: I searched for other issues and couldn't find a solution or duplication + required: true + - label: I already searched in Google and didn't find any good information or help + required: true + - type: textarea + id: what-happened + attributes: + label: What happened? + description: And what should have happened instead? This really helps everyone review quicker and greatly increases the chance that someone can get around to solve your issue + placeholder: Tell us what you see! + validations: + required: true + - type: dropdown + id: browsers + attributes: + label: What browsers are you seeing the problem on? (if applicable) + multiple: true + options: + - Firefox + - Chrome + - Safari + - Microsoft Edge + - Other + validations: + required: false + - type: textarea + id: list + attributes: + label: Console info + description: | + If there are errors in your browser console then its helpful to be able to troubleshoot. + - Chrome , Firefox, and Edge: Right-click on the page and select *Inspect*. Alternatively you can press F12 on your keyboard. + - Safari: Find instructions [here](https://support.apple.com/guide/safari/use-the-developer-tools-in-the-develop-menu-sfri20948/mac). + render: shell + - type: textarea + id: context + attributes: + label: Additional Context + description: Add any additional context information or screenshots you think are useful. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000000..cbd90d4bb82 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: true +contact_links: + - name: Feature Proposals + url: https://github.com/pyscript/pyscript/discussions/new?category=proposals + about: Create a feature request to make PyScript even better + - name: Questions + url: https://github.com/pyscript/pyscript/discussions/new?category=q-a + about: For questions or discussions about pyscript diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000000..591e81853a0 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,12 @@ +## Description + + + +## Changes + + + +## Checklist + +- [ ] I have checked `make build` works locally. +- [ ] I have created / updated documentation for this change (if applicable). diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000000..e29bff2bead --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +# Keep GitHub Actions up to date with GitHub's Dependabot... +# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + groups: + github-actions: + patterns: + - "*" # Group all Actions updates into a single larger pull request + schedule: + interval: weekly diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 00000000000..0bc80808634 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,5 @@ +changelog: + categories: + - title: New Features + - title: Breaking Changes + - title: Known Issues diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 63f4bd9725b..00000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Build - -on: - push: - branches: main - pull_request: - branches: '*' - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install node - uses: actions/setup-node@v3 - with: - node-version: '12.x' - - name: Cache node modules - uses: actions/cache@v3 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - name: Install dependencies - run: | - cd pyscriptjs - npm install - - name: Build pyscript - run: | - cd pyscriptjs - npm run build diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 5bd1ffc13ed..00000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Lint - -on: - push: - branches: main - pull_request: - branches: '*' - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install node - uses: actions/setup-node@v3 - with: - node-version: '12.x' - - name: Cache node modules - uses: actions/cache@v3 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - name: Install dependencies - run: | - cd pyscriptjs - npm install - - name: Run linter - run: | - cd pyscriptjs - npm run lint diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 00000000000..43fe719dbf1 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,71 @@ +name: "Prepare Release" + +on: + push: + tags: + - "[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9]+" # YYYY.MM.MICRO + +defaults: + run: + working-directory: ./core + +jobs: + prepare-release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install node + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Python venv + run: python -m venv env + + - name: Activate Python + run: source env/bin/activate + + - name: Update pip + run: pip install --upgrade pip + + - name: Install PyMinifier + run: pip install --ignore-requires-python python-minifier + + - name: Install Setuptools + run: pip install setuptools + + - name: Cache node modules + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: NPM Install + run: npm install && npx playwright install chromium + + - name: Build + run: npm run build + + - name: Generate index.html + working-directory: . + run: sed -e 's#_PATH_#./#' -e 's#_DOC_VERSION_#latest#' -e 's#_TAG_VERSION_##' -e 's#_VERSION_#latest#' ./public/index.html > ./core/dist/index.html + + - name: Zip dist folder + run: zip -r -q ./build.zip ./dist + + - name: Prepare Release + uses: softprops/action-gh-release@v2 + with: + draft: true + prerelease: true + generate_release_notes: true + files: ./build.zip diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 00000000000..5c605299dbc --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,78 @@ +name: "Publish Release" + +on: + release: + types: [published] + +defaults: + run: + working-directory: ./core + +jobs: + publish-release: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install node + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Python venv + run: python -m venv env + + - name: Activate Python + run: source env/bin/activate + + - name: Update pip + run: pip install --upgrade pip + + - name: Install PyMinifier + run: pip install --ignore-requires-python python-minifier + + - name: Install Setuptools + run: pip install setuptools + + - name: Cache node modules + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: npm install + run: npm install && npx playwright install chromium + + - name: build + run: npm run build + + - name: Generate index.html in snapshot + working-directory: . + run: sed -e 's#_PATH_#https://pyscript.net/releases/${{ github.ref_name }}/#' -e 's#_DOC_VERSION_#${{ github.ref_name }}#' -e 's#_TAG_VERSION_#/tag/${{ github.ref_name }}#' -e 's#_VERSION_#${{ github.ref_name }}#' ./public/index.html > ./core/dist/index.html + + - name: Generate release.tar from snapshot and put it in dist/ + working-directory: . + run: tar -cvf ../release.tar * && mv ../release.tar . + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: ${{ secrets.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_OIDC_RUNNER_ROLE }} + + - name: Sync to S3 + run: + | # Update /latest and create an explicitly versioned directory under releases/YYYY.MM.MICRO/ + aws s3 sync --quiet ./dist/ s3://pyscript.net/latest/ + aws s3 sync --quiet ./dist/ s3://pyscript.net/releases/${{ github.ref_name }}/ diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml new file mode 100644 index 00000000000..b7f51d52ae7 --- /dev/null +++ b/.github/workflows/publish-snapshot.yml @@ -0,0 +1,76 @@ +name: "Publish Snapshot" + +on: + workflow_dispatch: + inputs: + snapshot_version: + description: "The calver version of this snapshot: 2022.09.1 or 2022.09.1.RC1" + type: string + required: true + +defaults: + run: + working-directory: ./core + +jobs: + publish-snapshot: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install node + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Python venv + run: python -m venv env + + - name: Activate Python + run: source env/bin/activate + + - name: Update pip + run: pip install --upgrade pip + + - name: Install PyMinifier + run: pip install --ignore-requires-python python-minifier + + - name: Install Setuptools + run: pip install setuptools + + - name: Cache node modules + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install Dependencies + run: npm install && npx playwright install chromium + + - name: Build Pyscript.core + run: npm run build + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: ${{ secrets.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_OIDC_RUNNER_ROLE }} + + - name: Generate index.html in snapshot + working-directory: . + run: sed -e 's#_PATH_#https://pyscript.net/snapshots/${{ inputs.snapshot_version }}/#' -e 's#_DOC_VERSION_#${{ inputs.snapshot_version }}#' -e 's#_TAG_VERSION_#/tag/${{ inputs.snapshot_version }}#' -e 's#_VERSION_#${{ inputs.snapshot_version }}#' ./public/index.html > ./core/dist/index.html + + - name: Copy to Snapshot + run: > + aws s3 sync ./dist/ s3://pyscript.net/snapshots/${{ inputs.snapshot_version }}/ diff --git a/.github/workflows/publish-unstable.yml b/.github/workflows/publish-unstable.yml new file mode 100644 index 00000000000..89a0e2b8902 --- /dev/null +++ b/.github/workflows/publish-unstable.yml @@ -0,0 +1,76 @@ +name: "Publish Unstable" + +on: + push: # Only run on merges into main that modify files under core/ and examples/ + branches: + - main + paths: + - core/** + - examples/** + + workflow_dispatch: + +jobs: + publish-unstable: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + defaults: + run: + working-directory: ./core + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install node + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Python venv + run: python -m venv env + + - name: Activate Python + run: source env/bin/activate + + - name: Update pip + run: pip install --upgrade pip + + - name: Install PyMinifier + run: pip install --ignore-requires-python python-minifier + + - name: Install Setuptools + run: pip install setuptools + + - name: Cache node modules + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: NPM Install + run: npm install && npx playwright install chromium + + - name: Build + run: npm run build + + - name: Generate index.html in snapshot + working-directory: . + run: sed -e 's#_PATH_#./#' -e 's#_DOC_VERSION_#latest#' -e 's#_TAG_VERSION_##' -e 's#_VERSION_#latest#' ./public/index.html > ./core/dist/index.html + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: ${{ secrets.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_OIDC_RUNNER_ROLE }} + + - name: Sync to S3 + run: aws s3 sync --quiet ./dist/ s3://pyscript.net/unstable/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000000..785b7cbbf3f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,80 @@ +name: "[CI] Test" + +on: + push: # Only run on merges into main that modify certain files + branches: + - main + paths: + - core/** + - .github/workflows/test.yml + + pull_request: # Only run on merges into main that modify certain files + branches: + - main + paths: + - core/** + - .github/workflows/test.yml + workflow_dispatch: + +jobs: + BuildAndTest: + runs-on: ubuntu-latest + env: + MINICONDA_PYTHON_VERSION: py38 + MINICONDA_VERSION: 4.11.0 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 3 + + # display a git log: when you run CI on PRs, github automatically + # merges the PR into main and run the CI on that commit. The idea + # here is to show enough of git log to understand what is the + # actual commit (in the PR) that we are using. See also + # 'fetch-depth: 3' above. + - name: git log + run: git log --graph -3 + + - name: Install node + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Cache node modules + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: setup Miniconda + uses: conda-incubator/setup-miniconda@v3 + + - name: Create and activate virtual environment + run: | + python3 -m venv test_venv + source test_venv/bin/activate + echo PATH=$PATH >> $GITHUB_ENV + echo VIRTUAL_ENV=$VIRTUAL_ENV >> $GITHUB_ENV + + - name: Setup dependencies in virtual environment + run: | + make setup + + - name: Build + run: make build # Integration tests run in the build step. + + - uses: actions/upload-artifact@v4 + with: + name: pyscript + path: | + core/dist/ + if-no-files-found: error + retention-days: 7 diff --git a/.gitignore b/.gitignore index 86b04373c8b..6ccef40cf9e 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ instance/ # Sphinx documentation docs/_build/ +docs/_env/ # PyBuilder target/ @@ -134,3 +135,18 @@ dmypy.json .pyre/ node_modules/ + +coverage/ + +# junit xml for test results +test_results + +# @pyscript/core npm artifacts +core/test-results/* +core/core.* +core/dist +core/dist.zip +core/src/plugins.js +core/src/stdlib/pyscript.js +core/src/3rd-party/* +!core/src/3rd-party/READMEmd diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f0784a62504..b18b22ee168 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,53 @@ -default_stages: [commit] +# This is the configuration for pre-commit, a local framework for managing pre-commit hooks +# Check out the docs at: https://pre-commit.com/ +ci: + #skip: [eslint] + autoupdate_schedule: monthly + +default_stages: [pre-commit] repos: - - repo: https://github.com/psf/black - rev: 22.3.0 - hooks: - - id: black - - repo: https://github.com/pycqa/isort - rev: 5.10.1 - hooks: - - id: isort - name: isort (python) - args: [--profile, black] + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-builtin-literals + - id: check-case-conflict + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-json + exclude: tsconfig\.json + - id: check-toml + exclude: bad\.toml + - id: check-xml + - id: check-yaml + - id: detect-private-key + - id: end-of-file-fixer + exclude: core/dist|\.min\.js$ + - id: trailing-whitespace + + - repo: https://github.com/psf/black + rev: 25.1.0 + hooks: + - id: black + exclude: core/tests + args: ["-l", "88", "--skip-string-normalization"] + + - repo: https://github.com/codespell-project/codespell + rev: v2.4.1 + hooks: + - id: codespell # See 'pyproject.toml' for args + exclude: fs\.py|\.js\.map$ + additional_dependencies: + - tomli + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.11.8 + hooks: + - id: ruff + exclude: core/tests + + - repo: https://github.com/hoodmane/pyscript-prettier-precommit + rev: "v3.0.0-alpha.6" + hooks: + - id: prettier + exclude: core/tests|core/dist|core/types|core/src/stdlib/pyscript.js|pyscript\.sw/|core/src/3rd-party + args: [--tab-width, "4"] diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000000..32b310b5153 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +ISSUE_TEMPLATE +*.min.* +package-lock.json diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 14e7620f6e2..66e416d3162 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,4 +1,4 @@ # Code of Conduct -The Code of Conduct is available in the pyscript Governance repo. +The Code of Conduct is available in the PyScript Governance repo. See https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b28b179e00c..8ce2c517a45 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,11 +1,4 @@ -# Contributing +# Contributing to PyScript -This Project welcomes contributions, suggestions, and feedback. All contributions, suggestions, and feedback you submitted are accepted under the [Apache 2.0](./LICENSE) license. You represent that if you do not own copyright in the code that you have the authority to submit it under the [Apache 2.0](./LICENSE) license. All feedback, suggestions, or contributions are not confidential. - -Contributors are invited to be maintainers to the project by demonstrating good decision making in their contributions, a commitment to goals of the project, and consistent adherence to the [code of conduct](https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md). New maintainers are invited by a 3/4 vote of the existing maintainers. - -The Project abides by the Organization's [code of conduct](https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md) and [trademark policy](https://github.com/pyscript/governance/blob/main/TRADEMARKS.md). - ---- -Part of MVG-0.1-beta. -Made with love by GitHub. Licensed under the [CC-BY 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/). +Please see our guide to contributing to PyScript +[in our documentation](https://docs.pyscript.net/latest/contributing/). diff --git a/GETTING-STARTED.md b/GETTING-STARTED.md deleted file mode 100644 index d43e5521431..00000000000 --- a/GETTING-STARTED.md +++ /dev/null @@ -1,211 +0,0 @@ -# Getting started with PyScript - -This page will guide you through getting started with PyScript. - -## Development setup - -PyScript does not require any development environment other -than a web browser. We recommend using [Chrome](https://www.google.com/chrome/). - -If you're using [VSCode](https://code.visualstudio.com/), the -[Live Server extension](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer) -can be used to reload the page as you edit the HTML file. - -## Installation - -There is no installation required. In this document we'll use -the PyScript assets served on https://pyscript.net. - -If you want to download the source and build it yourself, follow -the instructions in the README.md file. - -## Your first PyScript HTML file - -Here's a "Hello, world!" example using PyScript. - -Using your favorite editor create a new file called `hello.html` in -the same directory as your PyScript, JavaScript, and CSS files with the -following content, and open the file in your web browser. You can typically -open an HTML by double clicking it in your file explorer. - -```html - -
- - - -Today is
-