|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + types: [ opened, synchronize, reopened, edited ] |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + checks: write |
| 13 | + pull-requests: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + test: |
| 17 | + name: Test Node.js ${{ matrix.node-version }} |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + node-version: [18.x, 20.x, 22.x] |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout code |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Setup Node.js ${{ matrix.node-version }} |
| 29 | + uses: actions/setup-node@v4 |
| 30 | + with: |
| 31 | + node-version: ${{ matrix.node-version }} |
| 32 | + cache: 'npm' |
| 33 | + |
| 34 | + - name: Install just |
| 35 | + uses: extractions/setup-just@v2 |
| 36 | + |
| 37 | + - name: Install dependencies |
| 38 | + run: just install |
| 39 | + |
| 40 | + - name: Run type check |
| 41 | + run: just typecheck |
| 42 | + |
| 43 | + - name: Run linter |
| 44 | + run: just lint |
| 45 | + |
| 46 | + - name: Run tests with coverage |
| 47 | + run: just test-coverage |
| 48 | + |
| 49 | + - name: Upload coverage to Codecov |
| 50 | + if: matrix.node-version == '20.x' && github.repository == 'jacobboykin/amazing-marvin-client-javascript' |
| 51 | + uses: codecov/codecov-action@v4 |
| 52 | + with: |
| 53 | + files: ./coverage/lcov.info |
| 54 | + fail_ci_if_error: false |
| 55 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 56 | + continue-on-error: true |
| 57 | + |
| 58 | + - name: Build project |
| 59 | + run: just build |
| 60 | + |
| 61 | + - name: Test package installation |
| 62 | + if: matrix.node-version == '20.x' |
| 63 | + run: | |
| 64 | + npm pack |
| 65 | + npm install -g ./jacobboykin-amazing-marvin-client-*.tgz |
| 66 | + node -e "console.log('Package installed successfully')" |
| 67 | +
|
| 68 | + commitlint: |
| 69 | + name: Validate commit messages |
| 70 | + runs-on: ubuntu-latest |
| 71 | + if: github.event_name == 'pull_request' |
| 72 | + |
| 73 | + steps: |
| 74 | + - name: Checkout code |
| 75 | + uses: actions/checkout@v4 |
| 76 | + with: |
| 77 | + fetch-depth: 0 |
| 78 | + |
| 79 | + - name: Setup Node.js |
| 80 | + uses: actions/setup-node@v4 |
| 81 | + with: |
| 82 | + node-version: '20.x' |
| 83 | + cache: 'npm' |
| 84 | + |
| 85 | + - name: Install just |
| 86 | + uses: extractions/setup-just@v2 |
| 87 | + |
| 88 | + - name: Install dependencies |
| 89 | + run: just install |
| 90 | + |
| 91 | + - name: Validate PR title |
| 92 | + run: echo "${{ github.event.pull_request.title }}" | npx commitlint --verbose |
| 93 | + |
| 94 | + security: |
| 95 | + name: Security audit |
| 96 | + runs-on: ubuntu-latest |
| 97 | + |
| 98 | + steps: |
| 99 | + - name: Checkout code |
| 100 | + uses: actions/checkout@v4 |
| 101 | + |
| 102 | + - name: Setup Node.js |
| 103 | + uses: actions/setup-node@v4 |
| 104 | + with: |
| 105 | + node-version: '20.x' |
| 106 | + cache: 'npm' |
| 107 | + |
| 108 | + - name: Install just |
| 109 | + uses: extractions/setup-just@v2 |
| 110 | + |
| 111 | + - name: Install dependencies |
| 112 | + run: just install |
| 113 | + |
| 114 | + - name: Run security audit |
| 115 | + run: just audit |
| 116 | + |
| 117 | + - name: Check for known vulnerabilities |
| 118 | + run: npx audit-ci --config .audit-ci.json || true |
| 119 | + |
| 120 | + release: |
| 121 | + name: Release |
| 122 | + runs-on: ubuntu-latest |
| 123 | + needs: [test, security] |
| 124 | + if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
| 125 | + |
| 126 | + permissions: |
| 127 | + contents: write |
| 128 | + issues: write |
| 129 | + pull-requests: write |
| 130 | + id-token: write |
| 131 | + packages: write |
| 132 | + |
| 133 | + steps: |
| 134 | + - name: Checkout code |
| 135 | + uses: actions/checkout@v4 |
| 136 | + with: |
| 137 | + fetch-depth: 0 |
| 138 | + persist-credentials: false |
| 139 | + |
| 140 | + - name: Setup Node.js |
| 141 | + uses: actions/setup-node@v4 |
| 142 | + with: |
| 143 | + node-version: '20.x' |
| 144 | + cache: 'npm' |
| 145 | + registry-url: 'https://npm.pkg.github.com' |
| 146 | + scope: '@jacobboykin' |
| 147 | + |
| 148 | + - name: Install just |
| 149 | + uses: extractions/setup-just@v2 |
| 150 | + |
| 151 | + - name: Install dependencies |
| 152 | + run: just install |
| 153 | + |
| 154 | + - name: Run full CI pipeline |
| 155 | + run: just ci |
| 156 | + |
| 157 | + - name: Release |
| 158 | + env: |
| 159 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 160 | + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 161 | + run: npx semantic-release |
0 commit comments