Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autogenerate README.md File #792

Merged
merged 2 commits into from
Dec 14, 2022
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
92 changes: 69 additions & 23 deletions .github/workflows/site.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,74 @@
# This file was autogenerated using `zio-sbt` via `sbt generateGithubWorkflow`
# task and should be included in the git repository. Please do not edit
# it manually.
# This file was autogenerated using `zio-sbt-website` via `sbt generateGithubWorkflow`
# task and should be included in the git repository. Please do not edit it manually.

name: website

on:
name: Website
'on':
release:
types: [ published ]

types:
- published
push:
branches:
- master
jobs:
publish-docs:
runs-on: ubuntu-20.04
timeout-minutes: 30
name: Publish Docs
runs-on: ubuntu-latest
if: ${{ (github.event_name == 'release') && (github.event.action == 'published')
}}
steps:
- name: Git Checkout
uses: actions/checkout@v3.1.0
with:
fetch-depth: '0'
- name: Setup Scala
uses: actions/setup-java@v3.6.0
with:
distribution: temurin
java-version: 17
check-latest: true
- name: Setup NodeJs
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: https://registry.npmjs.org
- name: Publish Docs to NPM Registry
run: sbt docs/publishToNpm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
generate-readme:
name: Generate README
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.1.0
with:
fetch-depth: 0
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v13
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Publishing Docs to NPM Registry
run: sbt docs/publishToNpm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Git Checkout
uses: actions/checkout@v3.1.0
with:
ref: ${{ github.head_ref }}
fetch-depth: '0'
- name: Setup Scala
uses: actions/setup-java@v3.6.0
with:
distribution: temurin
java-version: 17
check-latest: true
- name: Generate Readme
run: sbt docs/generateReadme
- name: Commit Changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add README.md
git commit -m "Update README.md" || echo "No changes to commit"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
body: |
Autogenerated changes after running the `sbt docs/generateReadme` command of the [zio-sbt-website](https://zio.dev/zio-sbt) plugin.

I will automatically update the README.md file whenever there is new change for README.md, e.g.
- After each release, I will update the version in the installation section.
- After any changes to the "docs/index.md" file, I will update the README.md file accordingly.
branch: zio-sbt-website/update-readme
commit-message: Update README.md
branch-suffix: short-commit-hash
title: Update README.md

30 changes: 27 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,34 @@ lazy val macros = project
lazy val docs = project
.in(file("zio-sql-docs"))
.settings(
publish / skip := true,
moduleName := "zio-sql-docs",
publish / skip := true,
moduleName := "zio-sql-docs",
scalacOptions -= "-Yno-imports",
scalacOptions -= "-Xfatal-warnings"
scalacOptions -= "-Xfatal-warnings",
projectName := "ZIO SQL",
badgeInfo := Some(
BadgeInfo(
artifact = "zio-sql_2.12",
projectStage = ProjectStage.ProductionReady
)
),
docsPublishBranch := "master",
readmeContribution := readmeContribution.value +
"""|### TL;DR
|Prerequisites (installed):
|
|| Technology | Version |
||------------|---------|
|| sbt | 1.4.3 |
|| Docker | 3.1 |
|
|To set up the project follow below steps:
|1. Fork the repository.
|2. Setup the upstream (Extended instructions can be followed [here](https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/fork-a-repo)).
|3. Make sure you have installed `sbt` and `Docker`.
|4. In project directory execute `sbt test`.
|5. Pick up an issue & you are ready to go!
|""".stripMargin
)
.dependsOn(postgres)
.enablePlugins(WebsitePlugin)
Expand Down
55 changes: 55 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,59 @@ title: "Introduction to ZIO SQL"
sidebar_label: "ZIO SQL"
---

ZIO SQL lets you write type-safe, type-inferred, and composable SQL queries in ordinary Scala, helping you prevent persistence bugs before they happen, and leverage your IDE to make writing SQL productive, safe, and fun.

@PROJECT_BADGES@

## Introduction

* **Type-safety**. ZIO SQL queries are type-safe by construction. Most classes of bugs can be detected at compile-time, shortening your feedback loop and helping you use your IDE to write correct queries.
* **Composable**. All ZIO SQL components are ordinary values, which can be transformed and composed in sensible ways. This uniformity and regularity means you have a lot of power in a small package.
* **Type-inferred**. ZIO SQL uses maximal variance and lower-kinded types, which means it features very good type inference. You can let Scala figure out the types required for type-safe SQL.
* **No magic**. ZIO SQL does not need any macros or plug-ins to operate (everything is a value!), and it works across both Scala 2.x and Scala 3. Optionally, Scala schema can be created from database schemas.

ZIO SQL can be used as a library for modeling SQL in a type-safe ADT. In addition, ZIO SQL has a JDBC interface, which utilizes the type-safe SQL ADT for interacting with common JDBC databases.

For the JDBC module:

- Like Slick, ZIO SQL has an emphasis on type-safe SQL construction using Scala values and methods. However, ZIO SQL utilizes reified lenses, contravariant intersection types, and in-query nullability to improve ergonomics for end-users. Unlike Slick, the intention is to use names resembling SQL instead of trying to mimic the Scala collections.
- Like Doobie, ZIO SQL is purely functional, but ZIO SQL does compile-time query validation that catches most issues, and has rich ZIO integration, offering improved type-safety compared to monofunctor effects and minimal dependencies (depending only on ZIO).

ZIO SQL does not offer Language Integrated Queries (LINQ) or similar functionality. It is intended only as a data model for representing SQL queries and an accompanying lightweight JDBC-based executor.

## Current status: Non-production release

### Progress report towards 0.1

:heavy_check_mark: - good to go

:white_check_mark: - some more work needed

#### General features:

| Feature | Progress |
|:-----------------|:-------------------|
| Type-safe schema | :heavy_check_mark: |
| Type-safe DSL | :heavy_check_mark: |
| Running Reads | :heavy_check_mark: |
| Running Deletes | :heavy_check_mark: |
| Running Updates | :heavy_check_mark: |
| Running Inserts | :heavy_check_mark: |
| Transactions | :white_check_mark: |
| Connection pool | :white_check_mark: |

#### Db-specific features:

| Feature | PostgreSQL | SQL Server | Oracle | MySQL |
|:--------------|:-------------------|:-------------------|:-------------------|:-------------------|
| Render Read | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Render Delete | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Render Update | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Render Insert | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Functions | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Types | :white_check_mark: | | | :white_check_mark: |
| Operators | | | | |

## Installation

ZIO SQL is packaged into separate modules for different databases. Depending on which of these (currently supported) systems you're using, you will need to add one of the following dependencies:
Expand All @@ -25,6 +78,7 @@ libraryDependencies += "dev.zio" %% "zio-sql-sqlserver" % "@VERSION@"
## Imports and modules

Most of the needed imports will be resolved with

```scala
import zio.sql._
```
Expand Down Expand Up @@ -82,6 +136,7 @@ Field names are also converted to lowercase and snake case.

Once we have our table definition we need to decompose table into columns which we will use in queries.
Using the previous example with `Product` and `Order` table

```scala
val (id, name, price) = products.columns

Expand Down
11 changes: 9 additions & 2 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
const sidebars = {
sidebar: [
"index",
"deep-dive"
{
type: "category",
label: "ZIO SQL",
collapsed: false,
link: { type: "doc", id: "index" },
items: [
"deep-dive"
]
}
]
};

Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" %
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.1")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.4.1")
addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.1.0")
addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.1.5+10-49adf3d7-SNAPSHOT")

resolvers ++= Resolver.sonatypeOssRepos("public")