Skip to content

Commit

Permalink
WIP: Gleam Bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
maennchen committed Nov 10, 2024
1 parent a3c0432 commit d0e109d
Show file tree
Hide file tree
Showing 8 changed files with 106 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 @@ -99,6 +99,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 @@ -255,6 +291,28 @@ jobs:
name: mix_test-coverage-${{ matrix.elixir }}
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
2 changes: 2 additions & 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 Expand Up @@ -28,6 +29,7 @@ oidcc-*.tar
# Ignore Package Lock Files (not relevant for library)
mix.lock
rebar.lock
manifest.toml

# Certification Subtree
/certification
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 27.1.2
rebar 3.24.0
elixir 1.17.3
gleam 1.5.1
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ Supervisor.init(
)
```

### Gleam

```sh
gleam add oidcc
```

<!-- TODO: Instructions -->

## Usage

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

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"

gleam = ">= 1.5.1"

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

[dev-dependencies]
gleeunit = "~> 1.2"
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 d0e109d

Please sign in to comment.