-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Herb-AI/template-setup
Add CI, testing, hooks, etc.
- Loading branch information
Showing
15 changed files
with
309 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# See https://domluna.github.io/JuliaFormatter.jl/stable/ for a list of options | ||
style = "sciml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[deps] | ||
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
""" | ||
Formatting script inspired by that of the `Flux.jl` package, which | ||
can be found at: | ||
https://github.com/FluxML/Flux.jl/blob/caa1ceef9cf59bd817b7bf5c94d0ffbec5a0f32c/dev/flux_format.jl | ||
""" | ||
|
||
using Pkg | ||
Pkg.activate(@__DIR__) | ||
Pkg.instantiate() | ||
|
||
using JuliaFormatter | ||
|
||
help = """ | ||
Usage: herb_format [flags] [FILE/PATH]... | ||
Formats the given julia files using the Herb formatting options. | ||
If paths are given instead, it will format all *.jl files under | ||
the paths. If nothing is given, all changed julia files are formatted. | ||
-v, --verbose | ||
Print the name of the files being formatted with relevant details. | ||
-h, --help | ||
Print this help message. | ||
--check | ||
Check if the files are formatted without changing them. | ||
""" | ||
|
||
options = Dict{Symbol, Bool}() | ||
indices_to_remove = [] # used to delete options once processed | ||
|
||
for (index, arg) in enumerate(ARGS) | ||
if arg[1] != '-' | ||
continue | ||
end | ||
val = true | ||
if arg in ["-v", "--verbose"] | ||
opt = :verbose | ||
push!(indices_to_remove, index) | ||
elseif arg in ["-h", "--help"] | ||
opt = :help | ||
push!(indices_to_remove, index) | ||
elseif arg == "--check" | ||
opt = :overwrite | ||
val = false | ||
write(stdout, "Checking files.\n") | ||
push!(indices_to_remove, index) | ||
else | ||
error("Option $arg is not supported.") | ||
end | ||
options[opt] = val | ||
end | ||
|
||
# remove options from args | ||
deleteat!(ARGS, indices_to_remove) | ||
|
||
# print help message if asked | ||
if haskey(options, :help) | ||
write(stdout, help) | ||
exit(0) | ||
end | ||
|
||
# otherwise format files | ||
if isempty(ARGS) | ||
filenames = readlines(`git ls-files "*.jl"`) | ||
else | ||
filenames = ARGS | ||
end | ||
|
||
write(stdout, "Formatting in progress.\n") | ||
# format returns true if the files were already formatted | ||
# and false if they were not (had to be formatted) | ||
exit(format(filenames; options...) ? 0 : 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" | ||
Dev environment setup script inspired by that of the `Flux.jl` package, which | ||
can be found at: | ||
https://github.com/FluxML/Flux.jl/blob/caa1ceef9cf59bd817b7bf5c94d0ffbec5a0f32c/dev/setup.jl | ||
""" | ||
|
||
# instantiate the environment | ||
using Pkg | ||
Pkg.activate(@__DIR__) | ||
Pkg.instantiate() | ||
|
||
# setup the custom git hook | ||
using Git | ||
|
||
# set the local hooks path | ||
const git = Git.git() | ||
run(`$git config --local core.hooksPath .githooks/`) | ||
|
||
# set file permission for hook | ||
Base.Filesystem.chmod(".githooks", 0o777; recursive = true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Get the list of files that are about to be committed and filter out only the .jl files | ||
files=$(git diff --cached --name-only --diff-filter=ACM | grep "\.jl$") | ||
|
||
# If no files are found, exit | ||
if [ -z "$files" ]; then | ||
exit 0 | ||
fi | ||
|
||
# Run the herb formatter on the list of files | ||
julia --startup-file=no -O1 --color=yes .dev/herb_format.jl --check $files | ||
|
||
# If the formatter exited with an error, abort the commit | ||
if [ $? -ne 0 ]; then | ||
echo "Error: formatter must be run on the files before committing." | ||
echo "Please run julia .dev/herb_format.jl YOUR_CHANGED_FILES.jl" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: ['*'] | ||
pull_request: | ||
workflow_dispatch: | ||
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: | ||
test: | ||
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 60 | ||
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created | ||
actions: write | ||
contents: read | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
version: | ||
- '1.10' | ||
- '1.6' | ||
- 'pre' | ||
os: | ||
- ubuntu-latest | ||
arch: | ||
- x64 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: julia-actions/setup-julia@v2 | ||
with: | ||
version: ${{ matrix.version }} | ||
arch: ${{ matrix.arch }} | ||
- uses: julia-actions/cache@v2 | ||
- uses: julia-actions/julia-buildpkg@v1 | ||
- uses: julia-actions/julia-runtest@v1 | ||
- uses: julia-actions/julia-processcoverage@v1 | ||
- uses: codecov/codecov-action@v4 | ||
with: | ||
files: lcov.info | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
fail_ci_if_error: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: CompatHelper | ||
on: | ||
schedule: | ||
- cron: 0 0 * * * | ||
workflow_dispatch: | ||
jobs: | ||
CompatHelper: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Pkg.add("CompatHelper") | ||
run: julia -e 'using Pkg; Pkg.add("CompatHelper")' | ||
- name: CompatHelper.main() | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} | ||
run: julia -e 'using CompatHelper; CompatHelper.main()' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Formatting Check | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: '*' | ||
pull_request: | ||
|
||
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: | ||
format: | ||
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
version: | ||
- '1' | ||
os: | ||
- ubuntu-latest | ||
arch: | ||
- x64 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: dorny/paths-filter@v3 | ||
id: filter | ||
with: | ||
filters: | | ||
julia_file_change: | ||
- added|modified: '**.jl' | ||
list-files: 'shell' | ||
|
||
- uses: julia-actions/setup-julia@latest | ||
if: steps.filter.outputs.julia_file_change == 'true' | ||
with: | ||
version: ${{ matrix.version }} | ||
|
||
- uses: julia-actions/cache@v1 | ||
|
||
- name: Apply JuliaFormatter | ||
if: steps.filter.outputs.julia_file_change == 'true' | ||
run: | | ||
julia --color=yes .dev/herb_format.jl --verbose ${{ steps.filter.outputs.julia_file_change_files }} | ||
- name: Check formatting diff | ||
if: steps.filter.outputs.julia_file_change == 'true' | ||
run: | | ||
git diff --color=always --exit-code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: TagBot | ||
on: | ||
issue_comment: | ||
types: | ||
- created | ||
workflow_dispatch: | ||
inputs: | ||
lookback: | ||
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 }} | ||
ssh: ${{ secrets.DOCUMENTER_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
name = "Garden" | ||
uuid = "22d0bc84-1826-4aaf-b584-c2a6a91114a2" | ||
authors = ["Sebastijan <sebastijan.dumancic@gmail.com>"] | ||
version = "0.1.0" | ||
|
||
[compat] | ||
julia = "1.6.7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# Garden | ||
Please water the Herbs. | ||
|
||
[![Build Status](https://github.com/Herb-AI/Garden.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/Herb-AI/Garden.jl/actions/workflows/CI.yml?query=branch%3Amain) | ||
[![Coverage](https://codecov.io/gh/Herb-AI/Garden.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/Herb-AI/Garden.jl) | ||
[![PkgEval](https://JuliaCI.github.io/NanosoldierReports/pkgeval_badges/G/Garden.svg)](https://JuliaCI.github.io/NanosoldierReports/pkgeval_badges/G/Garden.html) | ||
[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using Garden | ||
using BenchmarkTools | ||
|
||
SUITE = BenchmarkGroup() | ||
SUITE["rand"] = @benchmarkable rand(10) | ||
|
||
# Write your benchmarks here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[deps] | ||
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" | ||
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Garden | ||
using Test | ||
using Aqua | ||
using JET | ||
|
||
@testset "Garden.jl" begin | ||
@testset "Code quality (Aqua.jl)" begin | ||
Aqua.test_all(Garden) | ||
end | ||
if VERSION >= v"1.7" | ||
@testset "Code linting (JET.jl)" begin | ||
JET.test_package(Garden; target_defined_modules = true) | ||
end | ||
end | ||
# Write your tests here. | ||
end |