Skip to content

Commit

Permalink
feat(CI): Check code coverage of PHP and frontend code
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jul 12, 2023
1 parent 8e6acbf commit b0d5c79
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 7 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/node-test.yml
Original file line number Diff line number Diff line change
@@ -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@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3.7.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
11 changes: 10 additions & 1 deletion .github/workflows/phpunit-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
php-version: ${{ matrix.php-versions }}
# https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
coverage: none
coverage: xdebug
ini-file: development
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -103,6 +103,15 @@ jobs:
working-directory: apps/${{ env.APP_NAME }}
run: composer run test:unit

- name: Upload PHPUnit code coverage
if: steps.check_phpunit.outcome == 'success'
uses: codecov/codecov-action@v3
with:
root_dir: ./apps/${{ env.APP_NAME }}
files: ./apps/${{ env.APP_NAME }}/tests/clover.unit.xml
fail_ci_if_error: true
flags: unit

- name: Check PHPUnit integration script is defined
id: check_integration
continue-on-error: true
Expand Down
13 changes: 10 additions & 3 deletions tests/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="./clover.xml"/>
</logging>
<coverage>
<!-- filters for code coverage -->
<include>
<directory suffix=".php">../lib</directory>
</include>
<report>
<!-- and this is where your report will be written -->
<clover outputFile="./clover.unit.xml"/>
</report>
</coverage>
</phpunit>
6 changes: 3 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createAppConfig } from '@susnux/nextcloud-vite-config'
import type { UserConfig } from 'vite';
import type { UserConfig } from 'vite'

const config = createAppConfig({
main: 'src/index.ts',
main: 'src/index.ts',
}) as UserConfig

export default config
export default config

0 comments on commit b0d5c79

Please sign in to comment.