Skip to content

Commit

Permalink
WIP: Gleam Bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
maennchen committed Dec 5, 2023
1 parent 6d28af8 commit 4e0c1c2
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/branch_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ on:
push:
branches:
- "main"
# TODO: Remove after testing
- "jm/gleam_bindings"

name: "Main Branch"

Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/part_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,42 @@ jobs:
- run: mix deps.get
- run: mix format --check-formatted

gleam_format:
name: gleam format

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
id: setupBEAM
with:
version-file: .tool-versions
version-type: strict
- run: gleam format --check src test

gleam_check:
name: gleam check

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
id: setupBEAM
with:
version-file: .tool-versions
version-type: strict
- uses: actions/cache@v3
with:
path: build
key: gleam_check-build-${{ runner.os }}-${{ steps.setupBEAM.outputs.gleam-version }}-${{ hashFiles('gleam.toml') }}
restore-keys: |
gleam_check-build-${{ runner.os }}-${{ steps.setupBEAM.outputs.gleam-version }}-
- run: gleam deps download
- run: gleam build --warnings-as-errors
- run: gleam check

eunit:
name: rebar3 eunit (${{ matrix.otp }})

Expand Down Expand Up @@ -208,6 +244,28 @@ jobs:
name: mix_test-coverage
path: cover/mix_test-${{ steps.setupBEAM.outputs.elixir-version }}.coverdata

gleam_test:
name: gleam test

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
id: setupBEAM
with:
version-file: .tool-versions
version-type: strict
- uses: actions/cache@v3
with:
path: build
key: gleam_test-build-${{ runner.os }}-${{ steps.setupBEAM.outputs.gleam-version }}-${{ hashFiles('gleam.toml') }}
restore-keys: |
gleam_test-build-${{ runner.os }}-${{ steps.setupBEAM.outputs.gleam-version }}-
- run: gleam deps download
- run: gleam build --warnings-as-errors
- run: gleam test

coverage:
name: mix test.coverage

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# The directory Mix & Rebar will write compiled artifacts to.
/_build/
/build/
*.beam

# If you run "mix test --cover" / "rebar3 eunit" / "rebar3 ct", coverage assets end up here.
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
erlang 26.1.2
rebar 3.22.1
elixir 1.15.7
gleam 0.32.4
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ Supervisor.init([
], strategy: :one_for_one)
```

### Gleam

```sh
gleam add oidcc
```

<!-- TODO: Instructions -->

## Usage

### Companion libraries
Expand Down
16 changes: 16 additions & 0 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name = "oidcc"
version = "3.1.0"

description = "OpenID Connect client library for the BEAM."
licences = ["Apache-2.0"]
repository = { type = "github", user = "erlef", repo = "oidcc" }
links = [{ title = "Github", href = "https://github.com/erlef/oidcc" }]

target = "erlang"

[dependencies]
gleam_stdlib = "~> 0.32"
jose = "~> 1.11"

[dev-dependencies]
gleeunit = "~> 1.0"
13 changes: 13 additions & 0 deletions manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file was generated by Gleam
# You typically do not need to edit this file

packages = [
{ name = "gleam_stdlib", version = "0.33.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "3CEAD7B153D896499C78390B22CC968620C27500C922AED3A5DD7B536F922B25" },
{ name = "gleeunit", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D3682ED8C5F9CAE1C928F2506DE91625588CC752495988CBE0F5653A42A6F334" },
{ name = "jose", version = "1.11.6", build_tools = ["mix", "rebar3"], requirements = [], otp_app = "jose", source = "hex", outer_checksum = "6275CB75504F9C1E60EEACB771ADFEEE4905A9E182103AA59B53FED651FF9738" },
]

[requirements]
gleam_stdlib = { version = "~> 0.32" }
gleeunit = { version = "~> 1.0" }
jose = { version = "~> 1.11" }
5 changes: 5 additions & 0 deletions src/oidcc.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import gleam/io

pub fn main() {
io.println("Hello from oidcc!")
}
12 changes: 12 additions & 0 deletions test/oidcc_test.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import gleeunit
import gleeunit/should

pub fn main() {
gleeunit.main()
}

// gleeunit test functions end in `_test`
pub fn hello_world_test() {
1
|> should.equal(2)
}

0 comments on commit 4e0c1c2

Please sign in to comment.