Skip to content

Commit

Permalink
update to 0.3.0 (#13)
Browse files Browse the repository at this point in the history
* fix: version compatibility (#12)

* fix: compilation issues

includes:
- bump to zig from 0.9 to 0.11
- `Jason` package dependency
- better libcurl library linking

* chore: bump to 0.3.0

* chore(ci): updated version matrix

* fix(compatibility): set elixir 1.14 as minimum

zigler depends on `Keyword.replace_lazy` which was
introduced in Elixir 1.14.

* chore(deps): bump zigler to 0.12.x dev branch

* fix: working with zigler and zig 0.12

* fix(ci): install zig and update version matrix

* chore(ci): update deprecated action steps

* feat: add devenv

* chore(deps): bump ex_doc to 0.34

* chore(deps): update zigler version

* feat(ci): add macos-latest and use ubuntu-latest

* fix(macos-ci): caching and rebar3

* fix(ci): macos installs zig

* chore(deps): bump bypass deps

* fix(ci): macos erlang 27.0 -> 27.0.1

* chore(macos-ci): specify elixir otp version

* fix(macos-ci): use asdf to install zig instead of zig.get

* fix(macos-ci): less specific latest elixir/otp versions

* chore(deps): bump to stable zigler

* chore(devenv): bump to zig 0.13

* chore(ci): use zig.get

* chore(ci): add publish action

* chore(ci): use separate action for zig

* chore: use metrics struct instead of inline fields

* chore(docs): minor docs corrections

* chore(docs): updated repo urls

* chore(lint): use Zig.Formatter
  • Loading branch information
danielrudn authored Aug 21, 2024
1 parent 5c35b5f commit ff0841d
Show file tree
Hide file tree
Showing 20 changed files with 556 additions and 359 deletions.
3 changes: 2 additions & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
plugins: [Zig.Formatter]
]
65 changes: 55 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,83 @@ on:
branches:
- master

env:
MIX_ENV: test

jobs:
ci:
runs-on: ubuntu-20.04
env:
MIX_ENV: test
ci-macos:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
include:
- pair:
elixir: "1.11.4"
otp: "23.0"
elixir: "1.14"
otp: "25.3"
zig: "0.13.0"
- pair:
elixir: "1.17"
otp: "27.0"
zig: "0.13.0"
steps:
- uses: actions/checkout@v4
- name: Generate .tool-versions file
run: |
echo "zig ${{ matrix.pair.zig }}" >> .tool-versions
echo "elixir ${{ matrix.pair.elixir }}" >> .tool-versions
echo "erlang ${{ matrix.pair.otp }}" >> .tool-versions
cp .tool-versions ~/.
cat .tool-versions
- uses: asdf-vm/actions/install@v3
- name: Install Hex package manager
run: mix local.hex --force && mix local.rebar --force
- run: mix deps.get
- uses: actions/cache@v4
with:
path: |
~/.asdf
deps
key: mix-deps-${{ hashFiles('**/mix.lock') }}-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}
- run: mix test
ci-ubuntu:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- pair:
elixir: "1.14"
otp: "25.0"
otp: "25.3"
- pair:
elixir: "1.15"
otp: "26.2"
- pair:
elixir: "1.16"
otp: "26.2"
- pair:
elixir: "1.17"
otp: "27.0"
lint: lint
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install test dependencies
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev krb5-{user,kdc,admin-server}

- name: Setup Kerberos environment and initialize configuration
run: sudo ./test/support/files/setup_kerberos.sh

- uses: erlef/setup-beam@main
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.13.0

- uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.pair.otp}}
elixir-version: ${{matrix.pair.elixir}}
version-type: strict

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: deps
key: mix-deps-${{ hashFiles('**/mix.lock') }}
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish

on:
push:
branches: [master]
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest
name: Publish
env:
HEX_API_KEY: ${{secrets.HEX_API_KEY}}
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: "27.0"
elixir-version: "1.17"
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.13.0
- run: mix deps.get
- name: Publish Documentation
run: mix hex.publish docs --yes
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
- name: Publish Package
run: mix hex.publish --yes
if: github.event_name == 'release' && github.event.action == 'published'
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ ex_curl-*.tar

# Temporary files, for example, from tests.
/tmp/

lib/.Elixir.*.zig

