-
Notifications
You must be signed in to change notification settings - Fork 0
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
4 changed files
with
123 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
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,63 @@ | ||
name: PR CI | ||
|
||
on: | ||
pull_request: | ||
branches: ['**'] | ||
|
||
jobs: | ||
node_ci: | ||
name: Node.js CI | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 5 | ||
defaults: | ||
run: | ||
shell: bash | ||
|
||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
node_version: ['12.22.12', '14.19.2', '16.15.0'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node_version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '${{ matrix.node_version }}' | ||
cache: 'npm' | ||
- run: npm ci | ||
- run: npm run build | ||
- run: npm pack | ||
|
||
deno_ci: | ||
name: Deno CI | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 5 | ||
defaults: | ||
run: { shell: bash } | ||
|
||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
deno_version: ['v1.17.0', 'v1.21.1', 'vx.x.x'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Deno ${{ matrix.deno_version }} | ||
uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: '${{ matrix.deno_version }}' | ||
- run: deno fmt --check | ||
if: matrix.deno_version == 'vx.x.x' | ||
- run: deno lint | ||
if: matrix.deno_version == 'vx.x.x' | ||
- run: deno test --allow-all | ||
- name: deno coverage cov_profile/ | ||
if: matrix.deno_version == 'vx.x.x' | ||
run: | | ||
rm -rf cov_profile/ || true | ||
deno test --allow-all --coverage=cov_profile/ > /dev/null 2>%1 | ||
deno coverage cov_profile/ | ||
- name: Check coverage 100% | ||
if: matrix.deno_version == 'vx.x.x' | ||
run: ./scripts/check-coverage 100 |
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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
# result.js | ||
|
||
Typescript implementation of Rust's Result | ||
Zero dependency Typescript implementation of Rust's Result. | ||
|
||
## Supported Environments | ||
|
||
| Environment | Versions | | ||
| ----------- | ------------------------------------ | | ||
| Deno | `v1.17.0` and `v1.21.1` | | ||
| Node.js | `12.22.12`, `14.19.2`, and `16.15.0` | |
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 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
repo_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null 2>&1 && pwd )" | ||
|
||
help_text=" | ||
check-coverage | ||
This script check test coverage output in cov_profile/ directory. | ||
Usage: build_nexe MININUM_PERCENT | ||
" | ||
|
||
case "$1" in | ||
"help"|"--help"|"-h"|"") | ||
echo "$help_text" | ||
exit 0 | ||
;; | ||
*) | ||
integer_regex='^[0-9]+$' | ||
if ! [[ $1 =~ $integer_regex ]] ; then | ||
echo "error: Input is not an integer: $1" | ||
exit 1 | ||
fi | ||
if ! [[ -d "$repo_dir/cov_profile/" ]]; then | ||
echo "Code coverage directory not found. Run: deno test --allow-all --coverage=cov_profile/" | ||
exit 1 | ||
fi | ||
echo "Running deno coverage report ..." | ||
coverage_report="$(deno coverage cov_profile | sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g')" | ||
coverage_stats="$(echo "$coverage_report" | grep -E '^cover \S+ \.\.\.')" | ||
failed_files="" | ||
echo -e "Checking all files in deno coverage report meet minimum ...\n" | ||
while IFS= read -r coverage_stat; do | ||
coverage_number="$(echo "$coverage_stat" | rev | cut -d ' ' -f 2 | rev | sed 's|%||g')" | ||
if (( $(echo "$coverage_number < $1" | bc -l) )); then | ||
failed_files="$failed_files$coverage_stat\n" | ||
fi | ||
done <<< "$coverage_stats" | ||
if [[ "$failed_files" == "" ]]; then | ||
echo "PASSED" | ||
exit 0 | ||
else | ||
echo "FAILED" | ||
echo -e "$failed_files" | ||
exit 1 | ||
fi | ||
;; | ||
esac |