Skip to content

Commit

Permalink
refactor: overhaul impl, deps, tooling, and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
TillaTheHun0 committed Feb 27, 2024
1 parent f09af73 commit 52f8da3
Show file tree
Hide file tree
Showing 19 changed files with 415 additions and 145 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/deploy.yml

This file was deleted.

110 changes: 110 additions & 0 deletions .github/workflows/test-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: 🏎 Test & Publish Adapter

on:
pull_request:
branches:
- main
push:
branches:
- main

# Perform a release using a workflow dispatch
workflow_dispatch:
inputs:
# See https://github.com/hyper63/hyper-ci-bump#inputs for available inputs for the bump action
version:
description: the semver version to bump to
required: true

jobs:

test:
runs-on: ubuntu-latest
strategy:
matrix:
deno-version: [1.x]

steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: 🦕 Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno-version }}

- name: ⚡ Run Tests
run: |
deno task test
env:
CI: true

bump:
# Releases are performed via a workflow dispatch
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
needs: [test]
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: 👀 Env
run: |
echo "Event name: ${{ github.event_name }}"
echo "Git ref: ${{ github.ref }}"
echo "GH actor: ${{ github.actor }}"
echo "SHA: ${{ github.sha }}"
VER=`node --version`; echo "Node ver: $VER"
VER=`npm --version`; echo "npm ver: $VER"
- name: 🤓 Set Git User
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: ✊ Bump
id: bump
uses: hyper63/hyper-ci-bump@main
with:
bump-to: ${{ github.event.inputs.version }}

- name: ⬆️ Push
run: |
git push
git push --tags
- name: 🤖 Create Github Release
if: steps.bump.outputs.tag
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.bump.outputs.tag }}

publish:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
needs: [bump]
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: 🛠 Build Executables
run: deno task compile
env:
CI: true

- name: 🤫 Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: 🗄 Upload Executables to S3
run: |
aws s3 cp --acl public-read ./hyper-copy s3://hyperland

17 changes: 0 additions & 17 deletions .github/workflows/test.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hyper-copy
17 changes: 0 additions & 17 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,2 @@
image:
file: .gitpod.Dockerfile

github:
prebuilds:
# enable for the default branch (defaults to true)
master: true
# enable for all branches in this repo (defaults to false)
branches: false
# enable for pull requests coming from this repo (defaults to true)
pullRequests: true
# enable for pull requests coming from forks (defaults to false)
pullRequestsFromForks: false
# add a check to pull requests (defaults to true)
addCheck: true
# add a "Review in Gitpod" button as a comment to pull requests (defaults to false)
addComment: false
# add a "Review in Gitpod" button to the pull request's description (defaults to false)
addBadge: false
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deno task staged
4 changes: 4 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"*.{md,json,js,ts}": ["deno fmt"],
"README.md": ["deno run -A --no-lock npm:markdown-toc-gen@1 insert", "deno fmt"]
}
7 changes: 2 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"deno.enable": true,
"deno.lint": true,
"deno.unstable": true,
"deno.importMap": "./import_map.json",
}
"deno.enable": true
}
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,48 @@
<h1 align="center">⚡️ hyper copy ⚡️</h1>
<p align="center">Copy a hyper data service</p>
<p align="center">Copy documents from one hyper Data Service to another hyper Data Service</p>

<a href="https://github.com/hyper63/copy/actions/workflows/test.yml"><img src="https://github.com/hyper63/copy/actions/workflows/test.yml/badge.svg" alt="Test" /></a>
<a href="https://github.com/hyper63/copy/actions/workflows/test-and-publish.yml"><img src="https://github.com/hyper63/copy/actions/workflows/test-and-publish.yml/badge.svg" alt="Test" /></a>

---

## Table of Contents
<!-- toc -->

