-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
66,239 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import todomvc/web/routes | ||
import todomvc/log | ||
import gleam/int | ||
import gleam/string | ||
import gleam/result | ||
import gleam/erlang/os | ||
import gleam/http/elli | ||
import gleam/option | ||
import gleam/pgo | ||
|
||
pub fn main() { | ||
log.configure_backend() | ||
|
||
let port = load_port() | ||
let application_secret = load_application_secret() | ||
let db = start_database_connection_pool() | ||
let web = routes.stack(application_secret, db) | ||
|
||
let log_string = | ||
string.concat(["Listening on localhost:", int.to_string(port), " ✨"]) | ||
log.info(log_string) | ||
|
||
assert Ok(_) = elli.become(web, on_port: port) | ||
} | ||
|
||
pub fn start_database_connection_pool() -> pgo.Connection { | ||
let config = | ||
os.get_env("DATABASE_URL") | ||
|> result.then(pgo.url_config) | ||
|> result.lazy_unwrap(fn() { | ||
pgo.Config( | ||
..pgo.default_config(), | ||
host: "0.0.0.0", | ||
database: "gleam_todomvc_dev", | ||
user: "postgres", | ||
password: option.Some("postgres"), | ||
) | ||
}) | ||
|
||
pgo.connect(pgo.Config(..config, pool_size: 15)) | ||
} | ||
|
||
fn load_application_secret() -> String { | ||
os.get_env("APPLICATION_SECRET") | ||
|> result.unwrap("27434b28994f498182d459335258fb6e") | ||
} | ||
|
||
fn load_port() -> Int { | ||
os.get_env("PORT") | ||
|> result.then(int.parse) | ||
|> result.unwrap(8080) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import todomvc/web/routes | ||
import todomvc/log | ||
import gleam/int | ||
import gleam/string | ||
import gleam/result | ||
import gleam/erlang/os | ||
import gleam/http/elli | ||
import gleam/option | ||
import gleam/pgo | ||
|
||
pub fn main() { | ||
log.configure_backend() | ||
|
||
let port = load_port() | ||
let application_secret = load_application_secret() | ||
let db = start_database_connection_pool() | ||
let web = routes.stack(application_secret, db) | ||
|
||
string.concat(["Listening on localhost:", int.to_string(port), " ✨"]) | ||
|> log.info | ||
|
||
assert Ok(_) = elli.become(web, on_port: port) | ||
} | ||
|
||
pub fn start_database_connection_pool() -> pgo.Connection { | ||
let config = | ||
os.get_env("DATABASE_URL") | ||
|> result.then(pgo.url_config) | ||
|> result.lazy_unwrap(fn() { | ||
pgo.Config( | ||
..pgo.default_config(), | ||
host: "localhost", | ||
database: "gleam_todomvc_dev", | ||
user: "postgres", | ||
password: option.Some("postgres"), | ||
) | ||
}) | ||
|
||
pgo.connect(pgo.Config(..config, pool_size: 15)) | ||
} | ||
|
||
fn load_application_secret() -> String { | ||
os.get_env("APPLICATION_SECRET") | ||
|> result.unwrap("27434b28994f498182d459335258fb6e") | ||
} | ||
|
||
fn load_port() -> Int { | ||
os.get_env("PORT") | ||
|> result.then(int.parse) | ||
|> result.unwrap(3000) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../tree-sitter-gleam/queries/highlights.scm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tree-sitter-gleam/src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
src/** linguist-generated | ||
test/** linguist-documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
bless: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "14.x" | ||
|
||
- name: Cache npm dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: Install npm dependencies | ||
run: npm ci | ||
|
||
- name: Ensure generated parser files are up to date | ||
run: npx tree-sitter generate | ||
|
||
- name: Run tree-sitter tests | ||
run: npx tree-sitter test | ||
|
||
- name: Check formatting | ||
run: npm run check-formatted |
43 changes: 43 additions & 0 deletions
43
vendor/tree-sitter-gleam/.github/workflows/generate-parser.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# generates the parser with 'tree-sitter generate' if the parser is out of date | ||
name: Generate Parser | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
generate: | ||
name: Generate Parser | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "14.x" | ||
|
||
- name: Cache npm dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: Install npm dependencies | ||
run: npm ci | ||
|
||
- name: Generate parser files | ||
run: npx tree-sitter generate | ||
|
||
- name: Commit generated parser files | ||
run: | | ||
git config --local user.email "$(git log --format='%ae' HEAD^!)" | ||
git config --local user.name "$(git log --format='%an' HEAD^!)" | ||
git add src | ||
git commit -m "Generate parser" || true | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: release | ||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
build-release: | ||
name: build-release | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: | ||
- macos-latest | ||
- ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "14.x" | ||
|
||
- name: Install npm dependencies | ||
run: npm ci | ||
|
||
- name: Ensure generated parser files are up to date | ||
run: npx tree-sitter generate | ||
|
||
- name: Ensure tests pass | ||
run: npx tree-sitter test | ||
|
||
- name: Compile library file | ||
run: cc -shared -fPIC -g -O2 -I src src/parser.c -o tree-sitter-gleam.so | ||
|
||
- name: Create archive | ||
run: | | ||
VERSION="${GITHUB_REF#refs/tags/}" | ||
case ${{ matrix.os }} in | ||
"ubuntu-latest") FAMILY="linux";; | ||
"macos-latest") FAMILY="macos";; | ||
esac | ||
ARCHIVE="tree-sitter-gleam-$VERSION-$FAMILY.tar.gz" | ||
tar -czf $ARCHIVE tree-sitter-gleam.so | ||
echo "ASSET=$ARCHIVE" >> $GITHUB_ENV | ||
- name: Upload release archive | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
draft: true | ||
prerelease: false | ||
fail_on_unmatched_files: true | ||
files: | | ||
${{ env.ASSET }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
target | ||
build | ||
*.wasm | ||
log.html |
Oops, something went wrong.