Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust/maturin CI #375

Merged
merged 39 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
252b13a
build: Update flake with rust and maturin
alecandido May 17, 2024
7f12ec3
build: Move the workspace top-level
alecandido May 17, 2024
3d7e6bc
build: Migrate metadata to workspace from individual crates
alecandido May 17, 2024
1c7912f
ci: Provide maturin-deploying workflow
alecandido May 17, 2024
b98d289
build: Reintroduce explicit internal version dependency
alecandido May 17, 2024
d3e0062
build: Add script to bump versions
alecandido May 17, 2024
84ebeb8
build: Bump workspace version as well
alecandido May 17, 2024
e1da0a5
build: Restore pre-commit package installation in flake
alecandido May 17, 2024
2d137ad
ci: Add crates publishing workflow, add branches push events for both
alecandido May 20, 2024
b546bb8
ci: Providing missing path to maturin sdist job
alecandido May 20, 2024
06dfc79
ci: Checkout repo in crate releasing worklow
alecandido May 20, 2024
edcc497
ci: Fix writing on file just read
alecandido May 20, 2024
2a2319b
ci: Define an alpha version to test crates release
alecandido May 20, 2024
4e61d42
ci: Expose cargo token from secrets
alecandido May 21, 2024
48b946d
ci: Allow dirty publish to support version bumping in the CI
alecandido May 21, 2024
8e44182
ci: Define release order for crates
alecandido May 21, 2024
a57ca34
rust: Fix KaTeX location
felixhekhorn May 21, 2024
a7ad7d0
ci: Bump prerelease version once more
alecandido May 21, 2024
b7df850
docs: Symlink katex header in individual crates
alecandido May 21, 2024
06c4cf1
docs: Fix extensions
alecandido May 21, 2024
b83d1bd
build: Convert Nu script to python
alecandido May 21, 2024
4b29cee
build: Add poe script to bump versions
alecandido May 21, 2024
dde27b4
ci: Rearrange crates deployment with python script
alecandido May 21, 2024
5138556
ci: Use virtual environment
alecandido May 21, 2024
bc7457a
ci: Remove bumping script in Nu
alecandido May 21, 2024
5dc8835
ci: Fix crates definition path
alecandido May 21, 2024
0cb7087
rust: Fix pyproject patch
felixhekhorn May 21, 2024
828d47b
Merge branch 'master' into oxidize-ci
felixhekhorn May 22, 2024
5ea1440
rust: Add fmt and clippy
felixhekhorn May 22, 2024
0518475
rust: Fix clippy warnings
felixhekhorn May 22, 2024
69d5104
rust: Add fmt and clippy to CI
felixhekhorn May 22, 2024
fe8a8db
rust: Attempt dynamic version resolution
felixhekhorn May 22, 2024
1742488
rust: Fix poe bump-version
felixhekhorn May 22, 2024
0be1e89
rust: Add comment to bumb-versions
felixhekhorn May 22, 2024
94c8270
Update crates/Readme
felixhekhorn May 22, 2024
909ad77
Temporarily disable PyPI
felixhekhorn May 22, 2024
49233a5
Reactivate PyPI
felixhekhorn May 22, 2024
b0ed871
Merge branch 'master' into oxidize-ci
felixhekhorn May 30, 2024
af02fad
Fix clippy warnings
felixhekhorn May 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/crates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Deploy Crates

on:
push:
tags:
- "*"
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install and configure Poetry
uses: snok/install-poetry@v1
- name: Install task runner
run: pip install poethepoet
- name: Bump versions
run: |
poetry install --only version
poe bump-version
- name: Publish crates
run: |
jq '.[]' crates/release.json | xargs -I _ cargo publish -p _ --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
123 changes: 123 additions & 0 deletions .github/workflows/maturin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Deploy Maturin wheels

on:
push:
tags:
- "*"
workflow_dispatch:

permissions:
contents: read

jobs:
linux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: x86
- runner: ubuntu-latest
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter -m crates/eko/Cargo.toml
sccache: "true"
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.platform.target }}
path: dist

windows:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: windows-latest
target: x64
- runner: windows-latest
target: x86
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
architecture: ${{ matrix.platform.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter -m crates/eko/Cargo.toml
sccache: "true"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-${{ matrix.platform.target }}
path: dist

macos:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: macos-latest
target: x86_64
- runner: macos-14
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter -m crates/eko/Cargo.toml
sccache: "true"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.platform.target }}
path: dist

sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist -m crates/eko/Cargo.toml
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist

release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
steps:
- uses: actions/download-artifact@v4
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
felixhekhorn marked this conversation as resolved.
Show resolved Hide resolved
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*
8 changes: 7 additions & 1 deletion .github/workflows/unittests-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ name: Rust unit tests
on: push

