From 8169f4e3fede2772ad53059192ce25039be7f641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20M=C3=A4nnchen?= Date: Tue, 5 Dec 2023 21:43:19 +0100 Subject: [PATCH] WIP: Gleam Bindings --- .github/workflows/branch_main.yml | 2 ++ .github/workflows/part_test.yml | 58 +++++++++++++++++++++++++++++++ .gitignore | 1 + .tool-versions | 1 + README.md | 8 +++++ gleam.toml | 16 +++++++++ manifest.toml | 13 +++++++ src/oidcc.gleam | 5 +++ test/oidcc_test.gleam | 12 +++++++ 9 files changed, 116 insertions(+) create mode 100644 gleam.toml create mode 100644 manifest.toml create mode 100644 src/oidcc.gleam create mode 100644 test/oidcc_test.gleam diff --git a/.github/workflows/branch_main.yml b/.github/workflows/branch_main.yml index 058e43c..98499c7 100644 --- a/.github/workflows/branch_main.yml +++ b/.github/workflows/branch_main.yml @@ -2,6 +2,8 @@ on: push: branches: - "main" + # TODO: Remove after testing + - "jm/gleam_bindings" name: "Main Branch" diff --git a/.github/workflows/part_test.yml b/.github/workflows/part_test.yml index d2cfc91..5a4d190 100644 --- a/.github/workflows/part_test.yml +++ b/.github/workflows/part_test.yml @@ -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 }}) @@ -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 diff --git a/.gitignore b/.gitignore index b4dc0c2..0c75a59 100644 --- a/.gitignore +++ b/.gitignore @@ -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. diff --git a/.tool-versions b/.tool-versions index f524e36..2f619b9 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,4 @@ erlang 27.0.1 rebar 3.24.0 elixir 1.17.2 +gleam 1.5.1 diff --git a/README.md b/README.md index b032610..f859aa5 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,14 @@ Supervisor.init( ) ``` +### Gleam + +```sh +gleam add oidcc +``` + + + ## Usage ### Companion libraries diff --git a/gleam.toml b/gleam.toml new file mode 100644 index 0000000..dd0ed91 --- /dev/null +++ b/gleam.toml @@ -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" diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..999ab75 --- /dev/null +++ b/manifest.toml @@ -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" } diff --git a/src/oidcc.gleam b/src/oidcc.gleam new file mode 100644 index 0000000..be76c94 --- /dev/null +++ b/src/oidcc.gleam @@ -0,0 +1,5 @@ +import gleam/io + +pub fn main() { + io.println("Hello from oidcc!") +} diff --git a/test/oidcc_test.gleam b/test/oidcc_test.gleam new file mode 100644 index 0000000..1a11c54 --- /dev/null +++ b/test/oidcc_test.gleam @@ -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) +}