Skip to content

Commit

Permalink
fix ci (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl authored Nov 10, 2024
1 parent df668e3 commit b0624b8
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 49 deletions.
48 changes: 40 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:
env:
PYTHONUNBUFFERED: '1'
PIP_DISABLE_PIP_VERSION_CHECK: '1'
CACHE_EPOCH: '0'
CACHE_EPOCH: '3'
URLJSF_PIXI_VERSION: 0.35.0

jobs:
Expand All @@ -30,16 +30,27 @@ jobs:
cache-key: job-build
- name: cache (node)
uses: actions/cache@v4
id: cache-node-modules
with:
path: node_modules
key: |
${{ env.CACHE_EPOCH }}-${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock') }}
- run: pixi run build-yarn
- run: ls node_modules/.skip-yarn || mkdir -p build && echo '1' > node_modules/.skip-yarn
- run: pixi run dist
- uses: actions/upload-artifact@v4
with:
name: urljsf-${{ github.run_number }}-dist
path: ./dist
path: |
./dist
- uses: actions/upload-artifact@v4
with:
name: urljsf-${{ github.run_number }}-build
path: |
build/task-cache-v0
js/lib
js/dist
js/tsconfig.tsbuildinfo
src/urljs/_static
lint:
runs-on: ubuntu-latest
Expand All @@ -52,13 +63,16 @@ jobs:
cache: true
environments: build lint
cache-key: job-lint
- uses: actions/download-artifact@v4
with:
name: urljsf-${{ github.run_number }}-build
- name: cache (node)
uses: actions/cache@v4
id: cache-node-modules
with:
path: node_modules
key: |
${{ env.CACHE_EPOCH }}-${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock') }}
- run: pixi run fix
- run: pixi run lint

test:
Expand Down Expand Up @@ -87,8 +101,12 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: urljsf-${{ github.run_number }}-dist
path: ./dist
- run: pixi run ${{ matrix.test-env }}-pytest
path: |
./dist
- uses: actions/download-artifact@v4
with:
name: urljsf-${{ github.run_number }}-build
- run: pixi run -v ${{ matrix.test-env }}-pytest
- uses: actions/upload-artifact@v4
if: always()
with:
Expand All @@ -106,20 +124,34 @@ jobs:
cache: true
environments: build docs check atest
cache-key: job-docs
- name: cache (node)
uses: actions/cache@v4
with:
path: node_modules
key: |
${{ env.CACHE_EPOCH }}-${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock') }}
- uses: actions/download-artifact@v4
with:
name: urljsf-${{ github.run_number }}-dist
path: ./dist
- run: pixi run docs-sphinx
path: |
./dist
- uses: actions/download-artifact@v4
with:
name: urljsf-${{ github.run_number }}-build
- run: pixi run build-yarn
- run: pixi run docs
- uses: actions/upload-artifact@v4
if: always()
with:
name: urljsf-${{ github.run_number }}-docs
path: ./build/docs
- run: pixi run build-app-cov
- run: pixi run atest
- run: pixi run check
- run: pixi run report
if: always()
- uses: actions/upload-artifact@v4
if: always()
with:
name: urljsf-${{ github.run_number }}-docs-reports
path: ./build/reports
18 changes: 14 additions & 4 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ permissions:
env:
PYTHONUNBUFFERED: '1'
PIP_DISABLE_PIP_VERSION_CHECK: '1'
URLJSF_PIXI_VERSION: 0.35.0

jobs:
build:
Expand All @@ -22,13 +23,22 @@ jobs:
- uses: actions/checkout@v4
- uses: prefix-dev/[email protected]
with:
pixi-version: v0.27.0
cache: true
environments: build docs test test-min
cache-key: job-pages
pixi-version: v${{ env.URLJSF_PIXI_VERSION }}
cache: false
environments: |
atest
build
docs
test
test-min
- run: pixi run build-yarn
- run: pixi run build
- run: pixi run dist
- run: pixi run test
- run: pixi run docs
- run: pixi run atest
- run: pixi run report
- run: cp -r build/reports/ build/docs/_static/
- uses: actions/upload-pages-artifact@v3
with:
path: build/docs
Expand Down
12 changes: 12 additions & 0 deletions docs/.readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

build:
os: ubuntu-lts-latest
tools:
# `mambaforge-latest` will now start failing: we just need a working `mamba`
python: mambaforge-23.11
commands:
- mamba install -c conda-forge -c nodefaults pixi==0.35.0
- pixi r build
- pixi r docs-sphinx
- pixi r -v docs-rtd
2 changes: 1 addition & 1 deletion js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

This is the browser side of [`urljsf`](https://github.com/deathbeds/urljsf).

You might be able to install this and use it directly, but no particular support will be
You _might_ be able to install this and use it directly, but no particular support is
provided for using it outside of its host application.
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"browser": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"{lib,dist}/**/*.{js,ts,json,html,toml,yaml}"
"{lib,dist}/**/*.{js,ts,json,html,toml,yaml,map}"
],
"scripts": {
"build": "yarn build:lib && yarn build:app",
Expand Down
75 changes: 46 additions & 29 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ build ALL distributed artifacts""", depends-on = [
], cmd = "echo 📦"}
test = {description = """
run ALL unit tests""", depends-on = [
"dist-pypi",
"test-pytest",
"test-min-pytest",
], cmd = "echo 🧪"}
Expand Down Expand Up @@ -92,13 +93,14 @@ py-static-- = """rm -rf src/urljsf/_static/
platform-- = '''mkdir -p build
&& python -c 'import platform; u = platform.uname(); print(f"{u.system}-{u.machine}".lower())'
> build/platform.txt'''
pip-e-- = """python -m pip install
pip-- = """python -m pip install
-vv
-e .
--no-deps
--no-build-isolation
--disable-pip-version-check
--ignore-installed"""
pip-e-- = """pixi r pip-- -e ."""
pip-whl-- = """pixi r pip-- urljsf --find-links=dist --no-index"""
schema-vars-- = '''echo
PROPS_TS=$PIXI_PROJECT_ROOT/js/src/_props.ts
PROPS_JSON=$PIXI_PROJECT_ROOT/js/schema/v0/props.schema.json
Expand All @@ -121,34 +123,35 @@ schema-all-- = '''pixi r schema-props
# setup ########################################################################
[feature.tasks-build.tasks.build-yarn]
description = "- install nodejs-based dependencies"
cmd = "yarn"
cmd = "(cat node_modules/.skip-yarn && echo 'skipping yarn install') || yarn"
inputs = ["{yarn.lock,package.json,.yarnrc.yml}", "js/package.json"]
outputs = ["node_modules/.yarn-state.yml"]

[feature.tasks-dev.tasks.dev-pip]
description = "- install the editable python package for development"
cmd = "pixi r -e dev pip-e--"
inputs = ["pyproject.toml"]

[feature.tasks-lint.tasks.lint-pip]
description = "- install the editable python package for linting"
cmd = "pixi r -e lint pip-e--"
inputs = ["pyproject.toml"]

[feature.tasks-test.tasks.test-pip]
description = "- install the editable python package for testing"
cmd = "pixi r -e test pip-e--"
inputs = ["pyproject.toml"]
description = "- install the built python package for testing"
cmd = "pixi r -e test pip-whl--"
inputs = ["dist/*.whl"]

[feature.tasks-test-min.tasks.test-min-pip]
description = "- install the editable python package for testing (oldest)"
cmd = "pixi r -e test-min pip-e--"
inputs = ["pyproject.toml"]

[feature.tasks-dev.tasks.dev-pip]
description = "- install the editable python package for development"
cmd = "pixi r -e dev pip-e--"
inputs = ["pyproject.toml"]
description = "- install the built python package for testing (oldest)"
cmd = "pixi r -e test-min pip-whl--"
inputs = ["dist/*.whl"]

[feature.tasks-docs.tasks.docs-pip]
description = "- install the editable python package for docs"
cmd = "pixi r -e docs pip-e--"
inputs = ["pyproject.toml"]
description = "- install the built python package for docs"
cmd = "pixi r -e docs pip-whl--"
inputs = ["dist/*.whl"]
depends-on = ["dist-pypi"]

# build ########################################################################
[feature.tasks-build.tasks.build-demo]
Expand Down Expand Up @@ -196,7 +199,7 @@ description = "- build the Python distributions for pypi.org"
cmd = "pyproject-build . --no-isolation"
depends-on = ["build-static", "schema-py"]
inputs = ["{pyproject.toml,LICENSE,README.md}", "src", "!**/__pycache__"]
outputs = ["dist/*.whl", "dist/*.tar.gz"]
outputs = ["dist/*.{whl,tar.gz}"]

[feature.tasks-build.tasks.dist-hash]
description = "- hash the built distributions"
Expand All @@ -218,6 +221,7 @@ description = "- build JSON schema for rjsf form props"
cmd = "export $(pixi r schema-vars--) && pixi r schema-ts-json--"
inputs = ["js/src/_props.ts", "scripts/schema.py"]
outputs = ["js/schema/v0/props.schema.json"]
depends-on = ["build-yarn"]

[feature.tasks-build.tasks.schema-json]
description = "- build JSON schema from TOML"
Expand Down Expand Up @@ -353,8 +357,8 @@ cmd = """export PIXI_PLATFORM=$(cat build/platform.txt)
--cov-context=test
--no-cov-on-fail
--cov-fail-under=97"""
depends-on = ["test-pip", "build-static", "platform--"]
inputs = ["{tests,src/urljsf}/**/*.{py,rst,json}", "src/urljsf/{_static,_templates}"]
depends-on = ["test-pip", "platform--"]
inputs = ["tests/**/*.{py,rst,json}", "dist/*.whl"]
outputs = ["build/reports/test_*"]

[feature.tasks-test.tasks.report]
Expand All @@ -369,8 +373,8 @@ cmd = """export PIXI_PLATFORM=$(cat build/platform.txt)
-n auto
--html=build/reports/test-min_pytest_$PIXI_PLATFORM.html
--self-contained-html"""
depends-on = ["test-min-pip", "build-static", "platform--"]
inputs = ["{tests,src/urljsf}/**/*.{py,rst,json}", "src/urljsf/{_static,_templates}"]
depends-on = ["test-min-pip", "platform--"]
inputs = ["tests/**/*.{py,rst,json}", "dist/*.whl"]
outputs = ["build/reports/test-min_*"]

# docs #########################################################################
Expand All @@ -388,15 +392,28 @@ description = "- build docs with sphinx"
cmd = """export PYDEVD_DISABLE_FILE_VALIDATION=1
&& sphinx-build -W --keep-going --color -b html docs build/docs"""
inputs = [
"*.md",
"*.toml",
"*.{md,toml}",
"src/**/*.py",
"dist/*.whl",
"docs/**/*.{css,ipynb,md,py}",
"docs/**/*.{css,rst,md,py}",
]
depends-on = ["docs-pip", "docs-scour"]
depends-on = ["docs-pip", "docs-scour", "dist-hash"]
outputs = ["build/docs"]

[feature.tasks-docs.tasks.docs-rtd]
description = "... copy the documentation site to where ReadTheDocs wants it"
cmd = """
python -c "
import os;
assert all(map(os.getenv, ['READTHEDOCS', 'READTHEDOCS_OUTPUT'])), 'not on ReadTheDocs'
"
&& mkdir -p "$READTHEDOCS_OUTPUT"
&& cp -r docs/build "$READTHEDOCS_OUTPUT/html"
&& ls "$READTHEDOCS_OUTPUT/html"
"""
depends-on = ["docs-sphinx"]

# atest ########################################################################
[feature.tasks-atest.tasks.atest-robot]
description = "- run acceptance test reports with robot"
cmd = "python scripts/atest.py"
Expand Down Expand Up @@ -436,13 +453,13 @@ cmd = """rm -rf build/reports/check-links
-k "not (404 or coverage or lite or mypy or Untitled)"
../../../build/docs/**/*.html"""
depends-on = ["docs-sphinx"]
inputs = ["docs/**/*.html"]
inputs = ["build/docs/**/*.html"]

[feature.tasks-check.tasks.check-vale]
description = "... check spelling in documentation"
cmd = "python scripts/vale/check.py"
depends-on = ["docs-sphinx"]
inputs = ["build/docs", "scripts/vale"]
inputs = ["build/docs/**/*.html", "scripts/vale", "{src,tests,scripts,atest}/**/*.py"]

[feature.tasks-check.tasks.check-wheel]
description = "... check the built wheel"
Expand Down Expand Up @@ -658,7 +675,7 @@ myst_heading_anchors = 3
html_theme = "pydata_sphinx_theme"
html_logo = "_static/logo.svg"
html_favicon = "_static/icon.svg"
html_static_path = ["_static", "../js/dist/"]
html_static_path = ["_static", "../js/dist/", "../dist"]

[tool.sphinx.html_theme_options]
github_url = "{{ ppt.project.urls.Source }}"
Expand Down
10 changes: 6 additions & 4 deletions scripts/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import annotations

import json
import shutil
import sys
from pathlib import Path
from subprocess import call as _call
Expand All @@ -20,6 +21,7 @@
# Distributed under the terms of the Modified BSD License.
'''
ROOT = Path(__file__).parent.parent
YARN = f"""{shutil.which("yarn") or shutil.which("yarn.cmd")}"""


def call(args: list[str | Path], **kwargs: Any) -> int:
Expand All @@ -36,15 +38,15 @@ def call(args: list[str | Path], **kwargs: Any) -> int:
def ts_to_json(in_path: Path, out_path: Path) -> int:
"""Get JSON schema from TypeScript."""
args = [
"yarn",
YARN,
"ts-json-schema-generator",
"--tsconfig=js/tsconfig.json",
f"--path={in_path}",
f"--out={out_path}",
]
if in_path.name == "_props.ts":
args += ["--type=Props"]
return call(args) or call(["yarn", "prettier", "--write", out_path])
return call(args) or call([YARN, "prettier", "--write", out_path])


def toml_to_json(in_path: Path, out_path: Path, *def_paths: Path) -> int:
Expand All @@ -60,7 +62,7 @@ def toml_to_json(in_path: Path, out_path: Path, *def_paths: Path) -> int:
def_schema["description"] = desc.strip()
text = json.dumps(raw, indent=2)
out_path.write_text(text, **UTF8)
return call(["yarn", "prettier", "--write", out_path])
return call([YARN, "prettier", "--write", out_path])


def json_to_ts(in_path: Path, out_path: Path) -> int:
Expand All @@ -77,7 +79,7 @@ def json_to_ts(in_path: Path, out_path: Path) -> int:
]

return call(args) or call([
"yarn",
YARN,
"prettier",
"--write",
str(out_path),
Expand Down
Loading

0 comments on commit b0624b8

Please sign in to comment.