|
| 1 | +name: CI/CD Pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + pull_request: |
| 7 | + branches: [ master ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: Test & Build |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + node-version: [18, 20, 22] |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Setup Node.js ${{ matrix.node-version }} |
| 23 | + uses: actions/setup-node@v4 |
| 24 | + with: |
| 25 | + node-version: ${{ matrix.node-version }} |
| 26 | + cache: 'npm' |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: npm ci |
| 30 | + |
| 31 | + - name: Run type checking |
| 32 | + run: npm run type-check |
| 33 | + |
| 34 | + - name: Run tests |
| 35 | + run: npm run test:run |
| 36 | + |
| 37 | + - name: Run tests with coverage |
| 38 | + run: npm run test:coverage |
| 39 | + |
| 40 | + - name: Upload coverage to Codecov |
| 41 | + if: matrix.node-version == 20 |
| 42 | + uses: codecov/codecov-action@v4 |
| 43 | + with: |
| 44 | + file: ./coverage/lcov.info |
| 45 | + flags: unittests |
| 46 | + name: codecov-umbrella |
| 47 | + fail_ci_if_error: false |
| 48 | + |
| 49 | + - name: Build library |
| 50 | + run: npm run build-only |
| 51 | + |
| 52 | + - name: Build documentation |
| 53 | + run: npm run docs:build |
| 54 | + continue-on-error: true |
| 55 | + |
| 56 | + - name: Check for build artifacts |
| 57 | + run: | |
| 58 | + ls -la dist/ |
| 59 | + test -f dist/vuejs-tour.js |
| 60 | + test -f dist/vuejs-tour.umd.cjs |
| 61 | + test -f dist/vuejs-tour.d.ts |
| 62 | + test -f dist/style.css |
| 63 | +
|
| 64 | + lint: |
| 65 | + name: Lint & Format Check |
| 66 | + runs-on: ubuntu-latest |
| 67 | + |
| 68 | + steps: |
| 69 | + - name: Checkout code |
| 70 | + uses: actions/checkout@v4 |
| 71 | + |
| 72 | + - name: Setup Node.js |
| 73 | + uses: actions/setup-node@v4 |
| 74 | + with: |
| 75 | + node-version: 20 |
| 76 | + cache: 'npm' |
| 77 | + |
| 78 | + - name: Install dependencies |
| 79 | + run: npm ci |
| 80 | + |
| 81 | + - name: Run linting |
| 82 | + run: npm run lint |
| 83 | + |
| 84 | + - name: Check code formatting |
| 85 | + run: | |
| 86 | + npm run format |
| 87 | + git diff --exit-code || (echo "Code is not formatted. Run 'npm run format' to fix." && exit 1) |
| 88 | +
|
| 89 | + security: |
| 90 | + name: Security Audit |
| 91 | + runs-on: ubuntu-latest |
| 92 | + |
| 93 | + steps: |
| 94 | + - name: Checkout code |
| 95 | + uses: actions/checkout@v4 |
| 96 | + |
| 97 | + - name: Setup Node.js |
| 98 | + uses: actions/setup-node@v4 |
| 99 | + with: |
| 100 | + node-version: 20 |
| 101 | + cache: 'npm' |
| 102 | + |
| 103 | + - name: Install dependencies |
| 104 | + run: npm ci |
| 105 | + |
| 106 | + - name: Run security audit |
| 107 | + run: npm audit --audit-level=moderate |
| 108 | + |
| 109 | + publish-coverage: |
| 110 | + name: Publish Test Coverage |
| 111 | + runs-on: ubuntu-latest |
| 112 | + needs: [test] |
| 113 | + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' |
| 114 | + |
| 115 | + steps: |
| 116 | + - name: Checkout code |
| 117 | + uses: actions/checkout@v4 |
| 118 | + |
| 119 | + - name: Setup Node.js |
| 120 | + uses: actions/setup-node@v4 |
| 121 | + with: |
| 122 | + node-version: 20 |
| 123 | + cache: 'npm' |
| 124 | + |
| 125 | + - name: Install dependencies |
| 126 | + run: npm ci |
| 127 | + |
| 128 | + - name: Generate coverage report |
| 129 | + run: npm run test:coverage |
| 130 | + |
| 131 | + - name: Generate coverage badge |
| 132 | + uses: jaywcjlove/coverage-badges-cli@main |
| 133 | + with: |
| 134 | + source: coverage/coverage-summary.json |
| 135 | + output: coverage/badges.svg |
| 136 | + |
| 137 | + - name: Upload coverage reports |
| 138 | + uses: actions/upload-artifact@v4 |
| 139 | + with: |
| 140 | + name: coverage-reports |
| 141 | + path: | |
| 142 | + coverage/ |
| 143 | + !coverage/tmp/ |
| 144 | + retention-days: 30 |
0 commit comments