- [Quick Start](#quick-start)
- [Requirements](#requirements)
- [Example](#example)
- [Contributing](#contributing)
- [LICENSE](#license)

<!-- tocstop -->

---

## Quick Start

``` sh
> First, make sure you've
> [created your destination hyper `Data` `Service`](https://docs.hyper.io/docs/api-reference/rest/data.html#create-a-data-service)
```sh
curl -O https://hyperland.s3.amazon.aws.com/hyper-copy
chmod +x hyper-copy
hyper-copy [SRC_CONNECTION_STRING] [TARGET_CONNECTION_STRING]
```

`hyper-copy` will copy documents from `SRC_CONNECTION_STRING` to `TARGET_CONNECTION_STRING`, `1000`
at a time, until all documents have been copied.

## Requirements

* Linux x64 Environment
- Linux x64 Environment

> If there is interest in creating binaries for other enviroments, please submit an issue.
## Example

## Contributing
## Contributing

All contributions are welcome as long as they are targeted at improving and extending the capabilities of the copy functionality.
All contributions are welcome as long as they are targeted at improving and extending the
capabilities of the copy functionality.

## LICENSE

Expand Down
22 changes: 11 additions & 11 deletions copy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as R from 'ramda'
import crocks from 'crocks'
const { Async } = crocks
const { compose, prop, last } = R
const FINISHED = '__FINISHED__'
const lastId = compose(prop('id'), last)
const isOk = result => result.ok ? Async.of(result) : Async.Rejected('Error Copying Data')
const checkFinished = limit => xs => xs.length === limit ? lastId(xs) : FINISHED
import { crocks, R } from './deps.js';

const { Async } = crocks;
const { compose, prop, last } = R;
const FINISHED = '__FINISHED__';
const lastId = compose(prop('id'), last);
const isOk = (result) => result.ok ? Async.of(result) : Async.Rejected('Error Copying Data');
const checkFinished = (limit) => (xs) => xs.length === limit ? lastId(xs) : FINISHED;
/**
* @param {Async} list
* @param {Async} bulk
Expand All @@ -22,6 +22,6 @@ export default function (list, bulk) {
.chain(bulk)
.chain(isOk)
.map(prop('results'))
.map(checkFinished(limit))
}
}
.map(checkFinished(limit));
};
}
33 changes: 33 additions & 0 deletions copy.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { assertEquals } from 'https://deno.land/[email protected]/testing/asserts.ts';

import { crocks } from './deps.js';
import copy from './copy.js';
const { Async } = crocks;

const test = Deno.test;
const list = () =>
Async.Resolved({ ok: true, docs: [{ id: '1', type: 'foo' }, { id: '2', type: 'bar' }] });
const bulk = () =>
Async.Resolved({ ok: true, results: [{ ok: true, id: '1' }, { ok: true, id: '2' }] });

const cp = copy(list, bulk);

test('return last key', async () => {
const key = await cp(2, '').toPromise();
assertEquals(key, '2');
});

test('return finished', async () => {
const key = await cp(1001, '').toPromise();
assertEquals(key, '__FINISHED__');
});

test('error', async () => {
const b = () => Async.Resolved({ ok: false });
const cp2 = copy(list, b);
try {
await cp2(1001, '').toPromise();
} catch (err) {
assertEquals(err, 'Error Copying Data');
}
});
30 changes: 0 additions & 30 deletions copy_test.js

This file was deleted.

22 changes: 22 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://deno.land/x/deno/cli/schemas/config-file.v1.json",
"description": "Copy documents from one hyper Data Service to another hyper Data Service",
"tasks": {
"cache": "deno cache --lock=deno.lock --lock-write ./deps.js",
"compile": "deno compile --allow-net --unstable --no-check --output hyper-copy mod.js",
"prepare": "deno run -A --no-lock npm:husky@^9",
"staged": "deno run -A --no-lock npm:lint-staged@^15",
"test": "deno lint && deno test --no-lock -A"
},
"lint": {
"rules": {
"tags": ["recommended"]
}
},
"fmt": {
"useTabs": false,
"lineWidth": 100,
"indentWidth": 2,
"singleQuote": true
}
}
Loading

0 comments on commit 52f8da3

Please sign in to comment.