jobs:
test-rust:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install task runner
run: pip install poethepoet
- name: Run fmt
run: |
poe fmtcheck
- name: Run clippy
run: |
poe clippy
- name: Run Rust unit tests
run: |
poe rtest
21 changes: 6 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
ci:
autofix_prs: false
skip: [fmt-eko, fmt-ekore]
skip: [fmt] # will be run by a separate CI
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
Expand Down Expand Up @@ -45,21 +45,12 @@ repos:
- toml
- repo: local
hooks:
- id: fmt-eko
name: fmt-eko
description: Format eko files with cargo fmt.
entry: cargo fmt --manifest-path crates/eko/Cargo.toml --
- id: fmt
name: fmt
description: Format Rust files with cargo fmt.
entry: cargo fmt --
language: system
files: ^crates/eko/.*\.rs$
args: []
- repo: local
hooks:
- id: fmt-ekore
name: fmt-ekore
description: Format ekore files with cargo fmt.
entry: cargo fmt --manifest-path crates/ekore/Cargo.toml --
language: system
files: ^crates/ekore/.*\.rs$
files: ^crates/.*\.rs$
args: []
- repo: https://github.com/pre-commit/pre-commit
rev: v3.7.1
Expand Down
4 changes: 2 additions & 2 deletions crates/Cargo.lock → Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[workspace]
members = ["crates/*"]
resolver = "2"

[workspace.package]
authors = [
"A. Barontini <[email protected]>",
"A. Candido <[email protected]>",
"F. Hekhorn <[email protected]>",
"N. Laurenti <[email protected]>",
"G. Magni <[email protected]>",
"T. Sharma <[email protected]>",
]
description = "Evolution Kernel Operators"
readme = "README.md"
categories = ["science"]
edition = "2021"
keywords = ["physics"]
license = "GPL-3.0-or-later"
repository = "https://github.com/NNPDF/eko"
rust-version = "1.60.0"
version = "0.0.1"
3 changes: 0 additions & 3 deletions crates/Cargo.toml

This file was deleted.

18 changes: 18 additions & 0 deletions crates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Welcome to the rusty side of EKO!

Here, we develop the Rust components of the EKO library

## Crates

- `ekore` contains the underlying collinear anomalous dimensions and the operator matrix elements
- `eko` is the glue between the Python side and the `ekore` crate

## Files

- `release.json` defines the releasing order of crates
- only listed crates will be released
- dependent crates should follow those they are depending on
- `katex-header.html` is an HTML snippet to be included in every docs page to inject
KaTeX support
- `bump-versions.py` increases the Rust versions in all crates consistently
- `make_bib.py` generates the Rust function stubs which serve as fake bibliography system
40 changes: 40 additions & 0 deletions crates/bump-versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import json
import sys
from pathlib import Path

import tomlkit

HERE = Path(__file__).parent
CRATES = json.loads((HERE / "release.json").read_text())


def workspace(manifest, version):
manifest["workspace"]["package"]["version"] = version
return manifest


def crate(manifest, version):
internals = set(manifest["dependencies"].keys()).intersection(CRATES)
for dep in internals:
manifest["dependencies"][dep]["version"] = version
return manifest


def update(path, version, edit):
path = HERE / Path(path) / "Cargo.toml"
manifest = tomlkit.parse(path.read_text())
manifest = edit(manifest, version)
path.write_text(tomlkit.dumps(manifest))


def main(version):
update("..", version, workspace)
for name in CRATES:
update(name, version, crate)


if __name__ == "__main__":
if len(sys.argv) < 2:
raise ValueError(f"Pass a version (e.g. v0.0.0) to {sys.argv[0]}")
# `git describe` starts with a `v` which we need to remove again
main(sys.argv[1][1:])
felixhekhorn marked this conversation as resolved.
Show resolved Hide resolved
17 changes: 13 additions & 4 deletions crates/eko/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
[package]
name = "eko"
version = "0.1.0"
edition = "2021"

authors.workspace = true
description.workspace = true
readme.workspace = true
categories.workspace = true
edition.workspace = true
keywords.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true

[package.metadata.docs.rs]
rustdoc-args = [ "--html-in-header", "../katex-header.html" ]
rustdoc-args = ["--html-in-header", "katex-header.html"]

[lib]
name = "ekors"
crate-type = ["cdylib"]

[dependencies]
num = "0.4.1"
ekore = { version = "0.1.0", path = "../ekore" }
ekore = { path = "../ekore", version = "0.0.1" }
1 change: 1 addition & 0 deletions crates/eko/katex-header.html
2 changes: 1 addition & 1 deletion crates/eko/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["maturin>=1.1,<2.0"]
build-backend = "maturin"

[project]
name = "ekors"
name = "eko-rs"
requires-python = ">=3.9"
classifiers = [
"Programming Language :: Rust",
Expand Down
Loading
Loading