Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/update-parsers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ jobs:
- name: Update parsers
run: ./cli --update-parsers

- name: Build application
run: shards build bit --release --no-debug
env:
ENV: production

- name: Run tests
run: crystal spec
env:
ENV: test

- name: Run end-to-end tests
run: crystal spec e2e
env:
ENV: test

- name: Check for changes
id: changes
run: |
Expand Down
2 changes: 1 addition & 1 deletion docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ info:
## Authentication

Multiple users are supported via `X-Api-Key` headers. Create, list and delete keys via the [CLI](https://github.com/sjdonado/bit/blob/master/SETUP.md#cli).
version: 1.6.0
version: 1.7.0
contact:
name: sjdonado
url: https://sjdonado.com
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: bit
version: 1.6.0
version: 1.7.0

authors:
- Juan Rodriguez Donado <@sjdonado>
Expand Down
22 changes: 22 additions & 0 deletions spec/lib/parsers_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require "../spec_helper"

# Runs against the files in data/, so the Update Parsers workflow checks each download before opening its PR.
describe "Parser data" do
it "resolves countries from the GeoLite2 database" do
App::Lib::IpLookup.country("8.8.8.8").should eq("US")
App::Lib::IpLookup.country("2001:4860:4860::8888").should eq("US")
end

it "parses common user agents with the uap-core regexes" do
{
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36" => {"Chrome", "Windows"},
"Mozilla/5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Mobile/15E148 Safari/604.1" => {"Mobile Safari", "iOS"},
"Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Mobile Safari/537.36" => {"Chrome Mobile", "Android"},
"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" => {"Googlebot", nil},
}.each do |user_agent, (browser, os)|
family, _, _, parsed_os = App::Lib::UserAgent.parse(user_agent)
family.should eq(browser)
parsed_os.try(&.[0]).should eq(os)
end
end
end
Loading