From cdbcf1eedb52aff052afb0a7a3447b1ea97d5a8b Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:09:30 +0100 Subject: [PATCH] init --- .../pull_request_template.md | 11 ++ .github/release.yml | 30 +++++ .github/workflows/jsr.yaml | 27 +++++ .github/workflows/test.yaml | 105 ++++++++++++++++++ .github/workflows/update.yaml | 60 ++++++++++ .gitignore | 5 + LICENSE | 21 ++++ README.md | 3 + deno.jsonc | 29 +++++ deno.lock | 50 +++++++++ main.ts | 3 + main_test.ts | 8 ++ 12 files changed, 352 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE/pull_request_template.md create mode 100644 .github/release.yml create mode 100644 .github/workflows/jsr.yaml create mode 100644 .github/workflows/test.yaml create mode 100644 .github/workflows/update.yaml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 deno.jsonc create mode 100644 deno.lock create mode 100644 main.ts create mode 100644 main_test.ts diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md new file mode 100644 index 0000000..1c72509 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -0,0 +1,11 @@ +## Describe your changes + +## Issue ticket number and link + +## Checklist before requesting a review + +- [ ] Did you implement the changes in the correct branch? +- [ ] Is JSDocs for your new implementation up to date? +- [ ] Did you add tests for your changes? +- [ ] Did you update the documentation? +- [ ] Did all CI checks pass? diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..1928cc4 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,30 @@ +changelog: + exclude: + labels: + - 'Type: Meta' + - 'Type: Question' + - 'Type: Release' + + categories: + - title: Security Fixes + labels: ['Type: Security'] + - title: Breaking Changes + labels: ['Type: Breaking Change'] + - title: Features + labels: ['Type: Feature'] + - title: Bug Fixes + labels: ['Type: Bug'] + - title: Documentation + labels: ['Type: Documentation'] + - title: Refactoring + labels: ['Type: Refactoring'] + - title: Testing + labels: ['Type: Testing'] + - title: Maintenance + labels: ['Type: Maintenance'] + - title: CI + labels: ['Type: CI'] + - title: Dependency Updates + labels: ['Type: Dependencies', "dependencies"] + - title: Other Changes + labels: ['*'] diff --git a/.github/workflows/jsr.yaml b/.github/workflows/jsr.yaml new file mode 100644 index 0000000..963c101 --- /dev/null +++ b/.github/workflows/jsr.yaml @@ -0,0 +1,27 @@ +name: jsr + +env: + DENO_VERSION: 1.x + +on: + push: + tags: + - "*" + +permissions: + contents: read + id-token: write + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: denoland/setup-deno@v1 + with: + deno-version: ${{ env.DENO_VERSION }} + - name: Publish + run: | + deno run -A jsr:@david/publish-on-tag@0.1.3 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..8b402f1 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,105 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: Deno Test + +on: + push: + branches: + - main + paths: + - '**.ts' + - '.github/workflows/test.yml' + - 'deno.jsonc' + pull_request: + branches: + - main + paths: + - '**.ts' + +permissions: + contents: read + +jobs: + ci: + runs-on: ubuntu-latest + steps: + - name: Setup repo + uses: actions/checkout@v4 + + - name: Setup Deno + uses: denoland/setup-deno@v1 + with: + deno-version: v1.x + + - name: Check + run: deno task check + + - name: Run linter + run: deno task lint + + test: + runs-on: ubuntu-latest + steps: + - name: Setup repo + uses: actions/checkout@v4 + + - name: Setup Deno + uses: denoland/setup-deno@v1 + with: + deno-version: v1.x + + - name: Run test with coverage report + shell: bash + run: | + deno task test:coverage + deno task coverage:lco + deno task coverage:show >> .coverage/result.txt + + - name: Upload coverage report to Artifact + uses: actions/upload-artifact@v4 + with: + name: my-artifact + path: ./.coverage + + coverage-report: + needs: + - ci + - test + if: false # if you want to upload coverage report to Codecov, set to true + runs-on: ubuntu-latest + permissions: + write-all + steps: + - name: Download coverage report from Artifact + uses: actions/download-artifact@v4 + with: + name: my-artifact + path: ./.coverage + + - name: Upload coverage report to Codecov + uses: codecov/codecov-action@v4.3.0 + with: + file: ./.coverage/lcov.info + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} + slug: ${{ github.repository }} + + jsr-publish-dry-run: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: denoland/setup-deno@v1 + with: + deno-version: ${{ env.DENO_VERSION }} + - run: deno publish --dry-run + + action-timeline: + needs: + - ci + - test + - coverage-report + - jsr-publish-dry-run + if: ${{ always() }} + runs-on: ubuntu-latest + steps: + - uses: Kesin11/actions-timeline@v2 diff --git a/.github/workflows/update.yaml b/.github/workflows/update.yaml new file mode 100644 index 0000000..fdb8984 --- /dev/null +++ b/.github/workflows/update.yaml @@ -0,0 +1,60 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: Deno Update + +on: + schedule: + - cron: "0 9 * * *" + workflow_dispatch: {} + +jobs: + update: + permissions: write-all + runs-on: ubuntu-latest + + steps: + - name: Setup repo + uses: actions/checkout@v4 + + - name: Setup Deno + uses: denoland/setup-deno@v1 + with: + deno-version: v1.x + + - name: Update dependencies with molt + id: run-deno-molt + env: + NO_COLOR: true + run: | + { + echo 'MOLT_RESULT<> $GITHUB_OUTPUT + + - name: Check + run: deno task check + + - name: Run linter + run: deno task lint + + - name: Run tests + run: deno task test + + - name: Create pull request + uses: peter-evans/create-pull-request@v6 + with: + commit-message: "chore(deps): Update deno dependencies" + title: Update Deno dependencies + body: |- + Some external modules are stale. +
Details
+ + ``` + ${{ steps.run-deno-molt.outputs.MOLT_RESULT }} + ``` + +
+ branch: molt-update + author: GitHub + delete-branch: true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f4156b --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.DS_Store +/node_modules +/types +/.coverage +/npm diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fc90fe7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 ryoppippi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ce87628 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Deno jsr library template + + diff --git a/deno.jsonc b/deno.jsonc new file mode 100644 index 0000000..67293ce --- /dev/null +++ b/deno.jsonc @@ -0,0 +1,29 @@ +{ + "name": "@ryoppippi/", + "version": "0.0.0", + "tasks": { + "dev": "deno run --watch main.ts", + "check": "deno check ./**/*.ts && deno fmt --check", + "lint": "deno lint ./**/*.ts", + "test": "deno test -A --parallel --doc", + "test:coverage": "deno task test --coverage=.coverage", + "coverage:show": "deno coverage .coverage", + "coverage:lco": "deno coverage --lcov .coverage > .coverage/lcov.info" + }, + "fmt": { + "exclude": [ + "*.md" + ] + }, + "imports": { + "@cross/test": "jsr:@cross/test@^0.0.9", + "@std/assert": "jsr:@std/assert@^0.226.0" + }, + "exports": "./main.ts", + "keywords": [ + "random", + "regex", + "typescript", + "typesafe" + ] +} diff --git a/deno.lock b/deno.lock new file mode 100644 index 0000000..224f792 --- /dev/null +++ b/deno.lock @@ -0,0 +1,50 @@ +{ + "version": "3", + "packages": { + "specifiers": { + "jsr:@cross/runtime@^1.0.0": "jsr:@cross/runtime@1.0.0", + "jsr:@cross/test@^0.0.9": "jsr:@cross/test@0.0.9", + "jsr:@std/assert@^0.226.0": "jsr:@std/assert@0.226.0", + "jsr:@std/internal@^1.0.0": "jsr:@std/internal@1.0.0", + "npm:@types/node": "npm:@types/node@18.16.19", + "npm:cronstrue": "npm:cronstrue@2.50.0" + }, + "jsr": { + "@cross/runtime@1.0.0": { + "integrity": "dddecdf99182df13d50279d1e473f715e83d41961c5c22edd7bb0c4c3cf8a76a" + }, + "@cross/test@0.0.9": { + "integrity": "2aa8237a96a2f8f51ccc8fec71135616d223bf4f38dd89ba4f863037c85ddc56", + "dependencies": [ + "jsr:@cross/runtime@^1.0.0" + ] + }, + "@std/assert@0.226.0": { + "integrity": "0dfb5f7c7723c18cec118e080fec76ce15b4c31154b15ad2bd74822603ef75b3", + "dependencies": [ + "jsr:@std/internal@^1.0.0" + ] + }, + "@std/internal@1.0.0": { + "integrity": "ac6a6dfebf838582c4b4f61a6907374e27e05bedb6ce276e0f1608fe84e7cd9a" + } + }, + "npm": { + "@types/node@18.16.19": { + "integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==", + "dependencies": {} + }, + "cronstrue@2.50.0": { + "integrity": "sha512-ULYhWIonJzlScCCQrPUG5uMXzXxSixty4djud9SS37DoNxDdkeRocxzHuAo4ImRBUK+mAuU5X9TSwEDccnnuPg==", + "dependencies": {} + } + } + }, + "remote": {}, + "workspace": { + "dependencies": [ + "jsr:@cross/test@^0.0.9", + "jsr:@std/assert@^0.226.0" + ] + } +} diff --git a/main.ts b/main.ts new file mode 100644 index 0000000..8d9b8a2 --- /dev/null +++ b/main.ts @@ -0,0 +1,3 @@ +export function add(a: number, b: number): number { + return a + b; +} diff --git a/main_test.ts b/main_test.ts new file mode 100644 index 0000000..2169c6c --- /dev/null +++ b/main_test.ts @@ -0,0 +1,8 @@ +import { test } from "@cross/test"; +import { assertEquals } from "@std/assert"; + +import { add } from "./main.ts"; + +test("dummy", () => { + assertEquals(add(1, 2), 3); +});