Skip to content

Commit

Permalink
deno skeletons
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyBanks committed Feb 14, 2021
1 parent a0b0c0d commit ab86262
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/deno.yaml
@@ -0,0 +1,88 @@
name: Deno

on:
push:
create:
pull_request:
workflow_dispatch:
schedule:
- cron: '44 4 * * 0'

jobs:
deno:
name: Deno
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- name: cache deno installation and deno.land dependencies
uses: actions/cache@v2
with:
key: ${{ runner.os }}-deno-${{ hashFiles('**/*') }}
restore-keys: ${{ runner.os }}-deno-
path: |
/home/runner/.deno
/home/runner/.cache/deno/deps/https/deno.land
- name: install or update deno installation
run: |
export DENO_INSTALL="/home/runner/.deno"
export PATH="${DENO_INSTALL}/bin:${PATH}"
mkdir -p "${DENO_INSTALL}"
deno upgrade || (
curl -fsSL https://deno.land/x/install/install.sh > "${DENO_INSTALL}/.sh";
sh "${DENO_INSTALL}/.sh"
)
deno --version
deno info
echo "DENO_INSTALL=${DENO_INSTALL}" >> "${GITHUB_ENV}"
echo "PATH=${PATH}" >> "${GITHUB_ENV}"
- name: build
id: build
run: |
deno fmt
git status
declare had_changes="$(
[[ -n "$(git status --porcelain)" ]] && echo true || echo false
)"
echo "::set-output name=had-changes::${had_changes}"
- run: deno test

- name: commit and push generated changes
if: success() && steps.build.outputs.had-changes == 'true' && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
run: |
declare br="
"
declare branch="$(echo ${GITHUB_REF#refs/heads/})"
declare date="$(git log -1 --pretty=format:'%ad')"
declare short_hash="$(git rev-parse --short=8 HEAD)"
declare short_subject="$(git log -1 --pretty=format:'%s')"
declare short_subject="$(git log -1 --pretty=format:'%s')"
if [[ ${#short_subject} -gt 50 ]]; then
short_subject="${short_subject:0:49}…"
fi
declare author_name="$(git log -1 --pretty=format:'%an')"
declare author_email="$(git log -1 --pretty=format:'%ae')"
declare current_action_url="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${{ github.run_id }}"
export GIT_AUTHOR_DATE="${date}"
export GIT_AUTHOR_NAME="${author_name}"
export GIT_AUTHOR_EMAIL="${author_email}"
export GIT_COMMITTER_DATE="${date}"
export GIT_COMMITTER_NAME="github-actions"
export GIT_COMMITTER_EMAIL="41898282+github-actions[bot]@users.noreply.github.com"
git remote rm origin
git remote add origin "https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
git checkout "${branch}"
git add .
git commit -m "⚙️ rebuild ${short_hash} (${short_subject})${br}${br}${current_action_url}"
git push --set-upstream origin "${branch}"
- name: fail if source files modified during build but this action cannot push
if: success() && steps.build.outputs.had-changes == 'true' && !(github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
run: |
echo "source files modified during build but this action cannot push"
git status
exit 1
3 changes: 3 additions & 0 deletions .vscode/settings.json
@@ -0,0 +1,3 @@
{
"deno.enable": true
}
5 changes: 5 additions & 0 deletions README.md
@@ -0,0 +1,5 @@
# x/database




1 change: 1 addition & 0 deletions mod.ts
@@ -0,0 +1 @@
export * as sql from "./sql/mod.ts";
5 changes: 5 additions & 0 deletions sql/README.md
@@ -0,0 +1,5 @@
# x/database/sql

`x/database/sql` provides an abstract interface for SQL databases in Deno,
inspired by
[Go's standard `database/sql` package](https://pkg.go.dev/database/sql).
1 change: 1 addition & 0 deletions sql/mod.ts
@@ -0,0 +1 @@
export {}
10 changes: 10 additions & 0 deletions sql/test.ts
@@ -0,0 +1,10 @@
import { assert } from "https://deno.land/std@0.87.0/testing/asserts.ts";

import * as sql from "./mod.ts";

Deno.test({
name: "import * from x/database/sql/mod.ts",
fn() {
assert(sql);
},
});
10 changes: 10 additions & 0 deletions test.ts
@@ -0,0 +1,10 @@
import { assert } from "https://deno.land/std@0.87.0/testing/asserts.ts";

import * as database from "./mod.ts";

Deno.test({
name: "import * from x/database/mod.ts",
fn() {
assert(database);
},
});

0 comments on commit ab86262

Please sign in to comment.