Skip to content

Commit 9533c57

Browse files
authored
Merge pull request #2 from inoas/release/v1.1.0
Release/v1.1.0
2 parents c70f8a5 + 30c5758 commit 9533c57

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+993
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env sh
2+
3+
set -eu
4+
5+
psql <<SQL
6+
SELECT 'CREATE DATABASE gleam_cake_pog_test'
7+
WHERE NOT EXISTS (
8+
SELECT FROM pg_database WHERE datname = 'gleam_cake_pog_test'
9+
)\\gexec
10+
SQL

.github/workflows/abstract_test.yml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
gleam_version:
7+
type: string
8+
required: true
9+
default: "1.6"
10+
erlang_version:
11+
type: string
12+
default: "26"
13+
test_erlang:
14+
type: boolean
15+
default: true
16+
test_node:
17+
type: boolean
18+
default: true
19+
20+
jobs:
21+
format:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: inoas/gleam_actions/.github/actions/install_gleam@main-on-upstream
26+
with:
27+
gleam_version: ${{inputs.gleam_version}}
28+
erlang_version: ${{inputs.erlang_version}}
29+
- uses: inoas/gleam_actions/.github/actions/format@main-on-upstream
30+
31+
deps:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
- uses: inoas/gleam_actions/.github/actions/install_gleam@main-on-upstream
36+
with:
37+
gleam_version: ${{ inputs.gleam_version }}
38+
erlang_version: ${{ inputs.erlang_version }}
39+
- uses: inoas/gleam_actions/.github/actions/deps_cache@main-on-upstream
40+
with:
41+
gleam_version: ${{ inputs.gleam_version }}
42+
43+
test_erlang:
44+
if: inputs.test_erlang
45+
runs-on: ubuntu-latest
46+
services:
47+
postgres:
48+
image: postgres:latest
49+
env:
50+
POSTGRES_PASSWORD: postgres
51+
options: >-
52+
--health-cmd pg_isready
53+
--health-interval 10s
54+
--health-timeout 5s
55+
--health-retries 5
56+
ports:
57+
- 5432:5432
58+
needs: deps
59+
strategy:
60+
fail-fast: true
61+
matrix:
62+
erlang:
63+
- ${{inputs.erlang_version}}
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: inoas/gleam_actions/.github/actions/install_gleam@main-on-upstream
67+
with:
68+
gleam_version: ${{ inputs.gleam_version }}
69+
erlang_version: ${{ matrix.erlang }}
70+
- run: ./.github/sh/create-database-gleam_cake_pog_test-postgres.sh
71+
env:
72+
PGHOST: localhost
73+
PGPORT: 5432
74+
PGPASSWORD: postgres
75+
PGUSER: postgres
76+
- uses: inoas/gleam_actions/.github/actions/test@main-on-upstream
77+
with:
78+
target: "erlang"

