From 17ab7ae3fa714cf46d6ef1b8ea0753bd02e8895c Mon Sep 17 00:00:00 2001 From: hustcer Date: Fri, 14 Feb 2025 23:50:46 +0800 Subject: [PATCH] chore: Try to add tests workflow and some common tests (#125) --- .github/workflows/tests.yml | 60 +++++++++++++++++++++++++++++++++++++ tests/test-common.nu | 20 +++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 .github/workflows/tests.yml create mode 100644 tests/test-common.nu diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..9a216ff --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,60 @@ +# Description: This workflow runs tests for hustcer/deepseek-review. +# REF: +# - https://github.com/vyadh/nutest/blob/main/.github/workflows/tests.yaml + +name: Tests + +on: + pull_request: + workflow_dispatch: + push: + branches: + - main + schedule: + - cron: '0 7 * * *' # Run every morning at 7am UTC + +permissions: + contents: read + +jobs: + nutest-tests: + name: Run Tests + + permissions: + checks: write + + strategy: + fail-fast: true + matrix: + version: ['*', nightly] # Earliest supported, latest and nightly + platform: [ubuntu-latest, windows-latest, macos-latest] + + runs-on: ${{ matrix.platform }} + + steps: + - uses: actions/checkout@v4 + + - name: Checkout Nutest Repo + uses: actions/checkout@v4 + with: + ref: v1.0.1 + path: nutest + repository: vyadh/nutest + sparse-checkout: nutest/ + + - name: Setup Nu + uses: hustcer/setup-nu@v3 + with: + version: ${{ matrix.version }} + + - name: Test Deepseek Review + shell: nu {0} + run: | + use ${{ github.workspace }}/nutest/nutest + ( + nutest run-tests + --fail + --display terminal + --report { type: junit, path: test-report.xml } + --returns summary | to json | save --force test-summary.json + ) diff --git a/tests/test-common.nu b/tests/test-common.nu new file mode 100644 index 000000000..f2d2279 --- /dev/null +++ b/tests/test-common.nu @@ -0,0 +1,20 @@ + +use std/assert + +use ../nu/common.nu [compare-ver] + +#[test] +def 'v1.0.0 is greater than v0.1.0' [] { + assert equal (compare-ver 1.0.0 0.1.0) 1 + assert equal (compare-ver v1.0.0 v0.1.0) 1 +} + +#[test] +def 'v1.0.1 is equal to v1.0.1' [] { + assert equal (compare-ver 1.0.1 1.0.1) 0 +} + +#[test] +def 'v1.0.1 is lower than v1.1.0' [] { + assert equal (compare-ver 1.0.1 1.1.0) (-1) +}