|
| 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 | + |
| 21 | +jobs: |
| 22 | + lint: |
| 23 | + name: ⬣ ESLint (STATIC ANALYSIS) |
| 24 | + runs-on: ubuntu-latest |
| 25 | + strategy: |
| 26 | + matrix: |
| 27 | + node-version: [lts/*] |
| 28 | + pnpm-version: [latest] |
| 29 | + steps: |
| 30 | + - name: ⬇️ Checkout |
| 31 | + id: checkout |
| 32 | + |
| 33 | + with: |
| 34 | + # We need to fetch all branches and commits so that Nx affected has a base to compare against. |
| 35 | + fetch-depth: 0 |
| 36 | + |
| 37 | + - name: 🟢 Setup node |
| 38 | + id: setup-node |
| 39 | + uses: actions/setup-node@v2 |
| 40 | + with: |
| 41 | + node-version: ${{ matrix.node-version }} |
| 42 | + |
| 43 | + - name: 🐳 Set SHAs for Nx |
| 44 | + id: set-shas |
| 45 | + uses: nrwl/nx-set-shas@v3 |
| 46 | + with: |
| 47 | + main-branch-name: "main" |
| 48 | + |
| 49 | + - name: 🥡 Setup pnpm |
| 50 | + id: setup-pnpm |
| 51 | + |
| 52 | + with: |
| 53 | + version: ${{ matrix.pnpm-version }} |
| 54 | + run_install: false |
| 55 | + |
| 56 | + - name: 🎈 Get pnpm store directory |
| 57 | + id: get-pnpm-cache-dir |
| 58 | + run: | |
| 59 | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" |
| 60 | +
|
| 61 | + - name: 🔆 Cache pnpm modules |
| 62 | + uses: actions/cache@v3 |
| 63 | + id: pnpm-cache |
| 64 | + with: |
| 65 | + path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }} |
| 66 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 67 | + restore-keys: | |
| 68 | + ${{ runner.os }}-pnpm-store- |
| 69 | +
|
| 70 | + - name: 🧩 Install Dependencies |
| 71 | + id: install-dependencies |
| 72 | + run: pnpm install |
| 73 | + |
| 74 | + - name: 🦄 Lint All Files |
| 75 | + id: lint-with-eslint |
| 76 | + run: pnpm nx affected --target=lint --parallel=3 --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} |
| 77 | + |
| 78 | + typecheck: |
| 79 | + name: ʦ Typecheck (STATIC ANALYSIS) |
| 80 | + runs-on: ubuntu-latest |
| 81 | + strategy: |
| 82 | + matrix: |
| 83 | + node-version: [lts/*] |
| 84 | + pnpm-version: [latest] |
| 85 | + steps: |
| 86 | + - name: ⬇️ Checkout |
| 87 | + id: checkout |
| 88 | + |
| 89 | + with: |
| 90 | + # We need to fetch all branches and commits so that Nx affected has a base to compare against. |
| 91 | + fetch-depth: 0 |
| 92 | + |
| 93 | + - name: 🟢 Setup node |
| 94 | + id: setup-node |
| 95 | + uses: actions/setup-node@v2 |
| 96 | + with: |
| 97 | + node-version: ${{ matrix.node-version }} |
| 98 | + |
| 99 | + - name: 🐳 Set SHAs for Nx |
| 100 | + id: set-shas |
| 101 | + uses: nrwl/nx-set-shas@v3 |
| 102 | + with: |
| 103 | + main-branch-name: "main" |
| 104 | + |
| 105 | + - name: 🥡 Setup pnpm |
| 106 | + |
| 107 | + with: |
| 108 | + version: ${{ matrix.pnpm-version }} |
| 109 | + run_install: false |
| 110 | + |
| 111 | + - name: 🎈 Get pnpm store directory |
| 112 | + id: get-pnpm-cache-dir |
| 113 | + run: | |
| 114 | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" |
| 115 | +
|
| 116 | + - name: 🔆 Cache pnpm modules |
| 117 | + uses: actions/cache@v3 |
| 118 | + id: pnpm-cache |
| 119 | + with: |
| 120 | + path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }} |
| 121 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 122 | + restore-keys: | |
| 123 | + ${{ runner.os }}-pnpm-store- |
| 124 | +
|
| 125 | + - name: 🧩 Install Dependencies |
| 126 | + id: install-dependencies |
| 127 | + run: pnpm install |
| 128 | + |
| 129 | + - name: ☄️ Check Type Errors |
| 130 | + run: pnpm nx affected --target=typecheck --parallel=3 --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} |
| 131 | + |
| 132 | + test: |
| 133 | + name: 👾 Unit Test (TESTING) |
| 134 | + # needs: [lint, typecheck] |
| 135 | + runs-on: ubuntu-latest |
| 136 | + strategy: |
| 137 | + matrix: |
| 138 | + node-version: [lts/*] |
| 139 | + pnpm-version: [latest] |
| 140 | + steps: |
| 141 | + - name: ⬇️ Checkout |
| 142 | + id: checkout |
| 143 | + |
| 144 | + with: |
| 145 | + # We need to fetch all branches and commits so that Nx affected has a base to compare against. |
| 146 | + fetch-depth: 0 |
| 147 | + |
| 148 | + - name: 🟢 Setup node |
| 149 | + id: setup-node |
| 150 | + uses: actions/setup-node@v2 |
| 151 | + with: |
| 152 | + node-version: ${{ matrix.node-version }} |
| 153 | + |
| 154 | + - name: 🥡 Setup pnpm |
| 155 | + |
| 156 | + with: |
| 157 | + version: ${{ matrix.pnpm-version }} |
| 158 | + run_install: false |
| 159 | + |
| 160 | + - name: 🎈 Get pnpm store directory |
| 161 | + id: get-pnpm-cache-dir |
| 162 | + run: | |
| 163 | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" |
| 164 | +
|
| 165 | + - name: 🔆 Cache pnpm modules |
| 166 | + uses: actions/cache@v3 |
| 167 | + id: pnpm-cache |
| 168 | + with: |
| 169 | + path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }} |
| 170 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 171 | + restore-keys: | |
| 172 | + ${{ runner.os }}-pnpm-store- |
| 173 | +
|
| 174 | + - name: 🧩 Install Dependencies |
| 175 | + id: install-dependencies |
| 176 | + run: pnpm install |
| 177 | + |
| 178 | + - name: 🃏 Run Jest & Collect Coverage |
| 179 | + id: run-jest-test-and-coverage |
| 180 | + run: pnpm test:ci |
| 181 | + |
| 182 | + - name: Upload `@asgardeo/passport-asgardeo` coverage reports to Codecov |
| 183 | + id: upload-asgardeo-passport-coverage |
| 184 | + |
| 185 | + with: |
| 186 | + files: ./lib/coverage/coverage-final.json |
| 187 | + flags: '@asgardeo/passport-asgardeo' |
| 188 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 189 | + |
| 190 | + build: |
| 191 | + name: 🚧 Build |
| 192 | + # needs: [ lint, typecheck, test ] |
| 193 | + runs-on: ubuntu-latest |
| 194 | + strategy: |
| 195 | + matrix: |
| 196 | + node-version: [lts/*] |
| 197 | + pnpm-version: [latest] |
| 198 | + steps: |
| 199 | + - name: ⬇️ Checkout |
| 200 | + id: checkout |
| 201 | + |
| 202 | + |
| 203 | + - name: 🟢 Setup node |
| 204 | + id: setup-node |
| 205 | + uses: actions/setup-node@v2 |
| 206 | + with: |
| 207 | + node-version: ${{ matrix.node-version }} |
| 208 | + |
| 209 | + - name: 🥡 Setup pnpm |
| 210 | + |
| 211 | + with: |
| 212 | + version: ${{ matrix.pnpm-version }} |
| 213 | + run_install: false |
| 214 | + |
| 215 | + - name: 🎈 Get pnpm store directory |
| 216 | + id: get-pnpm-cache-dir |
| 217 | + run: | |
| 218 | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" |
| 219 | +
|
| 220 | + - name: 🔆 Cache pnpm modules |
| 221 | + uses: actions/cache@v3 |
| 222 | + id: pnpm-cache |
| 223 | + with: |
| 224 | + path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }} |
| 225 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 226 | + restore-keys: | |
| 227 | + ${{ runner.os }}-pnpm-store- |
| 228 | +
|
| 229 | + - name: 🧩 Install Dependencies |
| 230 | + id: install-dependencies |
| 231 | + run: pnpm install |
| 232 | + |
| 233 | + - name: 🏗️ Build |
| 234 | + id: build |
| 235 | + run: pnpm build |
0 commit comments