Skip to content

Commit 1a0ff57

Browse files
authored
Merge branch 'main' into Xmader/feat/npm-py
2 parents 0e0d15d + f1e980c commit 1a0ff57

File tree

150 files changed

+16977
-1009
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+16977
-1009
lines changed

.eslintrc.js

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/**
2+
* @file .eslintrc.js - ESLint configuration file, following the Core Team's JS Style Guide.
3+
* @author Wes Garland <[email protected]>
4+
* @date Mar. 2022, July 2023
5+
*/
6+
7+
/**
8+
* @see {@link https://eslint.org/docs/latest/use/configure/}
9+
* @type {import('eslint').Linter.Config}
10+
*/
11+
module.exports = {
12+
extends: 'eslint:recommended',
13+
globals: {
14+
'python': true
15+
},
16+
env: {
17+
browser: true,
18+
commonjs: true,
19+
es2021: true,
20+
node: true
21+
},
22+
parserOptions: {
23+
ecmaVersion: 13,
24+
sourceType: 'script',
25+
},
26+
rules: {
27+
'indent': [ 'warn', 2, {
28+
SwitchCase: 1,
29+
ignoredNodes: ['CallExpression', 'ForStatement'],
30+
}],
31+
'linebreak-style': [ 'error', 'unix' ],
32+
'func-call-spacing': [ 'off', 'never' ],
33+
'no-prototype-builtins': 'off',
34+
'quotes': [ 'warn', 'single', 'avoid-escape' ],
35+
'no-empty': [ 'warn' ],
36+
'no-multi-spaces': [ 'off' ],
37+
'prettier/prettier': [ 'off' ],
38+
'vars-on-top': [ 'error' ],
39+
'no-var': [ 'off' ],
40+
'spaced-comment': [ 'warn' ],
41+
'brace-style': [ 'warn', 'allman' ],
42+
'no-eval': [ 'error' ],
43+
'object-curly-spacing': [ 'warn', 'always' ],
44+
'eqeqeq': [ 'warn', 'always' ],
45+
'no-constant-condition': [ 'warn' ],
46+
'no-extra-boolean-cast': [ 'warn' ],
47+
'no-sparse-arrays': [ 'off' ],
48+
'no-inner-declarations': [ 'off' ],
49+
'no-loss-of-precision': [ 'warn' ],
50+
'require-atomic-updates': [ 'warn' ],
51+
'no-dupe-keys': [ 'warn' ],
52+
'no-dupe-class-members': [ 'warn' ],
53+
'no-fallthrough': [ 'warn', { commentPattern: 'fall[ -]*through' }],
54+
'no-invalid-this': [ 'error' ],
55+
'no-return-assign': [ 'error' ],
56+
'no-return-await': [ 'warn' ],
57+
'no-unused-expressions': [ 'warn', { allowShortCircuit: true, allowTernary: true } ],
58+
'prefer-promise-reject-errors': [ 'error' ],
59+
'no-throw-literal': [ 'error' ],
60+
'semi': [ 'warn' ],
61+
'semi-style': [ 'warn', 'last' ],
62+
'semi-spacing': [ 'error', { 'before': false, 'after': true }],
63+
'no-extra-semi': [ 'warn' ],
64+
'no-tabs': [ 'error' ],
65+
'symbol-description': [ 'error' ],
66+
'operator-linebreak': [ 'warn', 'before' ],
67+
'new-cap': [ 'warn' ],
68+
'consistent-this': [ 'error', 'that' ],
69+
'no-shadow': [ 'error' ],
70+
'no-label-var': [ 'error' ],
71+
'radix': [ 'error' ],
72+
'no-self-compare': [ 'error' ],
73+
'require-await': [ 'error' ],
74+
'require-yield': [ 'error' ],
75+
'no-promise-executor-return': [ 'off' ],
76+
'no-template-curly-in-string': [ 'warn' ],
77+
'no-unmodified-loop-condition': [ 'warn' ],
78+
'no-unused-private-class-members': [ 'warn' ],
79+
'no-use-before-define': [ 'error', { functions: false, classes: true, variables: true }],
80+
'no-implicit-coercion': [1, {
81+
disallowTemplateShorthand: false,
82+
boolean: true,
83+
number: true,
84+
string: true,
85+
allow: ['!!'] /* really only want to allow if(x) and if(!x) but not if(!!x) */
86+
}],
87+
'no-trailing-spaces': [ 'off', {
88+
skipBlankLines: true,
89+
ignoreComments: true
90+
}],
91+
'no-unused-vars': ['warn', {
92+
vars: 'all',
93+
args: 'none',
94+
ignoreRestSiblings: false
95+
}],
96+
}
97+
};
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: File a Bug Report for PythonMonkey
2+
description: Use this template to report PythonMonkey-related issues. Thank you so much for making an issue!
3+
body:
4+
- type: dropdown
5+
id: issue-type
6+
attributes:
7+
label: Issue type
8+
description: What type of issue would you like to report?
9+
multiple: false
10+
options:
11+
- Bug
12+
- Build/Install
13+
- Performance
14+
- Support
15+
- Documentation Bug / Error
16+
- Other
17+
validations:
18+
required: true
19+
20+
- type: dropdown
21+
id: source
22+
attributes:
23+
label: How did you install PythonMonkey?
24+
options:
25+
- Source
26+
- Installed from pip
27+
- Other (Please specify in additional info)
28+
29+
- type: input
30+
id: OS
31+
attributes:
32+
label: OS platform and distribution
33+
placeholder: e.g., Linux Ubuntu 22.04
34+
35+
- type: input
36+
id: Python
37+
attributes:
38+
label: Python version (`python --version`)
39+
placeholder: e.g., 3.9
40+
41+
- type: input
42+
id: PythonMonkey
43+
attributes:
44+
label: PythonMonkey version (`pip show pythonmonkey`)
45+
placeholder: 0.2.0 or 0.0.1.dev997+1eb883
46+
description: You can also get this with `pmjs --version`.
47+
48+
- type: textarea
49+
id: what-happened
50+
attributes:
51+
label: Bug Description
52+
description: Please provide a clear and concise description of what the bug is.
53+
54+
- type: textarea
55+
id: code-to-reproduce
56+
attributes:
57+
label: Standalone code to reproduce the issue
58+
description: Provide a reproducible test case that is the bare minimum necessary to generate the problem.
59+
value:
60+
render: shell
61+
62+
- type: textarea
63+
id: logs
64+
attributes:
65+
label: Relevant log output or backtrace
66+
description: Please copy and paste any relevant log output.
67+
render: shell
68+
69+
- type: textarea
70+
id: additional-info
71+
attributes:
72+
label: Additional info if applicable
73+
description: Anything else to add.
74+
render: shell
75+
76+
- type: input
77+
id: branch
78+
attributes:
79+
label: What branch of PythonMonkey were you developing on? (If applicable)
80+
placeholder: main
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Make a Feature Request for PythonMonkey
2+
description: Use this template to make feature requests for PythonMonkey. Thank you so much for making an issue!
3+
body:
4+
5+
- type: textarea
6+
id: feature-body
7+
attributes:
8+
label: Describe your feature request here.
9+
description: Feel free to include diagrams drawings or anything else to help explain it.
10+
11+
- type: textarea
12+
id: feature-code
13+
attributes:
14+
label: Code example
15+
description: Provide a code example of this feature if applicable.
16+
value:
17+
render: shell
18+

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "npm" # See documentation for possible values
9+
directory: "/python/pminit/pythonmonkey" # Location of package manifests
10+
schedule:
11+
interval: "weekly"

