|
| 1 | +# This workflow will build PRs submitted to the main branch. |
| 2 | + |
| 3 | +name: 👷♂️ PR Builder |
| 4 | + |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + paths-ignore: |
| 9 | + - '**/*.md' |
| 10 | + - 'LICENSE' |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +# Avoid running multiple builds for the same PR. |
| 14 | +concurrency: |
| 15 | + group: pr-builder-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +env: |
| 19 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 20 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 21 | + |
| 22 | +jobs: |
| 23 | + lint: |
| 24 | + name: 🌳 ESLint (STATIC ANALYSIS) |
| 25 | + runs-on: ubuntu-latest |
| 26 | + strategy: |
| 27 | + matrix: |
| 28 | + node-version: [lts/*] |
| 29 | + pnpm-version: [latest] |
| 30 | + steps: |
| 31 | + - name: ⬇️ Checkout |
| 32 | + id: checkout |
| 33 | + uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + fetch-depth: 0 |
| 36 | + |
| 37 | + - name: 🥡 Setup pnpm |
| 38 | + id: setup-pnpm |
| 39 | + uses: pnpm/action-setup@v4 |
| 40 | + with: |
| 41 | + version: ${{ matrix.pnpm-version }} |
| 42 | + run_install: false |
| 43 | + |
| 44 | + - name: 🟢 Setup node |
| 45 | + id: setup-node |
| 46 | + uses: actions/setup-node@v4 |
| 47 | + with: |
| 48 | + node-version: ${{ matrix.node-version }} |
| 49 | + cache: 'pnpm' |
| 50 | + |
| 51 | + - name: 🐳 Set SHAs for Nx |
| 52 | + id: set-shas |
| 53 | + uses: nrwl/nx-set-shas@v3 |
| 54 | + with: |
| 55 | + main-branch-name: 'main' |
| 56 | + |
| 57 | + - name: 🎈 Get pnpm store directory |
| 58 | + id: get-pnpm-cache-dir |
| 59 | + run: | |
| 60 | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" |
| 61 | +
|
| 62 | + - name: 🔆 Cache pnpm modules |
| 63 | + uses: actions/cache@v3 |
| 64 | + id: pnpm-cache |
| 65 | + with: |
| 66 | + path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }} |
| 67 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 68 | + restore-keys: | |
| 69 | + ${{ runner.os }}-pnpm-store- |
| 70 | +
|
| 71 | + - name: 🧩 Install Dependencies |
| 72 | + id: install-dependencies |
| 73 | + run: | |
| 74 | + pwd |
| 75 | + ls -l |
| 76 | + tree -L 1 |
| 77 | + ls -l pnpm-lock.yaml |
| 78 | + pnpm store prune |
| 79 | + pnpm install |
| 80 | +
|
| 81 | + - name: 🏗️ Build Project |
| 82 | + id: build |
| 83 | + run: pnpm build |
| 84 | + |
| 85 | + - name: 🌳 Lint ES Files |
| 86 | + id: lint-with-eslint |
| 87 | + run: pnpm nx affected --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} --target=lint:es --parallel=3 |
| 88 | + |
| 89 | + - name: 💅 Lint Styles |
| 90 | + id: lint-with-stylelint |
| 91 | + run: | |
| 92 | + pnpm nx affected --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} --target=lint:styles --parallel=3 |
| 93 | +
|
| 94 | + typecheck: |
| 95 | + name: ʦ Typecheck (STATIC ANALYSIS) |
| 96 | + runs-on: ubuntu-latest |
| 97 | + strategy: |
| 98 | + matrix: |
| 99 | + node-version: [lts/*] |
| 100 | + pnpm-version: [latest] |
| 101 | + steps: |
| 102 | + - name: ⬇️ Checkout |
| 103 | + id: checkout |
| 104 | + uses: actions/checkout@v4 |
| 105 | + with: |
| 106 | + fetch-depth: 0 |
| 107 | + |
| 108 | + - name: 🥡 Setup pnpm |
| 109 | + id: setup-pnpm |
| 110 | + uses: pnpm/action-setup@v4 |
| 111 | + with: |
| 112 | + version: ${{ matrix.pnpm-version }} |
| 113 | + run_install: false |
| 114 | + |
| 115 | + - name: 🟢 Setup node |
| 116 | + id: setup-node |
| 117 | + uses: actions/setup-node@v4 |
| 118 | + with: |
| 119 | + node-version: ${{ matrix.node-version }} |
| 120 | + cache: 'pnpm' |
| 121 | + |
| 122 | + - name: 🐳 Set SHAs for Nx |
| 123 | + id: set-shas |
| 124 | + uses: nrwl/nx-set-shas@v3 |
| 125 | + with: |
| 126 | + main-branch-name: 'main' |
| 127 | + |
| 128 | + - name: 🎈 Get pnpm store directory |
| 129 | + id: get-pnpm-cache-dir |
| 130 | + run: | |
| 131 | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" |
| 132 | +
|
| 133 | + - name: 🔆 Cache pnpm modules |
| 134 | + uses: actions/cache@v3 |
| 135 | + id: pnpm-cache |
| 136 | + with: |
| 137 | + path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }} |
| 138 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 139 | + restore-keys: | |
| 140 | + ${{ runner.os }}-pnpm-store- |
| 141 | +
|
| 142 | + - name: 🧩 Install Dependencies |
| 143 | + id: install-dependencies |
| 144 | + run: pnpm install |
| 145 | + |
| 146 | + - name: 🏗️ Build Project |
| 147 | + id: build |
| 148 | + run: pnpm build |
| 149 | + |
| 150 | + - name: ☄️ Check Type Errors |
| 151 | + run: pnpm nx affected --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} --target=typecheck --parallel=3 |
| 152 | + |
| 153 | + test: |
| 154 | + name: 👾 Unit Tests |
| 155 | + needs: [lint, typecheck] |
| 156 | + runs-on: ubuntu-latest |
| 157 | + strategy: |
| 158 | + matrix: |
| 159 | + node-version: [lts/*] |
| 160 | + pnpm-version: [latest] |
| 161 | + steps: |
| 162 | + - name: ⬇️ Checkout |
| 163 | + id: checkout |
| 164 | + uses: actions/checkout@v4 |
| 165 | + with: |
| 166 | + fetch-depth: 0 |
| 167 | + |
| 168 | + - name: 🥡 Setup pnpm |
| 169 | + id: setup-pnpm |
| 170 | + uses: pnpm/action-setup@v4 |
| 171 | + with: |
| 172 | + version: ${{ matrix.pnpm-version }} |
| 173 | + run_install: false |
| 174 | + |
| 175 | + - name: 🟢 Setup node |
| 176 | + id: setup-node |
| 177 | + uses: actions/setup-node@v4 |
| 178 | + with: |
| 179 | + node-version: ${{ matrix.node-version }} |
| 180 | + cache: 'pnpm' |
| 181 | + |
| 182 | + - name: 🎈 Get pnpm store directory |
| 183 | + id: get-pnpm-cache-dir |
| 184 | + run: | |
| 185 | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" |
| 186 | +
|
| 187 | + - name: 🔆 Cache pnpm modules |
| 188 | + uses: actions/cache@v3 |
| 189 | + id: pnpm-cache |
| 190 | + with: |
| 191 | + path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }} |
| 192 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 193 | + restore-keys: | |
| 194 | + ${{ runner.os }}-pnpm-store- |
| 195 | +
|
| 196 | + - name: 🧩 Install Dependencies |
| 197 | + id: install-dependencies |
| 198 | + run: pnpm install |
| 199 | + |
| 200 | + - name: 🏗️ Build Project |
| 201 | + id: build |
| 202 | + run: pnpm build |
| 203 | + |
| 204 | + - name: 🃏 Run Unit Tests |
| 205 | + id: run-tests |
| 206 | + run: pnpm test |
| 207 | + |
| 208 | + - name: Upload `@asgardeo/mcp-node` coverage reports to Codecov |
| 209 | + id: upload-asgardeo-mcp-node-coverage |
| 210 | + uses: codecov/codecov-action@v4 |
| 211 | + with: |
| 212 | + token: ${{ env.CODECOV_TOKEN }} |
| 213 | + files: ./packages/mcp-node/coverage/coverage-final.json |
| 214 | + flags: '@asgardeo/mcp-node' |
| 215 | + verbose: true |
| 216 | + |
| 217 | + - name: Upload `@asgardeo/mcp-express` coverage reports to Codecov |
| 218 | + id: upload-asgardeo-mcp-express-coverage |
| 219 | + uses: codecov/codecov-action@v4 |
| 220 | + with: |
| 221 | + token: ${{ env.CODECOV_TOKEN }} |
| 222 | + files: ./packages/mcp-express/coverage/coverage-final.json |
| 223 | + flags: '@asgardeo/mcp-express' |
| 224 | + verbose: true |
| 225 | + |
| 226 | + build: |
| 227 | + name: 🚧 Build |
| 228 | + needs: [lint, typecheck, test] |
| 229 | + runs-on: ubuntu-latest |
| 230 | + strategy: |
| 231 | + matrix: |
| 232 | + node-version: [lts/*] |
| 233 | + pnpm-version: [latest] |
| 234 | + steps: |
| 235 | + - name: ⬇️ Checkout |
| 236 | + id: checkout |
| 237 | + uses: actions/checkout@v4 |
| 238 | + |
| 239 | + - name: 🥡 Setup pnpm |
| 240 | + id: setup-pnpm |
| 241 | + uses: pnpm/action-setup@v4 |
| 242 | + with: |
| 243 | + version: ${{ matrix.pnpm-version }} |
| 244 | + run_install: false |
| 245 | + |
| 246 | + - name: 🟢 Setup node |
| 247 | + id: setup-node |
| 248 | + uses: actions/setup-node@v4 |
| 249 | + with: |
| 250 | + node-version: ${{ matrix.node-version }} |
| 251 | + cache: 'pnpm' |
| 252 | + |
| 253 | + - name: 🎈 Get pnpm store directory |
| 254 | + id: get-pnpm-cache-dir |
| 255 | + run: | |
| 256 | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" |
| 257 | +
|
| 258 | + - name: 🔆 Cache pnpm modules |
| 259 | + uses: actions/cache@v3 |
| 260 | + id: pnpm-cache |
| 261 | + with: |
| 262 | + path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }} |
| 263 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 264 | + restore-keys: | |
| 265 | + ${{ runner.os }}-pnpm-store- |
| 266 | +
|
| 267 | + - name: 🧩 Install Dependencies |
| 268 | + id: install-dependencies |
| 269 | + run: pnpm install |
| 270 | + |
| 271 | + - name: 🏗️ Build Project |
| 272 | + id: build |
| 273 | + run: pnpm build |
0 commit comments