Skip to content

Commit

Permalink
chore: add codecov workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mp3000mp committed Apr 27, 2024
1 parent 0a7d32f commit c3fc63f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 65 deletions.
70 changes: 30 additions & 40 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,20 @@
name: backend
on:
push:
branches: [ "main" ]
branches: [ "master" ]
pull_request:
branches: [ "main" ]
branches: [ "master" ]

jobs:
lint:
lint-and-tests:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
working-directory: ./backend
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: ctype, iconv, mbstring, mysql
tools: composer:v2
coverage: none

- name: Install Dependencies
working-directory: ./backend
run: composer install -q --no-ansi --no-interaction --no-suggest --no-scripts --no-progress --prefer-dist

- name: PHP cs fixer
working-directory: ./backend
run: composer cs

- name: PHPStan
working-directory: ./backend
run: composer ps

tests:
runs-on: ubuntu-latest
needs: [lint]
env:
DATABASE_URL: "mysql://user1:[email protected]:${{ job.services.mariadb.ports['3306'] }}/auto_entreprise_test"
DIRECTORY: ./backend

services:
mariadb_test:
mariadb:
image: mariadb:10.9
env:
MYSQL_ROOT_PASSWORD: secret
Expand All @@ -52,10 +27,10 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
working-directory: ./backend
working-directory: ${{ env.DIRECTORY }}
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
Expand All @@ -64,17 +39,32 @@ jobs:
coverage: xdebug

- name: Install Dependencies
working-directory: ./backend
run: composer install -q --no-ansi --no-interaction --no-suggest --no-scripts --no-progress --prefer-dist
working-directory: ${{ env.DIRECTORY }}
run: composer install -q --no-ansi --no-interaction --no-suggest --no-scripts --no-progress --prefer-dist --optimize-autoloader

- name: PHP cs fixer
working-directory: ${{ env.DIRECTORY }}
run: composer cs

- name: PHPStan
working-directory: ${{ env.DIRECTORY }}
run: composer ps

- name: Create database
working-directory: ./backend
working-directory: ${{ env.DIRECTORY }}
run: php bin/console doc:database:create --no-interaction -e test

- name: Migrate database
working-directory: ./backend
working-directory: ${{ env.DIRECTORY }}
run: php bin/console doc:mig:mig --no-interaction -e test

- name: Exec tests
working-directory: ./backend
run: composer tuc
working-directory: ${{ env.DIRECTORY }}
run: composer tuci

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
file: ${{ format('{0}/coverage.xml', env.DIRECTORY) }}
flags: backend
token: ${{ secrets.CODECOV_TOKEN }}
49 changes: 26 additions & 23 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
name: frontend
on:
push:
branches: [ "main" ]
branches: [ "master" ]
pull_request:
branches: [ "main" ]
branches: [ "master" ]

jobs:
lint-tests:
lint-and-tests:
runs-on: ubuntu-latest

env:
DIRECTORY: ./frontend

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Install dependencies
working-directory: ./frontend
working-directory: ${{ env.DIRECTORY }}
run: npm ci

- name: Run prettier
working-directory: ./frontend
- name: Run format
working-directory: ${{ env.DIRECTORY }}
run: npm run format
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run eslint
working-directory: ./frontend
- name: Run lint
working-directory: ${{ env.DIRECTORY }}
run: npm run lint
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run jest
working-directory: ./frontend
- name: Run tests
working-directory: ${{ env.DIRECTORY }}
run: npm run test:cov
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run jest e2e
working-directory: ./frontend
run: npm run test:e2e
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
file: ${{ format('{0}/coverage/clover.xml', env.DIRECTORY) }}
flags: frontend
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions backend/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"ps": "phpstan analyse -c phpstan.dist.neon",
"tu": "bin/phpunit --testdox",
"tuc": "bin/phpunit --testdox --coverage-html coverage",
"tuci": "bin/phpunit --testdox --coverage-clover ./coverage.xml",
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
Expand Down
4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "run-p type-check \"build-only {@}\" --",
"preview": "vite preview",
"test:unit": "vitest",
"test:cov": "vitest run --coverage",
"test:e2e": "playwright test",
"build-only": "vite build",
"type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
Expand Down Expand Up @@ -37,6 +38,7 @@
"@types/jsdom": "^21.1.3",
"@types/node": "^18.17.17",
"@vitejs/plugin-vue": "^4.3.4",
"@vitest/coverage-v8": "^1.5.2",
"@vue/eslint-config-prettier": "^8.0.0",
"@vue/eslint-config-typescript": "^12.0.0",
"@vue/test-utils": "^2.4.1",
Expand All @@ -49,7 +51,7 @@
"sass": "^1.68.0",
"typescript": "~5.2.0",
"vite": "^4.4.9",
"vitest": "^0.34.4",
"vitest": "^1.5.2",
"vue-tsc": "^1.8.11"
}
}
5 changes: 4 additions & 1 deletion frontend/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export default mergeConfig(
test: {
environment: 'jsdom',
exclude: [...configDefaults.exclude, 'e2e/*'],
root: fileURLToPath(new URL('./', import.meta.url))
root: fileURLToPath(new URL('./', import.meta.url)),
coverage: {
reporter: ['clover']
}
}
})
)

0 comments on commit c3fc63f

Please sign in to comment.