diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index f39b8de..699972d 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -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:password1@127.0.0.1:${{ job.services.mariadb.ports['3306'] }}/auto_entreprise_test" + DIRECTORY: ./backend services: - mariadb_test: + mariadb: image: mariadb:10.9 env: MYSQL_ROOT_PASSWORD: secret @@ -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' @@ -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/codecov-action@v4.0.1 + with: + file: ${{ format('{0}/coverage.xml', env.DIRECTORY) }} + flags: backend + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 2a0b3cc..8a6b719 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -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/codecov-action@v4.0.1 + with: + file: ${{ format('{0}/coverage/clover.xml', env.DIRECTORY) }} + flags: frontend + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/backend/composer.json b/backend/composer.json index bab2426..677dfed 100644 --- a/backend/composer.json +++ b/backend/composer.json @@ -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" diff --git a/frontend/package.json b/frontend/package.json index 489c4c3..7226cac 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -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", @@ -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", @@ -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" } } diff --git a/frontend/vitest.config.ts b/frontend/vitest.config.ts index 10067d5..e21b7dc 100644 --- a/frontend/vitest.config.ts +++ b/frontend/vitest.config.ts @@ -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'] + } } }) )