Skip to content

Commit

Permalink
add pre-commit (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
rscohn2 authored Apr 26, 2024
1 parent b0113ee commit 7667b2e
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 47 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Checks
on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]
7 changes: 2 additions & 5 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Publish
on:
workflow_dispatch:
# trigger will use workflow in target (main) so it can have access to secrets
pull_request_target:
branches:
- main
Expand Down Expand Up @@ -28,14 +29,10 @@ jobs:
python scripts/site.py build
cp -r src/_build/html/* dist
- name: Publish to development on PR
if: ${{ github.event_name == 'pull_request' }}
if: ${{ github.event_name == 'pull_request_target' }}
run: |
netlify deploy --dir=dist --site=oneapi-spec
- name: Publish to production with manual trigger
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
netlify deploy --dir=dist --site=oneapi-spec --prod
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/dist/
/src/_build/
/src/_build/
53 changes: 53 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# SPDX-FileCopyrightText: Intel Corporation
#
# SPDX-License-Identifier: BSD-3-Clause

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.0
hooks:
- id: clang-format

- repo: https://github.com/ambv/black
rev: 24.2.0
hooks:
- id: black
args: ['--line-length=79']


- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: mixed-line-ending
- id: check-xml
- id: check-yaml
- id: check-case-conflict
- id: check-toml
- id: check-json
- id: check-added-large-files
args: ['--maxkb=800']

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8

- repo: https://github.com/pycqa/doc8
rev: v1.1.1
hooks:
- id: doc8

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
38 changes: 24 additions & 14 deletions scripts/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,75 @@
import zipfile

import click
import yaml
import requests
import yaml


def download_file(url):
with requests.get(url, stream=True) as r:
click.echo(f"Downloading {url}...", nl=False)
r.raise_for_status()
with tempfile.NamedTemporaryFile(delete=False) as f:
for chunk in r.iter_content(chunk_size=8192):
for chunk in r.iter_content(chunk_size=8192):
f.write(chunk)
local_filename = f.name
click.echo("done.")
click.echo("done.")
return local_filename


def extract_release(releases_dir, url):
file = download_file(url)
with zipfile.ZipFile(file, 'r') as zip_ref:
with zipfile.ZipFile(file, "r") as zip_ref:
zip_ref.extractall(releases_dir)
os.remove(file)


def extract_releases(update, site_dir, config):
releases_dir = os.path.join(site_dir, 'versions')
releases_dir = os.path.join(site_dir, "versions")
os.makedirs(releases_dir, exist_ok=update)
for release in config['releases']:
if update and os.path.exists(os.path.join(releases_dir, release['name'])):
for release in config["releases"]:
if update and os.path.exists(
os.path.join(releases_dir, release["name"])
):
continue
f = extract_release(releases_dir, release['url'])
extract_release(releases_dir, release["url"])

latest = os.path.join(releases_dir, 'latest')
latest = os.path.join(releases_dir, "latest")
if update and os.path.exists(latest):
os.remove(latest)
try:
os.symlink(config['latest'], latest)
os.symlink(config["latest"], latest)
except Exception as e:
raise click.ClickException(f"Could not create latest link: {e}")


@click.group()
def cli():
pass


@cli.command()
@click.option("--update", is_flag=True, help="Update the site.")
@click.option('--dir', type=click.Path(), default="dist")
@click.option("--dir", type=click.Path(), default="dist")
def build(update, dir):
"""Build the site."""

# get configuration from site.yaml
try:
with open('site.yaml') as f:
with open("site.yaml") as f:
config = yaml.load(f, Loader=yaml.FullLoader)
except Exception as e:
raise click.ClickException(f"Could not load site configuration: {e}")

try:
os.makedirs(dir, exist_ok=update)
except Exception as e:
raise click.ClickException(f"Site directory {dir} could not be created: {e}")
raise click.ClickException(
f"Site directory {dir} could not be created: {e}"
)

extract_releases(update, dir, config)

if __name__ == '__main__':

if __name__ == "__main__":
cli()
2 changes: 1 addition & 1 deletion site.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
latest: 1.0-rev-1
releases:
- name: 1.0-rev-1
url: https://github.com/uxlfoundation/oneAPI-spec/releases/download/v1.0-rev-1/oneapi-spec-v1.0-rev-1.zip
url: https://github.com/uxlfoundation/oneAPI-spec/releases/download/v1.0-rev-1/oneapi-spec-v1.0-rev-1.zip
24 changes: 11 additions & 13 deletions src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,38 @@

# -- Project information -----------------------------------------------------

project = 'oneAPI Specification Versions'
copyright = 'Contributors to the oneapi specification project'
project = "oneAPI Specification Versions"
copyright = "Contributors to the oneapi specification project"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['notfound.extension']
extensions = ["notfound.extension"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_book_theme'
html_theme = "sphinx_book_theme"

html_theme_options = {
'repository_url': 'https://github.com/uxlfoundation/oneapi-spec-site',
'path_to_docs': 'src',
'use_issues_button': True,
'use_edit_page_button': True,
'repository_branch': 'main',
"repository_url": "https://github.com/uxlfoundation/oneapi-spec-site",
"path_to_docs": "src",
"use_issues_button": True,
"use_edit_page_button": True,
"repository_branch": "main",
}

html_sidebars = {
"**": []
}
html_sidebars = {"**": []}

notfound_urls_prefix = ""
26 changes: 13 additions & 13 deletions src/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ Changes since 1.2

* For oneCCL, we added new APIs for point to point send/recv
operations.

* Level Zero

See `Level Zero`_

* oneTBB

* Allowed using pointers to class functions and members in place of
Expand All @@ -131,7 +131,7 @@ Changes since 1.1
* SYCL

The following extensions were added:

* `sycl_ext_oneapi_assert` - Support for device-side assert.
* `sycl_ext_oneapi_default_context` - Adds the concept of a platform
default context.
Expand All @@ -140,15 +140,15 @@ Changes since 1.1
* `sycl_ext_oneapi_srgb` - Exposes sRGB support for images.
* `sycl_ext_oneapi_usm_device_read_only` - Adds a property for USM
allocations.

* oneDPL

The following updates were added in oneDPL specification for version 1.2:

* The content was reorganized.
* API for random number generation was added.
* Incremental improvements and bug fixes.

* oneDNN

This is a new major release of oneDNN spec, which breaks
Expand All @@ -174,23 +174,23 @@ Changes since 1.1
* Level Zero

See `Level Zero`_

* oneTBB

The following updates were added in oneTBB specification for version
1.2:

* Support for core types and thread-per-core limit was added to
task_arena constraints.
* API of concurrent_queue and concurrent_bounded_queue was extended
to better match C++ standard containers.
* Incremental improvements and bug fixes.

* oneVPL

This release updates oneVPL specification to version 2.9.0. New
features include:

* Deprecated mfxExtCodingOption2::BitrateLimit.
* Added note that applications must call MFXVideoENCODE_Query() to
check for support of mfxExtChromaLocInfo and mfxExtHEVCRegion
Expand Down Expand Up @@ -221,7 +221,7 @@ Changes since 1.1

The following updates were added in oneMKL specification for version
1.2:

* Dense matrix copy and transpose routines were added in the
BLAS-like extensions
* half/bfloat16 precision support were added to several L1 BLAS
Expand Down Expand Up @@ -280,14 +280,14 @@ Changes since 1.0
(optional) std::vector of input events instead of
sycl::vector_class. Other changes include minor clarifications and
bug fixes.

* oneTBB:

Introduces a way for collaborative one-time function processing
(collaborative_call_once), mutex classes with adaptive waiting
behavior (mutex, rw_mutex), the ability to wait for thread completion
(task_scheduler_handle and the finalize function). Extended task_group
and task_arena classes to support deferred task submission via
and task_arena classes to support deferred task submission via
the new task_handle class. Extended concurrent_hash_map with methods
that support lookup for distinct key types.

Expand Down

0 comments on commit 7667b2e

Please sign in to comment.