Skip to content

Implement 'in' operation for Objects #637

Implement 'in' operation for Objects

Implement 'in' operation for Objects #637

name: 'Test and Publish Suite'
on:
push:
branches:
- main
tags:
- '*'
workflow_call:
workflow_dispatch:
pull_request:
env:
# don't upgrade outdated brew packages because the process is too slow
HOMEBREW_NO_INSTALL_UPGRADE: 1
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
defaults:
run:
# run with Git Bash on Windows
shell: bash
jobs:
build-spidermonkey-unix:
strategy:
fail-fast: false
matrix:
# Use Ubuntu 20.04 / macOS 13 + Python 3.10 to build SpiderMonkey
os: [ 'ubuntu-20.04', 'macos-13', 'm2ci' ]
python_version: [ '3.10' ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- name: Cache spidermonkey build
id: cache-spidermonkey
uses: actions/cache@v3
with:
path: |
./_spidermonkey_install/*
key: spidermonkey115.1.0-${{ runner.os }}-${{ runner.arch }}
lookup-only: true # skip download
- name: Setup XCode
if: ${{ matrix.os == 'macos-13' && steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
# SpiderMonkey 115 ESR requires XCode SDK version at least 13.3
# https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#installed-sdks
run: sudo xcode-select -switch /Applications/Xcode_14.3.app
- name: Build spidermonkey
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
run: ./setup.sh
build-spidermonkey-win:
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
- name: Cache spidermonkey build
id: cache-spidermonkey
uses: actions/cache@v3
with:
path: |
./_spidermonkey_install/*
key: spidermonkey115.1.0-${{ runner.os }}-${{ runner.arch }}
lookup-only: true # skip download
- name: Install dependencies
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
shell: powershell
run: |
# Already installed in Github Actions runner
# choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System' # add CMake to system PATH
# choco install -y llvm gnuwin32-m4
choco install -y wget make
- name: Install MozillaBuild
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
run: |
wget -c -q https://ftp.mozilla.org/pub/mozilla/libraries/win32/MozillaBuildSetup-Latest.exe
powershell -command 'Start-Process -Wait -FilePath "./MozillaBuildSetup-Latest.exe" -ArgumentList "/S"'
- name: Build spidermonkey in MozillaBuild environment
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
run: /c/mozilla-build/start-shell.bat -use-full-path -here ./setup.sh
build-and-test:
needs: [build-spidermonkey-unix, build-spidermonkey-win]
strategy:
fail-fast: false
matrix:
# The lowest supported version is Ubuntu 20.04 + Python 3.8 or macOS 12 + Python 3.9
os: [ 'ubuntu-20.04', 'macos-12', 'windows-2019', 'm2ci' ]
python_version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
exclude:
# macOS 12 comes with Python 3.9 by default, so we drop ci support for Python 3.8 on macOS
# FIXME: We can't build on macOS 11 for now because our prebuilt `uncrustify` binary requires macOS 12
- os: 'macos-12'
python_version: '3.8'
# actions/setup-python: The version '3.8'/'3.9' with architecture 'arm64' was not found for macOS.
# see https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
- os: 'm2ci'
python_version: '3.8'
- os: 'm2ci'
python_version: '3.9'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0 # fetch all history for all branches and tags
# poetry-dynamic-versioning needs git tags to produce the correct version number
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- name: Setup Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
- name: Install Dependencies
run: |
echo "Installing Dependencies"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux
sudo apt-get update -y
sudo apt-get install -y cmake graphviz llvm
# Install Doxygen
# the newest version in Ubuntu 20.04 repository is 1.8.17, but we need Doxygen 1.9 series
wget -c -q https://www.doxygen.nl/files/doxygen-1.9.7.linux.bin.tar.gz
tar xf doxygen-1.9.7.linux.bin.tar.gz
cd doxygen-1.9.7 && sudo make install && cd -
rm -rf doxygen-1.9.7 doxygen-1.9.7.linux.bin.tar.gz
elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS
brew update || true # allow failure
brew install cmake doxygen graphviz pkg-config wget coreutils # `coreutils` installs the `realpath` command
fi
echo "Installing python deps"
poetry self add "poetry-dynamic-versioning[plugin]"
poetry env use python3 # use the correct Python version we've set up
poetry install --no-root --only=dev
echo "Installed Dependencies"
- name: Use cached spidermonkey build
uses: actions/cache@v3
with:
path: |
./_spidermonkey_install/*
key: spidermonkey115.1.0-${{ runner.os }}-${{ runner.arch }}
fail-on-cache-miss: true # SpiderMonkey is expected to be cached in its dedicated job
- name: Build pminit
run: |
cd python/pminit
poetry build --format=sdist
cd -
mkdir -p ./dist/
mv -v python/pminit/dist/* ./dist/
- name: Build wheel
run: |
echo $(poetry run python --version)
poetry build --format=wheel
ls -lah ./dist/
- name: Upload wheel as CI artifacts
uses: actions/upload-artifact@v3
with:
name: wheel-${{ github.run_id }}-${{ github.sha }}
path: ./dist/
- name: Upload Doxygen-generated docs as CI artifacts
uses: actions/upload-artifact@v3
if: ${{ matrix.os == 'ubuntu-20.04' && matrix.python_version == '3.11' }} # making sure we only upload once
with:
name: docs-${{ github.run_id }}-${{ github.sha }}
path: ./build/docs/html/
- name: Run Python tests (pytest)
run: |
poetry run python -m pip install --force-reinstall --verbose ./dist/*
poetry run python -m pytest tests/python
- name: Run JS tests (peter-jr)
run: |
poetry run bash ./peter-jr ./tests/js/
sdist:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Setup Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
- name: Build source distribution (sdist) file
run: |
poetry self add "poetry-dynamic-versioning[plugin]"
poetry build --format=sdist
ls -lah ./dist/
- name: Upload sdist as CI artifacts
uses: actions/upload-artifact@v3
with:
name: wheel-${{ github.run_id }}-${{ github.sha }}
path: ./dist/
publish:
needs: [build-and-test, sdist]
runs-on: ubuntu-20.04
if: ${{ success() && github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
steps:
# no need to checkout
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- run: pip install twine
- name: Download wheels built
uses: actions/download-artifact@v3
with:
name: wheel-${{ github.run_id }}-${{ github.sha }}
path: ./dist/
- run: ls -lah ./dist/
- name: Publish package
run: |
twine upload dist/* \
--non-interactive --skip-existing \
--username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
publish-nightly:
# Implement a very basic Python package repository (https://peps.python.org/pep-0503/)
# and deploy the static files to GitHub Pages
needs: [build-and-test, sdist]
runs-on: ubuntu-20.04
if: ${{ (success() || failure()) && github.ref_name == 'main' }} # publish nightly builds regardless of tests failure
permissions: # grant GITHUB_TOKEN the permissions required to make a Pages deployment
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
# don't checkout
- name: Download wheels built
uses: actions/download-artifact@v3
with:
name: wheel-${{ github.run_id }}-${{ github.sha }}
path: ./dist/
- name: Download docs html generated by Doxygen
uses: actions/download-artifact@v3
with:
name: docs-${{ github.run_id }}-${{ github.sha }}
path: ./docs/
- name: Move wheels to the correct repository project paths
run: |
mkdir -p ./pythonmonkey/ ./pminit/
mv ./dist/pythonmonkey-* ./pythonmonkey/
mv ./dist/pminit-* ./pminit/
- name: Generate index page for the project
run: |
generate_index () {
cd $1
html="<html><head><title>PythonMonkey Nightly Builds</title></head><body>"
for file in ./*; do # generate <a> tags for each file
html+="<a href=\"$file\">$file</a><br/>"
done
html+="</body></html>"
echo "$html" > ./index.html
cd -
}
generate_index ./pythonmonkey/
generate_index ./pminit/
- name: Generate repository root page
run: |
html="<html><head><title>PythonMonkey Nightly Builds</title></head><body>"
html+="<h1>PythonMonkey Nightly Builds</h1>"
html+="<p>To install nightly builds, run</p>"
html+="<pre>pip install --extra-index-url https://nightly.pythonmonkey.io/ --pre pythonmonkey</pre>"
html+="<h3>Browse files:</h3>"
html+="<li><a href="pythonmonkey/">pythonmonkey</a></li>"
html+="<li><a href="pminit/">pminit</a></li>"
html+="</body></html>"
echo "$html" > ./index.html
- uses: actions/upload-pages-artifact@v1
with:
path: ./
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2