Merge pull request #175 from vitruv-tools/Zip-download #257
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Frontend CI | |
| on: | |
| # Run on push and PRs to main and develop | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| pull_request: | |
| branches: | |
| - main | |
| - develop | |
| workflow_dispatch: | |
| jobs: | |
| build-and-test: | |
| name: Build and Test Frontend | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' # or 18, 16 — match your frontend version | |
| - name: Cache node_modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests | |
| run: npm test # or `npm run test` — adjust to your test command | |
| - name: Build frontend | |
| run: npm run build | |
| - name: Upload production build (optional) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: frontend-build | |
| path: dist/ # or your build output dir | |
| sonarcloud: | |
| name: SonarCloud Analysis | |
| runs-on: ubuntu-latest | |
| needs: build-and-test | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests with coverage | |
| run: npm test -- --coverage | |
| - name: Run SonarCloud scanner | |
| run: | | |
| npm install -g sonarqube-scanner | |
| npx sonar-scanner -Dsonar.login=${{ secrets.SONAR_TOKEN }} | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |