Skip to content

Commit

Permalink
Merge branch 'main' into al/json
Browse files Browse the repository at this point in the history
  • Loading branch information
DXTimer authored Dec 19, 2024
2 parents 49c9fd4 + 324ab10 commit a8916b5
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 34 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/check-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash -e

GITHUB_PR_LABEL="dependencies"
COMMIT_TITLE="Update dependencies"

if [ -z "$BRANCH_NAME" ]; then
echo "Branch name is required"
exit 1
fi

function check_pr {
gh pr list --state open --label "$GITHUB_PR_LABEL"
}

git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"

_update_output="$(TERM=dumb rebar3 update-deps --replace)"

if git diff --exit-code --quiet; then
echo "No changes to the dependencies"
exit 0
else
echo "Detected changes to dependencies, also reformatting"
rebar3 fmt --write
fi

git checkout -b "$BRANCH_NAME"
git add .

git commit -F- <<EOF
$COMMIT_TITLE
Updates from "rebar3 update-deps --replace":
$_update_output
EOF

git push --set-upstream origin "$BRANCH_NAME"

if [[ $(check_pr) == "" ]]; then
gh pr create \
--label "$GITHUB_PR_LABEL" \
--title "$COMMIT_TITLE" \
--body-file - <<EOF
This PR updates the dependencies to their latest versions.
The following changes were made from \`rebar3 update-deps --replace\`:
\`\`\`
$_update_output
\`\`\`
EOF
fi
45 changes: 45 additions & 0 deletions .github/workflows/check_deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Check Dependencies

on:
workflow_dispatch:
schedule:
- cron: '38 8 * * *'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions: write-all

jobs:
check-deps:
name: Check Dependencies
runs-on: ubuntu-22.04
strategy:
matrix:
otp_version: ['27.1']

steps:
- uses: actions/checkout@v4

- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp_version }}
rebar3-version: '3.22.1'
version-type: 'strict'

- uses: actions/cache@v4
with:
path: |
~/.cache/rebar3
_build
key: ${{ runner.os }}-erlang-${{ matrix.otp_version }}-${{ hashFiles('**/*rebar.lock') }}

- name: Build
run: make build

- name: Check dependencies
run: .github/workflows/check-deps.sh
env:
BRANCH_NAME: update-deps-${{ github.run_id }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 changes: 13 additions & 33 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,83 +1,63 @@
%%-*- mode: erlang -*-
{cover_enabled, true}.

{erl_opts, [
debug_info,
fail_on_warning,
{platform_define, "^[0-9]+", namespaced_types},
{parse_transform, lager_transform}
]}.

{project_plugins, [
erlfmt
]}.
{project_plugins, [erlfmt, rebar3_depup]}.

{deps, [
{lager, "3.9.2"},
recon,
folsom,
{dns_erlang, ".*", {git, "https://github.com/dnsimple/dns_erlang.git", {branch, "main"}}},
iso8601,
{nodefinder, "2.0.0"},
{opentelemetry_api, "0.6.0"},
{meck, "0.9.2"}
{nodefinder, "2.0.7"},
{opentelemetry_api, "1.4.0"},
{meck, "1.0.0"}
]}.

{profiles, [{test, [{deps, [proper]}]}]}.

{project_plugins, [rebar3_format]}.

{format, [
{formatter, default_formatter},
{files, [
"src/**/*.?rl", "include/**/*.?rl"
]},
{files, ["src/**/*.?rl", "include/**/*.?rl"]},
{options, #{
paper => 160,
ribbon => 150,
inline_attributes => none,
inline_qualified_function_composition => true
}}
]}.
{depup, [{only, minor}]}.

{shell, [
{apps, [erldns]},
{config, "erldns.config"}
]}.
{shell, [{apps, [erldns]}, {config, "erldns.config"}]}.

{relx, [
{release, {erldns, "3.0.0"}, [erldns]},

{dev_mode, true},
{include_erts, false},
{sys_config, "erldns.config"},
{overlay, [
{copy, "priv/zones-example.json", "priv/zones-example.json"},
{copy, "priv/zones-test.json", "priv/zones-test.json"}
]},

{extended_start_script, true}
]}.

%% This is a rebar3-ism
{overrides, [
{override, dns_erlang, [
{plugins, [
{provider_asn1, "0.2.3"}
]},
{plugins, [{provider_asn1, "0.2.3"}]},
{provider_hooks, [
{pre, [
{compile, {asn, compile}}
]},
{post, [
{clean, {asn, clean}}
]}
{pre, [{compile, {asn, compile}}]},
{post, [{clean, {asn, clean}}]}
]}
]}
]}.

{dialyzer, [{warnings, [no_unknown]}]}.
{erlfmt, [write, {print_width, 140}]}.

{erlfmt, [
write,
{print_width, 140}
]}.
%% This is a rebar3-ism
7 changes: 6 additions & 1 deletion src/erldns_zone_parser.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
-export([
start_link/0,
zone_to_erlang/1,
zone_to_erlang/2,
register_parsers/1,
register_parser/1,
list_parsers/0
Expand Down Expand Up @@ -59,10 +60,14 @@ start_link() ->
%% @doc Takes a JSON zone and turns it into the tuple {Name, Sha, Records}.
%%
%% The default timeout for parsing is currently 30 seconds.
-spec zone_to_erlang(binary()) -> {binary(), binary(), [dns:rr()], [erldns:keyset()]}.
-spec zone_to_erlang(map() | list()) -> {binary(), binary(), [dns:rr()], [erldns:keyset()]}.
zone_to_erlang(Zone) ->
gen_server:call(?SERVER, {parse_zone, Zone}, ?PARSE_TIMEOUT).

-spec zone_to_erlang(binary(), integer()) -> {binary(), binary(), [dns:rr()], [erldns:keyset()]}.
zone_to_erlang(Zone, Timeout) ->
gen_server:call(?SERVER, {parse_zone, Zone}, Timeout).

%% @doc Register a list of custom parser modules.
-spec register_parsers([module()]) -> ok.
register_parsers(Modules) ->
Expand Down

0 comments on commit a8916b5

Please sign in to comment.