.github/workflows/test.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_call:
9+
10+
jobs:
11+
test_lowest:
12+
uses: ./.github/workflows/abstract_test.yml
13+
with:
14+
erlang_version: "26"
15+
gleam_version: "1.6.3"
16+
test_erlang: true
17+
test_node: false
18+
test_highest:
19+
uses: ./.github/workflows/abstract_test.yml
20+
with:
21+
erlang_version: "27"
22+
gleam_version: "1.7.0"
23+
test_erlang: true
24+
test_node: false

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
*.ez
33
/build
44
erl_crash.dump
5+
6+
/docker/data/*
7+
!/docker/data/.gitkeep

.tool-versions

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# erlang 26.2.5.6
2+
# gleam 1.6.3
3+
erlang 27.2
4+
gleam 1.7.0
5+
# gleam nightly

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
55

66
<!-- ## [Unreleased] -->
77

8+
## [1.1.0] - 2025-01-12
9+
10+
- Added unit tests, CI and fixed compatibility with `gleam_stdlib >= 0.50`.
11+
812
## [1.0.3] - 2024-11-14
913

1014
- Renamed library from `cake_gleam_pgo` to `cake_pog`.

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import cake/delete as d
2828
import cake/insert as i
2929
import cake/select as s
3030
import cake/where as w
31-
import gleam/dynamic
31+
import gleam/dynamic/decode
3232
import gleam/option.{None}
3333
3434
const postgres_database_name = "my_postgres_database_name"
@@ -71,7 +71,7 @@ fn insert_into_table_birds(db_connection) {
7171
]
7272
)
7373
|> i.to_query
74-
|> postgres.run_write_query(dynamic.dynamic, db_connection)
74+
|> postgres.run_write_query(decode.dynamic, db_connection)
7575
|> io.debug
7676
}
7777
@@ -80,7 +80,7 @@ fn select_from_table_birds(db_connection) {
8080
|> s.from_table("table")
8181
|> s.selects([s.col("species")])
8282
|> s.to_query
83-
|> postgres.run_read_query(dynamic.dynamic, db_connection)
83+
|> postgres.run_read_query(decode.dynamic, db_connection)
8484
|> io.debug
8585
}
8686
@@ -89,7 +89,7 @@ fn delete_from_table_birds(db_connection) {
8989
|> d.table("birds")
9090
|> d.where(w.col("species") |> w.eq(w.string("Dodo")))
9191
|> d.to_query
92-
|> postgres.run_write_query(dynamic.dynamic, db_connection)
92+
|> postgres.run_write_query(decode.dynamic, db_connection)
9393
|> io.debug
9494
}
9595
```

bin/birdie/accept-all

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
gleam test >/dev/null 2>&1
4+
gleam run --module birdie accept-all

bin/birdie/interactive-review

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
gleam test >/dev/null 2>&1
4+
gleam run --module birdie review

bin/birdie/reject-all

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
gleam test >/dev/null 2>&1
4+
gleam run --module birdie reject-all

bin/cloc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
# Go to the root of the project
4+
cd "$(dirname "$0")" && cd ..
5+
6+
cloc ./bin ./birdie_snapshots ./src ./test

bin/docker/attached

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
# Go to the root of the project
4+
cd "$(dirname "$0")" && cd ../..
5+
6+
docker compose down
7+
docker rm gleam-cake-test-postgres --force --volumes 2>/dev/null
8+
docker rm gleam-cake-test-mariadb --force --volumes 2>/dev/null
9+
rm -rf docker/data/*
10+
touch docker/data/.keep
11+
docker compose up --remove-orphans

bin/docker/detached

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
# Go to the root of the project
4+
cd "$(dirname "$0")" && cd ../..
5+
6+
docker compose down
7+
docker rm gleam-cake-test-postgres --force --volumes 2>/dev/null
8+
docker rm gleam-cake-test-mariadb --force --volumes 2>/dev/null
9+
rm -rf docker/data/*
10+
touch docker/data/.keep
11+
docker compose up --remove-orphans --detach

bin/docker/down

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
# Go to the root of the project
4+
cd "$(dirname "$0")" && cd ../..
5+
6+
docker compose down
7+
rm -rf postgres-data
8+
rm -rf docker/data/postgres/pgdata

bin/rg-pub-fn-in-src

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
# Go to the root of the project
4+
cd "$(dirname "$0")" && cd ..
5+
6+
rg 'pub fn' --count --sort-files src

bin/test

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
# Go to the root of the project
4+
cd "$(dirname "$0")" && cd ..
5+
6+
gleam test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
version: 1.2.5
3+
title: delete_execution_result_test
4+
file: ./test/cake_test/delete_test.gleam
5+
test_name: delete_execution_result_test
6+
---
7+
Ok([])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
version: 1.2.5
3+
title: delete_prepared_statement_test
4+
file: ./test/cake_test/delete_test.gleam
5+
test_name: delete_prepared_statement_test
6+
---
7+
PreparedStatement(
8+
"$",
9+
"DELETE FROM owners USING cats INNER JOIN dogs AS dogs ON dogs.name = cats.name WHERE owners.name = $1 AND cats.owner_id = owners.id RETURNING owners.id",
10+
[StringParam("Alice")],
11+
1,
12+
Postgres,
13+
)

birdie_snapshots/delete_test.accepted

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
version: 1.2.5
3+
title: delete_test
4+
file: ./test/cake_test/delete_test.gleam
5+
test_name: delete_test
6+
---
7+
DeleteQuery(Delete(
8+
NoDeleteModifier,
9+
DeleteTable("owners"),
10+
DeleteUsing([FromTable("cats")]),
11+
Joins([
12+
InnerJoin(
13+
JoinTable("dogs"),
14+
"dogs",
15+
WhereComparison(
16+
WhereColumnValue("dogs.name"),
17+
Equal,
18+
WhereColumnValue("cats.name"),
19+
),
20+
),
21+
]),
22+
AndWhere([
23+
WhereComparison(
24+
WhereColumnValue("owners.name"),
25+
Equal,
26+
WhereParamValue(StringParam("Alice")),
27+
),
28+
WhereComparison(
29+
WhereColumnValue("cats.owner_id"),
30+
Equal,
31+
WhereColumnValue("owners.id"),
32+
),
33+
]),
34+
Returning(["owners.id"]),
35+
NoEpilog,
36+
NoComment,
37+
))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
version: 1.2.5
3+
title: insert_values_execution_result_test
4+
file: ./test/cake_test/insert_values_test.gleam
5+
test_name: insert_values_execution_result_test
6+
---
7+
Ok([#("Whiskers")])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
version: 1.2.5
3+
title: insert_values_prepared_statement_test
4+
file: ./test/cake_test/insert_values_test.gleam
5+
test_name: insert_values_prepared_statement_test
6+
---
7+
PreparedStatement(
8+
"$",
9+
"INSERT INTO cats (name, rating, age) VALUES ($1, $2, $3) RETURNING name",
10+
[
11+
StringParam("Whiskers"),
12+
FloatParam(3.14),
13+
IntParam(42),
14+
],
15+
3,
16+
Postgres,
17+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
version: 1.2.5
3+
title: insert_values_test
4+
file: ./test/cake_test/insert_values_test.gleam
5+
test_name: insert_values_test
6+
---
7+
InsertQuery(Insert(
8+
InsertIntoTable("cats"),
9+
InsertColumns([
10+
"name",
11+
"rating",
12+
"age",
13+
]),
14+
NoInsertModifier,
15+
InsertSourceRows([
16+
InsertRow([
17+
InsertParam(StringParam("Whiskers")),
18+
InsertParam(FloatParam(3.14)),
19+
InsertParam(IntParam(42)),
20+
]),
21+
]),
22+
InsertConflictError,
23+
Returning(["name"]),
24+
NoEpilog,
25+
NoComment,
26+
))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
version: 1.2.5
3+
title: select_distinct_execution_result_test
4+
file: ./test/cake_test/select_test.gleam
5+
test_name: select_distinct_execution_result_test
6+
---
7+
Ok([False, True, Null])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
version: 1.2.5
3+
title: select_distinct_prepared_statement_test
4+
file: ./test/cake_test/select_test.gleam
5+
test_name: select_distinct_prepared_statement_test
6+
---
7+
PreparedStatement(
8+
"$",
9+
"SELECT DISTINCT is_wild FROM cats ORDER BY is_wild ASC",
10+
[],
11+
0,
12+
Postgres,
13+
)

0 commit comments

Comments
 (0)