Skip to content

Commit bbae7db

Browse files
author
Stephan Sahm
committed
setup CI, docs and codecov
1 parent d3d209c commit bbae7db

File tree

9 files changed

+172
-28
lines changed

9 files changed

+172
-28
lines changed

.github/workflows/CompatHelper.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: CompatHelper
2+
on:
3+
schedule:
4+
- cron: 0 0 * * *
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Pkg.add("CompatHelper")
10+
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
11+
- name: CompatHelper.main()
12+
run: julia -e 'using CompatHelper; CompatHelper.main()'
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/TagBot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: TagBot
2+
on:
3+
schedule:
4+
- cron: 0 0 * * *
5+
jobs:
6+
TagBot:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: JuliaRegistries/TagBot@v1
10+
with:
11+
token: ${{ secrets.GITHUB_TOKEN }}
12+
ssh: ${{ secrets.DOCUMENTER_KEY }}

.github/workflows/ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: CI
2+
on:
3+
- push
4+
- pull_request
5+
jobs:
6+
test:
7+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
version:
12+
- '1.0'
13+
- '1.4'
14+
- 'nightly'
15+
os:
16+
- ubuntu-latest
17+
- macOS-latest
18+
- windows-latest
19+
arch:
20+
- x64
21+
steps:
22+
- uses: actions/checkout@v2
23+
- uses: julia-actions/setup-julia@v1
24+
with:
25+
version: ${{ matrix.version }}
26+
arch: ${{ matrix.arch }}
27+
- uses: actions/cache@v1
28+
env:
29+
cache-name: cache-artifacts
30+
with:
31+
path: ~/.julia/artifacts
32+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
33+
restore-keys: |
34+
${{ runner.os }}-test-${{ env.cache-name }}-
35+
${{ runner.os }}-test-
36+
${{ runner.os }}-
37+
- uses: julia-actions/julia-buildpkg@latest
38+
- uses: julia-actions/julia-runtest@latest
39+
- uses: julia-actions/julia-processcoverage@v1
40+
- uses: codecov/codecov-action@v1
41+
with:
42+
file: lcov.info
43+
docs:
44+
name: Documentation
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v2
48+
- uses: julia-actions/setup-julia@v1
49+
with:
50+
version: '1'
51+
- run: |
52+
julia --project=docs -e '
53+
using Pkg
54+
Pkg.develop(PackageSpec(path=pwd()))
55+
Pkg.instantiate()'
56+
- run: julia --project=docs docs/make.jl
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Stephan Sahm <stephan.sahm@gmx.de> and contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Project.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
name = "DataTypesBasic"
22
uuid = "83eed652-29e8-11e9-12da-a7c29d64ffc9"
33
authors = ["Sahm Stephan <stephan.sahm@gmx.de>"]
4-
version = "0.3.0"
4+
version = "1.0.0"
55

66
[deps]
7+
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
78
IsDef = "2704c575-34db-4e2b-9135-fc0075949e5a"
9+
10+
[compat]
11+
Compat = "2.1, 3"
12+
IsDef = "1"
13+
julia = "1"
14+
15+
[extras]
16+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
17+
18+
[targets]
19+
test = ["Test"]

README.md

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
# DataTypesBasic
22

