Skip to content

Commit

Permalink
add Docs, TagBot, CompatHelper (#10)
Browse files Browse the repository at this point in the history
* add Docs, TagBot, CompatHelper
* link to JuliaHEP in docs
* cleaned make.jl
* right ref and indenting
* repolink
* julia formatter
  • Loading branch information
mmikhasenko authored Oct 2, 2024
1 parent f3c7b7b commit b52c630
Show file tree
Hide file tree
Showing 15 changed files with 263 additions and 72 deletions.
3 changes: 3 additions & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# See https://domluna.github.io/JuliaFormatter.jl/stable/ for a list of options
style = "blue"
indent = 4
margin = 92
normalize_line_endings = "unix"
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://editorconfig.org
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_size = 4
indent_style = space
trim_trailing_whitespace = true
26 changes: 26 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!--
Thanks for making a pull request to LorentzVectorBase.jl.
We have added this PR template to help you help us.
See the comments below, fill the required fields, and check the items.
-->

## Related issues

<!-- We normally work with (i) create issue; (ii) discussion if necessary; (iii) create PR. So, at least one of the following should be true:-->

<!-- Option 1, this closes an existing issue. Fill the number below-->
Closes #

<!-- Option 2, this is a small fix that arguably won't need an issue. Uncomment below -->
<!--
There is no related issue.
-->

## Checklist

<!-- mark true if NA -->
<!-- leave PR as draft until all is checked -->

- [ ] Tests are passing
- [ ] Docs were updated and workflow is passing
51 changes: 51 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# CompatHelper v3.5.0
name: CompatHelper

on:
schedule:
- cron: 0 0 * * * # Every day at 00:00 UTC
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Check if Julia is already available in the PATH
id: julia_in_path
run: which julia
continue-on-error: true
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@v2
with:
version: "1"
arch: ${{ runner.arch }}
if: steps.julia_in_path.outcome != 'success'
- name: Use Julia cache
uses: julia-actions/cache@v2
- name: "Add the General registry via Git"
run: |
import Pkg
ENV["JULIA_PKG_SERVER"] = ""
Pkg.Registry.add("General")
shell: julia --color=yes {0}
- name: "Install CompatHelper"
run: |
import Pkg
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
version = "3"
Pkg.add(; name, uuid, version)
shell: julia --color=yes {0}
- name: "Run CompatHelper"
run: |
import CompatHelper
CompatHelper.main()
shell: julia --color=yes {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
# COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}
54 changes: 54 additions & 0 deletions .github/workflows/Docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Docs

on:
push:
branches:
- main
paths:
- "docs/**"
- "src/**"
- "*.toml"
tags: ["*"]
pull_request:
branches:
- main
paths:
- "docs/**"
- "src/**"
- "*.toml"
types: [opened, synchronize, reopened]

concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: "1"
- name: Use Julia cache
uses: julia-actions/cache@v2
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- run: |
julia --project=docs -e '
using Documenter: DocMeta, doctest
using LorentzVectorBase
DocMeta.setdocmeta!(LorentzVectorBase, :DocTestSetup, :(using LorentzVectorBase); recursive=true)
doctest(LorentzVectorBase)'
- run: julia --project=docs docs/make.jl
env:
JULIA_PKG_SERVER: ""
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
GKSwstype: "100" # https://discourse.julialang.org/t/generation-of-documentation-fails-qt-qpa-xcb-could-not-connect-to-display/60988
37 changes: 37 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: TagBot

on:
issue_comment:
types:
- created
workflow_dispatch:
inputs:
lookback:
type: number
default: 3

permissions:
actions: read
checks: read
contents: write
deployments: read
issues: read
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read

jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Edit the following line to reflect the actual name of the GitHub Secret containing your private key
ssh: ${{ secrets.DOCUMENTER_KEY }}
# ssh: ${{ secrets.NAME_OF_MY_SSH_PRIVATE_KEY_SECRET }}
8 changes: 0 additions & 8 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,3 @@ version = "0.0.1-DEV"
[compat]
julia = "1.6"

[extras]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Random","SafeTestsets"]

12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# LorentzVectorBase.jl
[WIP] Base interfaces for four-momenta in high-energy physics.
# LorentzVectorBase

<!-- [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://szabo137.github.io/LorentzVectorBase.jl/stable/)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://szabo137.github.io/LorentzVectorBase.jl/dev/) -->
Base interfaces for four-momenta in high-energy physics.

[![Build Status](https://github.com/JuliaHEP/LorentzVectorBase.jl/actions/workflows/Test.yml/badge.svg?branch=main)](https://github.com/JuliaHEP/LorentzVectorBase.jl/actions/workflows/Test.yml?query=branch%3Amain)
[![Stable Documentation](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaHEP.github.io/LorentzVectorBase.jl/stable/)
[![In development documentation](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaHEP.github.io/LorentzVectorBase.jl/dev/)
[![Test workflow status](https://github.com/JuliaHEP/LorentzVectorBase.jl/actions/workflows/Test.yml/badge.svg?branch=main)](https://github.com/JuliaHEP/LorentzVectorBase.jl/actions/workflows/Test.yml?query=branch%3Amain)
[![Docs workflow Status](https://github.com/JuliaHEP/LorentzVectorBase.jl/actions/workflows/Docs.yml/badge.svg?branch=main)](https://github.com/JuliaHEP/LorentzVectorBase.jl/actions/workflows/Docs.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/JuliaHEP/LorentzVectorBase.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaHEP/LorentzVectorBase.jl)
15 changes: 11 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@ DocMeta.setdocmeta!(
LorentzVectorBase, :DocTestSetup, :(using LorentzVectorBase); recursive=true
)

const numbered_pages = [
file for file in readdir(joinpath(@__DIR__, "src")) if
file != "index.md" && splitext(file)[2] == ".md"
]

makedocs(;
modules=[LorentzVectorBase],
authors="Uwe Hernandez Acosta <u.hernandez@hzdr.de",
authors="Uwe Hernandez Acosta <u.hernandez@hzdr.de>",
repo="https://github.com/JuliaHEP/LorentzVectorBase.jl/blob/{commit}{path}#{line}",
sitename="LorentzVectorBase.jl",
format=Documenter.HTML(;
canonical="https://szabo137.github.io/LorentzVectorBase.jl",
canonical="https://JuliaHEP.github.io/LorentzVectorBase.jl",
repolink="https://github.com/JuliaHEP/LorentzVectorBase.jl",
edit_link="main",
assets=String[],
),
pages=["Home" => "index.md"],
pages=["index.md"; numbered_pages],
)

deploydocs(; repo="github.com/szabo137/LorentzVectorBase.jl", devbranch="main")
deploydocs(; repo="github.com/JuliaHEP/LorentzVectorBase.jl")
17 changes: 17 additions & 0 deletions docs/src/95-reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# [Reference](@id reference)

## Contents

```@contents
Pages = ["95-reference.md"]
```

## Index

```@index
Pages = ["95-reference.md"]
```

```@autodocs
Modules = [LorentzVectorBase]
```
7 changes: 1 addition & 6 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ CurrentModule = LorentzVectorBase

# LorentzVectorBase

Documentation for [LorentzVectorBase](https://github.com/szabo137/LorentzVectorBase.jl).
Documentation for [LorentzVectorBase](https://github.com/JuliaHEP/LorentzVectorBase.jl).

```@index
```

```@autodocs
Modules = [LorentzVectorBase]
```
9 changes: 4 additions & 5 deletions src/coordinate_systems/PtEtaPhiM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ mass(::CustomFourMomentum)
struct PtEtaPhiM <: AbstractCoordinateSystem end
coordinate_names(::PtEtaPhiM) = (:pt, :eta, :phi, :energy)


####
# derived components
####
Expand All @@ -25,19 +24,19 @@ py(::PtEtaPhiM, v) = pt(v) * sin(phi(v))
pz(::PtEtaPhiM, v) = pt(v) * sinh(eta(v))

function energy(::PtEtaPhiM, mom)
sqrt(px(mom)^2 + py(mom)^2 + pz(mom)^2 + invariant_mass2(mom))
return sqrt(px(mom)^2 + py(mom)^2 + pz(mom)^2 + invariant_mass2(mom))
end

@inline function spatial_magnitude2(::PtEtaPhiM, mom)
return pt(mom)^2 * (1+sinh(eta(mom))^2)
return pt(mom)^2 * (1 + sinh(eta(mom))^2)
end

@inline function spatial_magnitude(::PtEtaPhiM, mom)
return sqrt(spatial_magnitude2(mom))
end

@inline function mass2(::PtEtaPhiM, mom)
mass(mom)^2
return mass(mom)^2
end

@inline function boost_beta(::PtEtaPhiM, mom)
Expand Down Expand Up @@ -85,7 +84,7 @@ end
@inline function rapidity(::PtEtaPhiM, mom)
E = energy(mom)
pz1 = pz(mom)
return 0.5*log((E+pz1)/(E-pz1))
return 0.5 * log((E + pz1) / (E - pz1))
end

#######################
Expand Down
Loading

0 comments on commit b52c630

Please sign in to comment.