Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add node testing workflow #642

Merged
merged 1 commit into from Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/node-test.yml
@@ -0,0 +1,65 @@
name: Node tests

on:
pull_request:
push:
branches:
- main
- master
- stable*

permissions:
contents: read

concurrency:
group: node-tests-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
id: versions
with:
fallbackNode: '^20'
fallbackNpm: '^9'

- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}

- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"

- name: Install dependencies & build
run: |
npm ci
npm run build --if-present

- name: Test
run: npm run test --if-present

- name: Test and process coverage
run: npm run test:coverage --if-present

- name: Collect coverage
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
with:
files: ./coverage/lcov.info

summary:
runs-on: ubuntu-latest
needs: test
if: always()

name: test-summary
steps:
- name: Summary status
run: if ${{ needs.test.result != 'success' && needs.test.result != 'skipped' }}; then exit 1; fi
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -25,7 +25,8 @@
"lint": "eslint .",
"lint:fix": "eslint --fix lib tests",
"test": "jest --verbose",
"test:watch": "jest --watchAll"
"test:watch": "jest --watchAll",
"test:coverage": "jest --coverage"
},
"keywords": [
"nextcloud"
Expand Down