Skip to content

Commit

Permalink
Skeleton updates (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman authored Dec 12, 2024
1 parent e63b07d commit 53af5b4
Show file tree
Hide file tree
Showing 13 changed files with 184 additions and 103 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Documentation"

on:
push:
branches:
- main
tags: '*'
pull_request:
schedule:
- cron: '1 4 * * 4'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref_name != github.event.repository.default_branch || github.ref != 'refs/tags/v*' }}

jobs:
build-and-deploy-docs:
name: "Documentation"
uses: "ITensor/ITensorActions/.github/workflows/Documentation.yml@main"
with:
localregistry: https://github.com/ITensor/ITensorRegistry.git
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
36 changes: 7 additions & 29 deletions .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,13 @@
name: Format check
name: "Format Check"

on:
push:
branches: [main]
tags: [v*]
branches:
- 'main'
tags: '*'
pull_request:

jobs:
format:
format-check:
name: "Format Check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: 1
- name: Install JuliaFormatter and format
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
julia -e 'using JuliaFormatter; format(".", verbose=true)'
- name: Check format
run: |
julia -e '
out = Cmd(`git diff --name-only`) |> read |> String
if out == ""
exit(0)
else
@error "The following files have not been formatted:"
write(stdout, out)
out_diff = Cmd(`git diff`) |> read |> String
@error "Diff:"
write(stdout, out_diff)
exit(1)
@error ""
end'
uses: "ITensor/ITensorActions/.github/workflows/FormatCheck.yml@main"
44 changes: 8 additions & 36 deletions .github/workflows/LiterateCheck.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,15 @@
name: Literate check
name: "Literate Check"

on:
push:
branches: [main]
tags: [v*]
branches:
- 'main'
tags: '*'
pull_request:

jobs:
literate:
name: "Literate Check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: 1
- name: Install Literate and generate docs
run: |
julia -e '
using Pkg
# TODO: Delete once they are registered.
Pkg.add(url="https://github.com/ITensor/BroadcastMapConversion.jl")
Pkg.add(url="https://github.com/ITensor/NestedPermutedDimsArrays.jl")
Pkg.add(url="https://github.com/ITensor/TypeParameterAccessors.jl")
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()
Pkg.add(PackageSpec(name="Literate"))'
julia -e 'include("docs/make_readme.jl")'
- name: Check if docs need to be updated
run: |
julia -e '
out = Cmd(`git diff --name-only`) |> read |> String
if out == ""
exit(0)
else
@error "The docs are outdated, rerun Literate to regenerate them."
write(stdout, out)
out_diff = Cmd(`git diff`) |> read |> String
@error "Diff:"
write(stdout, out_diff)
exit(1)
@error ""
end'
uses: "ITensor/ITensorActions/.github/workflows/LiterateCheck.yml@main"
with:
localregistry: https://github.com/ITensor/ITensorRegistry.git
42 changes: 42 additions & 0 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tests
on:
push:
branches:
- 'master'
- 'main'
- 'release-'
tags: '*'
paths-ignore:
- 'docs/**'
pull_request:
workflow_dispatch:

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

jobs:
tests:
name: "Tests"
strategy:
fail-fast: false
matrix:
version:
- 'lts' # minimal supported version
- '1' # latest released Julia version
# group:
# - 'core'
# - 'optional'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
uses: "ITensor/ITensorActions/.github/workflows/Tests.yml@main"
with:
group: "${{ matrix.group }}"
julia-version: "${{ matrix.version }}"
os: "${{ matrix.os }}"
localregistry: https://github.com/ITensor/ITensorRegistry.git
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
exclude_types: [markdown] # incompatible with Literate.jl
- repo: https://github.com/qiaojunfeng/pre-commit-julia-format
rev: v0.2.0

- repo: "https://github.com/domluna/JuliaFormatter.jl"
rev: v1.0.62
hooks:
- id: julia-format
- id: "julia-formatter"
5 changes: 0 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"
VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8"

[sources]
BroadcastMapConversion = {url = "https://github.com/ITensor/BroadcastMapConversion.jl"}
NestedPermutedDimsArrays = {url = "https://github.com/ITensor/NestedPermutedDimsArrays.jl"}
TypeParameterAccessors = {url = "https://github.com/ITensor/TypeParameterAccessors.jl"}

