diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml new file mode 100644 index 0000000..502bb9d --- /dev/null +++ b/.github/workflows/deno.yml @@ -0,0 +1,103 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# This workflow will install Deno and run tests across stable and nightly builds on Windows, Ubuntu and macOS. +# For more information see: https://github.com/denolib/setup-deno + +name: grammY validator + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + backport: + runs-on: ubuntu-latest + steps: + - name: Setup repo + uses: actions/checkout@v7 + with: + persist-credentials: false + + - name: Setup Node + uses: actions/setup-node@v7 + with: + node-version: 24 + + - name: Install dependencies + run: npm install --ignore-scripts + + - name: Run backporting + run: npm run backport + + format-and-lint: + runs-on: ubuntu-latest + steps: + - name: Setup repo + uses: actions/checkout@v7 + with: + persist-credentials: false + + - uses: denoland/setup-deno@v2 + with: + deno-version: v2.x + + - name: Check Format + run: deno fmt --check + + - name: Lint + run: deno lint + + - name: Type Check + run: deno check + + test: + runs-on: ${{ matrix.os }} # runs a test on Ubuntu, Windows and macOS + + strategy: + matrix: + os: [macOS-latest, windows-latest, ubuntu-latest] + + steps: + - name: Setup repo + uses: actions/checkout@v7 + with: + persist-credentials: false + + - uses: denoland/setup-deno@v2 + with: + deno-version: v2.x + + - name: Cache Dependencies + run: deno install + + - name: Run Tests + run: deno test + + coverage: + runs-on: ubuntu-latest + steps: + - name: Setup repo + uses: actions/checkout@v7 + with: + fetch-depth: 0 + persist-credentials: false + + - uses: denoland/setup-deno@v2 + with: + deno-version: v2.x + + - name: Create coverage files + run: deno task coverage + + - name: Collect coverage + uses: codecov/codecov-action@v7 # upload the report on Codecov + with: + files: ./test/cov_profile/lcov.info diff --git a/.gitignore b/.gitignore index c21fb20..1711e84 100644 --- a/.gitignore +++ b/.gitignore @@ -20,5 +20,10 @@ package-lock.json # Output of 'npm pack' *.tgz +# Test coverage +test/coverage +test/cov_profile +coverage.lcov + # Build output out/ diff --git a/deno.jsonc b/deno.jsonc index b2be2d5..979a550 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,10 +1,20 @@ { "lock": false, + "tasks": { + "ok": "deno fmt --check && deno lint && deno check && deno test", + "clean": "git clean -fX out test/cov_profile test/coverage coverage.lcov", + "coverage": "deno task clean && deno test --coverage=./test/cov_profile && echo 'Point your browser to test/cov_profile/html/index.html to see the test coverage report.'" + }, "fmt": { "indentWidth": 4, "proseWrap": "preserve" }, - "exclude": ["./node_modules/", "./out/", "./package-lock.json"], + "exclude": [ + "./node_modules/", + "./out/", + "./package-lock.json", + "./test/cov_profile" + ], "imports": { "@std/assert": "jsr:@std/assert@^1.0.19" }