CI: correct setup for nodeenv testing (#306) #595
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- "*.md" | |
- ".vscode/**" | |
- "docs/**" | |
- "LICENSE" | |
pull_request: | |
branches: | |
- main | |
paths-ignore: | |
- "*.md" | |
- ".vscode/**" | |
- "docs/**" | |
- "LICENSE" | |
jobs: | |
test: | |
name: test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-12, windows-latest] | |
node: [14, 16] | |
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v3 | |
# TODO: ensure that pyright-python uses this node version | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node }} | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r dev-requirements.txt | |
- uses: actions/cache@v2 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('dev-requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Ensure node version | |
run: | | |
python .github/scripts/check_node.py '${{ matrix.node }}' | |
- name: Run tests | |
run: | | |
tox -e setup,py,report | |
lint: | |
name: lint | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 2 | |
matrix: | |
python-version: [3.9] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r dev-requirements.txt | |
- uses: actions/cache@v2 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('dev-requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Check linters | |
run: | | |
tox -e lint | |
docker: | |
name: docker | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
docker-platform: [linux/amd64, linux/arm64] | |
python-os-distro: [slim-bullseye, alpine] | |
exclude: | |
# Dockerfile is currently broken for alpine / arm64 | |
# https://github.com/RobertCraigie/pyright-python/issues/123 | |
- docker-platform: linux/arm64 | |
python-os-distro: alpine | |
# This is currently way too slow, takes ~30 minutes to complete | |
# TODO: investigate | |
- docker-platform: linux/arm64 | |
python-os-distro: slim-bullseye | |
steps: | |
- uses: actions/checkout@v3 | |
# https://github.com/docker/build-push-action/ | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Docker Build | |
uses: docker/build-push-action@v3 | |
# https://github.com/docker/build-push-action/#inputs | |
# Test each platform individually for easier testing | |
with: | |
context: . | |
file: tests/Dockerfile | |
platforms: "${{ matrix.docker-platform }}" | |
build-args: OS_DISTRO=${{ matrix.python-os-distro }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
docker-windows: | |
name: docker (windows) | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Docker Build | |
# Use --% to allow double hyphen | |
# Caching not currently working since we don't use buildx yet, windows | |
# support seems poor because of interactions with --privileged | |
# --cache-from=type=gha --cache-to=type=gha,mode=max | |
run: | | |
docker build --% -f tests/windows.Dockerfile -t pyright-python . | |
docker-minimal: | |
name: docker (minimal) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Docker Build | |
run: | | |
REF=$(echo $GITHUB_REF | sed 's/refs\/heads\///') | |
docker run python:3.11.4 /bin/sh -c " | |
pip install git+https://github.com/RobertCraigie/pyright-python.git@$REF && \ | |
pyright --version | |
" | |
tests_status: | |
if: always() | |
needs: | |
- test | |
- lint | |
- docker | |
- docker-windows | |
runs-on: ubuntu-latest | |
steps: | |
- name: Decide whether the needed jobs succeeded or failed | |
uses: re-actors/alls-green@release/v1 | |
with: | |
jobs: ${{ toJSON(needs) }} |