[compat]
Accessors = "0.1.38"
Adapt = "4.1.1"
Expand Down
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,31 @@

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/SparseArraysBase.jl/stable/)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/SparseArraysBase.jl/dev/)
[![Build Status](https://github.com/ITensor/SparseArraysBase.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/SparseArraysBase.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Build Status](https://github.com/ITensor/SparseArraysBase.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/SparseArraysBase.jl/actions/workflows/Tests.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/ITensor/SparseArraysBase.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/SparseArraysBase.jl)
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)

## Installation instructions

This package resides in the `ITensor/ITensorRegistry` local registry.
In order to install, simply add that registry through your package manager.
This step is only required once.
```julia
julia> using Pkg: Pkg

julia> Pkg.add(url="https://github.com/ITensor/BroadcastMapConversion.jl")

julia> Pkg.add(url="https://github.com/ITensor/NestedPermutedDimsArrays.jl")
julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")
```
or:
```julia
julia> Pkg.Registry.add(url="[email protected]:ITensor/ITensorRegistry.git")
```
if you want to use SSH credentials, which can make it so you don't have to enter your Github ursername and password when registering packages.

julia> Pkg.add(url="https://github.com/ITensor/TypeParameterAccessors.jl")
Then, the package can be added as usual through the package manager:

julia> Pkg.add(url="https://github.com/ITensor/SparseArraysBase.jl")
```julia
julia> Pkg.add("SparseArraysBase")
```

## Examples
Expand Down
5 changes: 0 additions & 5 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@ Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
NestedPermutedDimsArrays = "2c2a8ec4-3cfc-4276-aa3e-1307b4294e58"
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"

[sources]
BroadcastMapConversion = {url = "https://github.com/ITensor/BroadcastMapConversion.jl"}
NestedPermutedDimsArrays = {url = "https://github.com/ITensor/NestedPermutedDimsArrays.jl"}
TypeParameterAccessors = {url = "https://github.com/ITensor/TypeParameterAccessors.jl"}
5 changes: 0 additions & 5 deletions examples/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,3 @@ BroadcastMapConversion = "4a4adec5-520f-4750-bb37-d5e66b4ddeb2"
NestedPermutedDimsArrays = "2c2a8ec4-3cfc-4276-aa3e-1307b4294e58"
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"

[sources]
BroadcastMapConversion = {url = "https://github.com/ITensor/BroadcastMapConversion.jl"}
NestedPermutedDimsArrays = {url = "https://github.com/ITensor/NestedPermutedDimsArrays.jl"}
TypeParameterAccessors = {url = "https://github.com/ITensor/TypeParameterAccessors.jl"}
24 changes: 18 additions & 6 deletions examples/README.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,36 @@
#
# [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/SparseArraysBase.jl/stable/)
# [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/SparseArraysBase.jl/dev/)
# [![Build Status](https://github.com/ITensor/SparseArraysBase.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/SparseArraysBase.jl/actions/workflows/CI.yml?query=branch%3Amain)
# [![Build Status](https://github.com/ITensor/SparseArraysBase.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/SparseArraysBase.jl/actions/workflows/Tests.yml?query=branch%3Amain)
# [![Coverage](https://codecov.io/gh/ITensor/SparseArraysBase.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/SparseArraysBase.jl)
# [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
# [![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)

# ## Installation instructions

# This package resides in the `ITensor/ITensorRegistry` local registry.
# In order to install, simply add that registry through your package manager.
# This step is only required once.
#=
```julia
julia> using Pkg: Pkg
julia> Pkg.add(url="https://github.com/ITensor/BroadcastMapConversion.jl")
julia> Pkg.add(url="https://github.com/ITensor/NestedPermutedDimsArrays.jl")
julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")
```
=#
# or:
#=
```julia
julia> Pkg.Registry.add(url="[email protected]:ITensor/ITensorRegistry.git")
```
=#
# if you want to use SSH credentials, which can make it so you don't have to enter your Github ursername and password when registering packages.

julia> Pkg.add(url="https://github.com/ITensor/TypeParameterAccessors.jl")
# Then, the package can be added as usual through the package manager:

julia> Pkg.add(url="https://github.com/ITensor/SparseArraysBase.jl")
#=
```julia
julia> Pkg.add("SparseArraysBase")
```
=#

Expand Down
3 changes: 3 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NestedPermutedDimsArrays = "2c2a8ec4-3cfc-4276-aa3e-1307b4294e58"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
65 changes: 57 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,61 @@
@eval module $(gensym())
using Test: @testset
using SafeTestsets: @safetestset
using Suppressor: Suppressor

@testset "SparseArraysBase.jl" begin
filenames = filter(readdir(@__DIR__)) do f
startswith("test_")(f) && endswith(".jl")(f)
# check for filtered groups
# either via `--group=ALL` or through ENV["GROUP"]
const pat = r"(?:--group=)(\w+)"
arg_id = findfirst(contains(pat), ARGS)
const GROUP = uppercase(
if isnothing(arg_id)
get(ENV, "GROUP", "ALL")
else
only(match(pat, ARGS[arg_id]).captures)
end,
)

"match files of the form `test_*.jl`, but exclude `*setup*.jl`"
istestfile(fn) =
endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup")
"match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`"
isexamplefile(fn) =
endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup")

@time begin
# tests in groups based on folder structure
for testgroup in filter(isdir, readdir(@__DIR__))
if GROUP == "ALL" || GROUP == uppercase(testgroup)
for file in filter(istestfile, readdir(joinpath(@__DIR__, testgroup); join=true))
@eval @safetestset $file begin
include($file)
end
end
end
end

# single files in top folder
for file in filter(istestfile, readdir(@__DIR__))
(file == basename(@__FILE__)) && continue # exclude this file to avoid infinite recursion
@eval @safetestset $file begin
include($file)
end
end
@testset "Test $filename" for filename in filenames
include(filename)

# test examples
examplepath = joinpath(@__DIR__, "..", "examples")
for (root, _, files) in walkdir(examplepath)
contains(chopprefix(root, @__DIR__), "setup") && continue
for file in filter(isexamplefile, files)
filename = joinpath(root, file)
@eval begin
@safetestset $file begin
$(Expr(
:macrocall,
GlobalRef(Suppressor, Symbol("@suppress")),
LineNumberNode(@__LINE__, @__FILE__),
:(include($filename)),
))
end
end
end
end
end
end
8 changes: 8 additions & 0 deletions test/test_aqua.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using SparseArraysBase: SparseArraysBase
using Aqua: Aqua
using Test: @testset

@testset "Code quality (Aqua.jl)" begin
# TODO: Fix Aqua issues and add this back.
# Aqua.test_all(SparseArraysBase)
end

0 comments on commit 53af5b4

Please sign in to comment.