.github/workflows/test-and-publish.yaml

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
# Use Ubuntu 20.04 / macOS 12 + Python 3.10 to build SpiderMonkey
29-
os: [ 'ubuntu-20.04', 'macos-12', 'm2ci' ]
28+
# Use Ubuntu 20.04 / macOS 13 x86_64 / macOS 14 arm64 + Python 3.10 to build SpiderMonkey
29+
os: [ 'ubuntu-20.04', 'macos-13', 'macos-14' ] # macOS 14 runner exclusively runs on M1 hardwares
30+
# see https://github.blog/changelog/2024-01-30-github-actions-macos-14-sonoma-is-now-available
3031
python_version: [ '3.10' ]
3132
runs-on: ${{ matrix.os }}
3233
steps:
@@ -40,13 +41,13 @@ jobs:
4041
with:
4142
path: |
4243
./_spidermonkey_install/*
43-
key: spidermonkey102.13-${{ runner.os }}-${{ runner.arch }}
44+
key: spidermonkey115.7.0-${{ runner.os }}-${{ runner.arch }}
4445
lookup-only: true # skip download
45-
- name: Setup Poetry
46-
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
47-
uses: snok/install-poetry@v1
48-
with:
49-
version: 1.5.1
46+
- name: Setup XCode
47+
if: ${{ (matrix.os == 'macos-13' || matrix.os == 'macos-14') && steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
48+
# SpiderMonkey 115 ESR requires XCode SDK version at least 13.3
49+
# https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#installed-sdks
50+
run: sudo xcode-select -switch /Applications/Xcode_14.3.app
5051
- name: Build spidermonkey
5152
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
5253
run: ./setup.sh
@@ -60,13 +61,8 @@ jobs:
6061
with:
6162
path: |
6263
./_spidermonkey_install/*
63-
key: spidermonkey102.13-${{ runner.os }}-${{ runner.arch }}
64+
key: spidermonkey115.7.0-${{ runner.os }}-${{ runner.arch }}
6465
lookup-only: true # skip download
65-
- name: Setup Poetry
66-
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
67-
uses: snok/install-poetry@v1
68-
with:
69-
version: 1.5.1
7066
- name: Install dependencies
7167
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
7268
shell: powershell
@@ -82,30 +78,35 @@ jobs:
8278
powershell -command 'Start-Process -Wait -FilePath "./MozillaBuildSetup-Latest.exe" -ArgumentList "/S"'
8379
- name: Build spidermonkey in MozillaBuild environment
8480
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
81+
env:
82+
# Preserve MozillaBuild v4.0.x behaviour
83+
# see https://groups.google.com/u/1/a/mozilla.org/g/dev-platform/c/hF51Q3j6ca8
84+
USE_MINTTY: 0
8585
run: /c/mozilla-build/start-shell.bat -use-full-path -here ./setup.sh
8686
build-and-test:
8787
needs: [build-spidermonkey-unix, build-spidermonkey-win]
8888
strategy:
8989
fail-fast: false
9090
matrix:
9191
# The lowest supported version is Ubuntu 20.04 + Python 3.8 or macOS 12 + Python 3.9
92-
os: [ 'ubuntu-20.04', 'macos-12', 'windows-2019', 'm2ci' ]
93-
python_version: [ '3.8', '3.9', '3.10', '3.11', '3.12-dev' ]
92+
os: [ 'ubuntu-20.04', 'macos-12', 'windows-2019', 'macos-14' ]
93+
python_version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
9494
exclude:
9595
# macOS 12 comes with Python 3.9 by default, so we drop ci support for Python 3.8 on macOS
9696
# FIXME: We can't build on macOS 11 for now because our prebuilt `uncrustify` binary requires macOS 12
9797
- os: 'macos-12'
9898
python_version: '3.8'
9999
# actions/setup-python: The version '3.8'/'3.9' with architecture 'arm64' was not found for macOS.
100100
# see https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
101-
- os: 'm2ci'
101+
- os: 'macos-14'
102102
python_version: '3.8'
103-
- os: 'm2ci'
103+
- os: 'macos-14'
104104
python_version: '3.9'
105105
runs-on: ${{ matrix.os }}
106106
steps:
107107
- uses: actions/checkout@v3
108108
with:
109+
submodules: recursive
109110
fetch-depth: 0 # fetch all history for all branches and tags
110111
# poetry-dynamic-versioning needs git tags to produce the correct version number
111112
- uses: actions/setup-python@v4
@@ -120,7 +121,13 @@ jobs:
120121
echo "Installing Dependencies"
121122
if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux
122123
sudo apt-get update -y
123-
sudo apt-get install -y cmake doxygen graphviz llvm
124+
sudo apt-get install -y cmake graphviz llvm
125+
# Install Doxygen
126+
# the newest version in Ubuntu 20.04 repository is 1.8.17, but we need Doxygen 1.9 series
127+
wget -c -q https://www.doxygen.nl/files/doxygen-1.9.7.linux.bin.tar.gz
128+
tar xf doxygen-1.9.7.linux.bin.tar.gz
129+
cd doxygen-1.9.7 && sudo make install && cd -
130+
rm -rf doxygen-1.9.7 doxygen-1.9.7.linux.bin.tar.gz
124131
elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS
125132
brew update || true # allow failure
126133
brew install cmake doxygen graphviz pkg-config wget coreutils # `coreutils` installs the `realpath` command
@@ -135,7 +142,7 @@ jobs:
135142
with:
136143
path: |
137144
./_spidermonkey_install/*
138-
key: spidermonkey102.13-${{ runner.os }}-${{ runner.arch }}
145+
key: spidermonkey115.7.0-${{ runner.os }}-${{ runner.arch }}
139146
fail-on-cache-miss: true # SpiderMonkey is expected to be cached in its dedicated job
140147
- name: Build pminit
141148
run: |
@@ -154,13 +161,17 @@ jobs:
154161
with:
155162
name: wheel-${{ github.run_id }}-${{ github.sha }}
156163
path: ./dist/
164+
- name: Upload Doxygen-generated docs as CI artifacts
165+
uses: actions/upload-artifact@v3
166+
if: ${{ matrix.os == 'ubuntu-20.04' && matrix.python_version == '3.11' }} # making sure we only upload once
167+
with:
168+
name: docs-${{ github.run_id }}-${{ github.sha }}
169+
path: ./build/docs/html/
157170
- name: Run Python tests (pytest)
158171
run: |
159172
poetry run python -m pip install --force-reinstall --verbose ./dist/*
160173
poetry run python -m pytest tests/python
161174
- name: Run JS tests (peter-jr)
162-
if: ${{ runner.os != 'Windows' }} # Python on Windows doesn't have the readline library
163-
# FIXME: on macOS we must make sure to use the GNU version of wc and realpath
164175
run: |
165176
poetry run bash ./peter-jr ./tests/js/
166177
sdist:
@@ -191,14 +202,11 @@ jobs:
191202
runs-on: ubuntu-20.04
192203
if: ${{ success() && github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
193204
steps:
194-
- uses: actions/checkout@v3
205+
# no need to checkout
195206
- uses: actions/setup-python@v4
196207
with:
197208
python-version: '3.9'
198-
- name: Setup Poetry
199-
uses: snok/install-poetry@v1
200-
with:
201-
version: 1.5.1
209+
- run: pip install twine
202210
- name: Download wheels built
203211
uses: actions/download-artifact@v3
204212
with:
@@ -207,8 +215,8 @@ jobs:
207215
- run: ls -lah ./dist/
208216
- name: Publish package
209217
run: |
210-
poetry publish \
211-
--no-interaction --skip-existing \
218+
twine upload dist/* \
219+
--non-interactive --skip-existing \
212220
--username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
213221
publish-nightly:
214222
# Implement a very basic Python package repository (https://peps.python.org/pep-0503/)
@@ -229,6 +237,11 @@ jobs:
229237
with:
230238
name: wheel-${{ github.run_id }}-${{ github.sha }}
231239
path: ./dist/
240+
- name: Download docs html generated by Doxygen
241+
uses: actions/download-artifact@v3
242+
with:
243+
name: docs-${{ github.run_id }}-${{ github.sha }}
244+
path: ./docs/
232245
- name: Move wheels to the correct repository project paths
233246
run: |
234247
mkdir -p ./pythonmonkey/ ./pminit/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "tests/commonjs-official"]
22
path = tests/commonjs-official
33
url = https://github.com/commonjs/commonjs.git
4+
[submodule "cmake/docs/doxygen-awesome-css"]
5+
path = cmake/docs/doxygen-awesome-css
6+
url = https://github.com/jothepro/doxygen-awesome-css.git

0 commit comments

Comments
 (0)