# devenv
.devenv*
devenv.local.nix
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ExCurl [![CI](https://github.com/open-status/ex_curl/actions/workflows/ci.yml/badge.svg)](https://github.com/open-status/ex_curl/actions/workflows/ci.yml) [![Hex.pm](https://img.shields.io/hexpm/v/ex_curl.svg)](https://hex.pm/packages/ex_curl) [![Hexdocs.pm](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/ex_curl/)
# ExCurl [![CI](https://github.com/danielrudn/ex_curl/actions/workflows/ci.yml/badge.svg)](https://github.com/danielrudn/ex_curl/actions/workflows/ci.yml) [![Hex.pm](https://img.shields.io/hexpm/v/ex_curl.svg)](https://hex.pm/packages/ex_curl) [![Hexdocs.pm](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/ex_curl/)

Elixir bindings for libcurl using Zig's C interoperability.

Expand All @@ -9,7 +9,7 @@ The package can be installed by adding `ex_curl` to your list of dependencies in
```elixir
def deps do
[
{:ex_curl, "~> 0.2.1"}
{:ex_curl, "~> 0.3.0"}
]
end
```
Expand All @@ -18,7 +18,7 @@ To install `ex_curl` in a Livebook, you can use `Mix.install/2`:

```elixir
Mix.install([
{:ex_curl, "~> 0.2.1"}
{:ex_curl, "~> 0.3.0"}
])
```

Expand All @@ -30,7 +30,7 @@ ExCurl.get("https://httpbin.org/get")

# view request metrics
ExCurl.get!("https://httpbin.org/get", return_metrics: true)
# => %ExCurl.Response{status_code: 200, total_time: 0.2, namelookup_time: 0.01, appconnect_time: 0.05, ...}}
# => %ExCurl.Response{status_code: 200, metrics: %ExCurl.ResponseMetrics{total_time: 0.2, ...}, ...}}

# submit a form
ExCurl.post("https://httpbin.org/post", body: "text=#{URI.encode_www_form("some value")}")
Expand Down
139 changes: 139 additions & 0 deletions devenv.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1722262342,
"owner": "cachix",
"repo": "devenv",
"rev": "11a1ca0ad80bc172d2efda34ae542494442dcf48",
"treeHash": "c1be883f8fad6adb0369cef0ac6e6c9bd7f3ec66",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"treeHash": "2addb7b71a20a25ea74feeaf5c2f6a6b30898ecb",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"treeHash": "ca14199cabdfe1a06a7b1654c76ed49100a689f9",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1716977621,
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "4267e705586473d3e5c8d50299e71503f16a6fb6",
"treeHash": "6d9f1f7ca0faf1bc2eeb397c78a49623260d3412",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1722221733,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "12bf09802d77264e441f48e25459c10c93eada2e",
"treeHash": "e959ebf2e25b21ec31266bef769b447e4b907916",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1722185531,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "52ec9ac3b12395ad677e8b62106f0b98c1f8569d",
"treeHash": "561285c3e9ff92b7fff8f6111828711f012cb158",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1721042469,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "f451c19376071a90d8c58ab1a953c6e9840527fd",
"treeHash": "91f40b7a3b9f6886bd77482cba5b5cd890415a2e",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable",
"pre-commit-hooks": "pre-commit-hooks"
}
}
},
"root": "root",
"version": 7
}
14 changes: 14 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{ pkgs, config, inputs, ... }:
let unstable-pkgs = import inputs.nixpkgs-unstable { system = pkgs.stdenv.system; };
in {
packages = [
unstable-pkgs.zig_0_13
unstable-pkgs.elixir_1_17
pkgs.curl
];

enterTest = ''
mix deps.get
mix test
'';
}
7 changes: 7 additions & 0 deletions devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
nixpkgs-unstable:
url: github:NixOS/nixpkgs/nixos-unstable

4 changes: 2 additions & 2 deletions lib/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule ExCurl.Client do
```elixir
defmodule GitHubClient do
use ExCurl.Client, defaults: [base_url: "https://api.github.com", headers: %{"authentication" => "Bearer some-secret-token"}]
use ExCurl.Client, defaults: [base_url: "https://api.github.com", headers: %{"Authorization" => "Bearer some-secret-token"}]
def user_repos(username), do: get("/users/\#{username}/repos")
end
Expand All @@ -33,7 +33,7 @@ defmodule ExCurl.Client do
```elixir
defmodule GitHubClient do
use ExCurl.Client, defaults: [base_url: "https://api.github.com", headers: %{"authentication" => "Bearer some-secret-token"}]
use ExCurl.Client, defaults: [base_url: "https://api.github.com", headers: %{"Authorization" => "Bearer some-secret-token"}]
def handle_response(%ExCurl.Response{body: body}) do
case Jason.decode(body) do
Expand Down
2 changes: 1 addition & 1 deletion lib/curl_error_codes.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule ExCurl.CurlErrorCodes do
@moduledoc """
Helper functions to map [curl error codes](https://curl.se/libcurl/c/libcurl-errors.html) from their integer value to the string value and vice versa.
Helper functions to map [libcurl error codes](https://curl.se/libcurl/c/libcurl-errors.html) from their integer value to the string value and vice versa.
"""

@all_error_codes [
Expand Down
Loading

0 comments on commit ff0841d

Please sign in to comment.