3-
This package defines julia implementations for the common types ``Option`` (aka ``Maybe``), ``Either`` and ``Try``, as well as one extra type `ContextManager` which mimics behaviour realized in Python with python contextmanagers.
3+
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://schlichtanders.github.io/DataTypesBasic.jl/stable)
4+
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://schlichtanders.github.io/DataTypesBasic.jl/dev)
5+
[![Build Status](https://github.com/schlichtanders/DataTypesBasic.jl/workflows/CI/badge.svg)](https://github.com/schlichtanders/DataTypesBasic.jl/actions)
6+
[![Coverage](https://codecov.io/gh/schlichtanders/DataTypesBasic.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/schlichtanders/DataTypesBasic.jl)
7+
8+
This package defines julia implementations for the common types `Option` (aka `Maybe`), `Either` and `Try`, as well as one extra type `ContextManager` which mimics Python's `with`-ContextManager.
49

510
Use it like
611
```julia
712
using DataTypesBasic
8-
DataTypesBasic.@overwrite_Base
913
```
10-
The macro `@overwrite_Base` assigns ``Some`` to `DataTypesBasic.Some` (in order to have consistent naming [following Scala](https://www.scala-lang.org/api/current/scala/Option.html)).
1114

1215
## Installation
1316

@@ -20,30 +23,18 @@ pkg"add DataTypesBasic"
2023

2124
## Option
2225

23-
``Option{T}`` Type is like ``Union{T, Nothing}``, plus that you can dispatch on it more easily.
24-
25-
It is literally defined like an abstract type with two instances ``None`` and ``Some``
26-
```julia
27-
abstract type Option{T} end
28-
struct None{T} <: Option{T} end
29-
struct Some{T} <: Option{T}
30-
value::T
31-
end
32-
```
33-
as you can see, ``None{T}`` captures the information ``"no value"`` of Type `T`, and ``Some{T}`` guarantees to have
34-
a value of Type `T`.
26+
`Option{T} = Union{Identity{T}, Nothing}`
3527

3628
Use it like
3729
```julia
3830
using DataTypesBasic
39-
DataTypesBasic.@overwrite_Base
4031

41-
fo(a::Some{String}) = a.value * "!"
42-
fo(a::None{String}) = "fallback behaviour"
32+
fo(a::Identity{String}) = a.value * "!"
33+
fo(a::Nothing) = "fallback behaviour"
4334

4435
fo(Option("hi")) # "hi!"
45-
fo(Option{String}()) # "fallback behaviour"
46-
# f(Option{Int}()) # not implemented
36+
fo(Option(nothing)) # "fallback behaviour"
37+
fo(Option()) # "fallback behaviour"
4738
```
4839

4940
The real power of `Option` comes from generic functionalities which you can define on it. `DataTypesBasic` already defines the following:
@@ -53,10 +44,9 @@ consult the respective function definition for details.
5344
Here an example for such a higher level perspective
5445
```julia
5546
using DataTypesBasic
56-
DataTypesBasic.@overwrite_Base
5747

58-
flatten(a::Some) = a.value
59-
flatten(a::None) = a
48+
flatten(a::Identity) = a.value
49+
flatten(a::Nothing) = a
6050

6151
function map2(f, a::Option{S}, b::Option{T}) where {S, T} # this comes
6252
nested_option = map(a) do a′
@@ -69,14 +59,14 @@ end
6959

7060
map2(Option("hi"), Option("there")) do a, b
7161
"$a $b"
72-
end # Some{String}("hi there")
62+
end # Identity("hi there")
7363

7464
map2(Option(1), Option()) do a, b
7565
a + b
76-
end # None{Any}()
66+
end # nothing
7767
```
7868

79-
The package ``TypeClasses.jl`` (soon to come) implements a couple of such higher level concepts of immense use
69+
The package `TypeClasses.jl` (soon to come) implements a couple of such higher level concepts of immense use
8070
(like Functors, Applicatives and Monads).
8171

8272

@@ -94,6 +84,6 @@ Please see the tests `test/ContextManager.jl`.
9484

9585
## [TODO] Other
9686

97-
For abstraction purposes, there is also ``Const`` and ``Identity`` defined.
87+
For abstraction purposes, there is also `Const` and `Identity` defined.
9888

9989
Please see the tests `test/Const.jl` and `test/Identity.jl` respectively.

docs/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[deps]
2+
DataTypesBasic = "83eed652-29e8-11e9-12da-a7c29d64ffc9"
3+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

docs/make.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using DataTypesBasic
2+
using Documenter
3+
4+
makedocs(;
5+
modules=[DataTypesBasic],
6+
authors="Stephan Sahm <stephan.sahm@gmx.de> and contributors",
7+
repo="https://github.com/schlichtanders/DataTypesBasic.jl/blob/{commit}{path}#L{line}",
8+
sitename="DataTypesBasic.jl",
9+
format=Documenter.HTML(;
10+
prettyurls=get(ENV, "CI", "false") == "true",
11+
canonical="https://schlichtanders.github.io/DataTypesBasic.jl",
12+
assets=String[],
13+
),
14+
pages=[
15+
"Home" => "index.md",
16+
],
17+
)
18+
19+
deploydocs(;
20+
repo="github.com/schlichtanders/DataTypesBasic.jl",
21+
)

docs/src/index.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
```@meta
2+
CurrentModule = DataTypesBasic
3+
```
4+
5+
# DataTypesBasic
6+
7+
```@index
8+
```
9+
10+
```@autodocs
11+
Modules = [DataTypesBasic]
12+
```

0 commit comments

Comments
 (0)