|
| 1 | +name: on-pull-request-or-push |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - development |
| 8 | + |
| 9 | +env: |
| 10 | + NX_BRANCH: ${{ github.event.number }} |
| 11 | + NX_RUN_GROUP: ${{ github.run_id }} |
| 12 | + NX_CLOUD_AUTH_TOKEN: ${{ secrets.NX_CLOUD_AUTH_TOKEN }} |
| 13 | + MOZ_HEALESS: 1 |
| 14 | + SAUCE_USERNAME_PR: valorkinpr |
| 15 | + SAUCE_ACCESS_KEY_PR: e0a97bd3-4b74-4408-89bf-cce1b44a8bf1 |
| 16 | + CYPRESS_CACHE_FOLDER: 'node_modules/.cypress' |
| 17 | + CYPRESS_RECORD_KEY: 4aa7a1c0-3a4f-444e-b324-6fc305a543a8 |
| 18 | + FIREBASE_CHANNEL: ${{ fromJSON('["", "live"]')[!github.base_ref] }} |
| 19 | + |
| 20 | + CACHE_NODE_MODULES_PATH: | |
| 21 | + ~/.npm |
| 22 | + node_modules |
| 23 | +
|
| 24 | + CACHE_DIST_PATH: dist |
| 25 | + |
| 26 | +jobs: |
| 27 | + # one run |
| 28 | + one_run: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - name: Cancel Previous Runs |
| 32 | + |
| 33 | + with: |
| 34 | + access_token: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + |
| 36 | + # install dependencies |
| 37 | + install: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + needs: one_run |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v2 |
| 42 | + - uses: actions/cache@v2 |
| 43 | + id: cache |
| 44 | + with: |
| 45 | + path: ${{ env.CACHE_NODE_MODULES_PATH }} |
| 46 | + key: node_modules-${{ hashFiles('**/package-lock.json') }} |
| 47 | + - run: npm ci |
| 48 | + if: steps.cache.outputs.cache-hit != 'true' |
| 49 | + |
| 50 | + # build ngx-bootstrap |
| 51 | + build: |
| 52 | + needs: install |
| 53 | + runs-on: ubuntu-latest |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v2 |
| 56 | + - uses: actions/cache@v2 |
| 57 | + with: |
| 58 | + path: ${{ env.CACHE_NODE_MODULES_PATH }} |
| 59 | + key: node_modules-${{ hashFiles('**/package-lock.json') }} |
| 60 | + - uses: actions/cache@v2 |
| 61 | + with: |
| 62 | + path: ${{ env.CACHE_DIST_PATH }} |
| 63 | + key: dist-${{ github.run_id }} |
| 64 | + - run: | |
| 65 | + npx nx build ngx-bootstrap --runner cloud --configuration production |
| 66 | + npx nx build --runner cloud --configuration production |
| 67 | +
|
| 68 | +
|
| 69 | + # run unit tests |
| 70 | + unit_tests_with_coverage: |
| 71 | + runs-on: ubuntu-latest |
| 72 | + needs: build |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v2 |
| 75 | + - uses: actions/cache@v2 |
| 76 | + with: |
| 77 | + path: ${{ env.CACHE_NODE_MODULES_PATH }} |
| 78 | + key: node_modules-${{ hashFiles('**/package-lock.json') }} |
| 79 | + - uses: actions/cache@v2 |
| 80 | + with: |
| 81 | + path: ${{ env.CACHE_DIST_PATH }} |
| 82 | + key: dist-${{ github.run_id }} |
| 83 | + - run: npm test -- --runner cloud --codeCoverage |
| 84 | + - run: npx codecov ./coverage/ |
| 85 | + continue-on-error: true |
| 86 | + |
| 87 | + # run linting |
| 88 | + linting: |
| 89 | + runs-on: ubuntu-latest |
| 90 | + needs: install |
| 91 | + steps: |
| 92 | + - uses: actions/checkout@v2 |
| 93 | + - uses: actions/cache@v2 |
| 94 | + with: |
| 95 | + path: ${{ env.CACHE_NODE_MODULES_PATH }} |
| 96 | + key: node_modules-${{ hashFiles('**/package-lock.json') }} |
| 97 | + - run: npm run lint -- --runner cloud |
| 98 | + |
| 99 | + # firebase deploy preview |
| 100 | + firebase_preview: |
| 101 | + runs-on: ubuntu-latest |
| 102 | + needs: build |
| 103 | + outputs: |
| 104 | + output_url: ${{ steps.firebase_hosting_preview.outputs.details_url }} |
| 105 | + steps: |
| 106 | + - uses: actions/checkout@v2 |
| 107 | + - uses: actions/cache@v2 |
| 108 | + with: |
| 109 | + path: ${{ env.CACHE_DIST_PATH }} |
| 110 | + key: dist-${{ github.run_id }} |
| 111 | + - uses: FirebaseExtended/action-hosting-deploy@v0 |
| 112 | + continue-on-error: true |
| 113 | + id: firebase_hosting_preview |
| 114 | + with: |
| 115 | + repoToken: '${{ secrets.GITHUB_TOKEN }}' |
| 116 | + firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_NGX_BOOTSTRAP_DEMO }}' |
| 117 | + projectId: ngx-bootstrap-demo |
| 118 | + channelId: ${{ env.FIREBASE_CHANNEL }} |
| 119 | + expires: 7d |
| 120 | + |
| 121 | + # run cypress |
| 122 | + e2e_smoke: |
| 123 | + name: e2e smoke |
| 124 | + runs-on: ubuntu-latest |
| 125 | + needs: [install, build, firebase_preview] |
| 126 | + |
| 127 | + strategy: |
| 128 | + # when one test fails, DO NOT cancel the other |
| 129 | + # containers, because this will kill Cypress processes |
| 130 | + # leaving the Dashboard hanging ... |
| 131 | + # https://github.com/cypress-io/github-action/issues/48 |
| 132 | + fail-fast: false |
| 133 | + matrix: |
| 134 | + # run 3 copies of the current job in parallel |
| 135 | + containers: [1, 2, 3, 4, 5] |
| 136 | + steps: |
| 137 | + - uses: actions/checkout@v2 |
| 138 | + - uses: actions/cache@v2 |
| 139 | + with: |
| 140 | + path: ${{ env.CACHE_NODE_MODULES_PATH }} |
| 141 | + key: node_modules-${{ hashFiles('**/package-lock.json') }} |
| 142 | + - uses: actions/cache@v2 |
| 143 | + with: |
| 144 | + path: ${{ env.CACHE_DIST_PATH }} |
| 145 | + key: dist-${{ github.run_id }} |
| 146 | + |
| 147 | + # because of "record" and "parallel" parameters |
| 148 | + # these containers will load balance all found tests among themselves |
| 149 | + - name: smoke e2e on firebase |
| 150 | + if: ${{ needs.firebase_preview.outputs.output_url }} |
| 151 | + run: npx nx run ngx-bootstrap-docs-e2e:e2e -- --configuration firebase --runner cloud --record --group smoke --baseUrl=${{ needs.firebase_preview.outputs.output_url }}/ngx-bootstrap/ --parallel |
| 152 | + |
| 153 | + - name: smoke e2e local |
| 154 | + if: ${{ !needs.firebase_preview.outputs.output_url }} |
| 155 | + run: npx nx run ngx-bootstrap-docs-e2e:e2e -- --configuration production --runner cloud --record --group smoke --parallel |
| 156 | + |
| 157 | + e2e_full: |
| 158 | + name: e2e full |
| 159 | + runs-on: ubuntu-latest |
| 160 | + needs: [e2e_smoke] |
| 161 | + |
| 162 | + strategy: |
| 163 | + # when one test fails, DO NOT cancel the other |
| 164 | + # containers, because this will kill Cypress processes |
| 165 | + # leaving the Dashboard hanging ... |
| 166 | + # https://github.com/cypress-io/github-action/issues/48 |
| 167 | + fail-fast: false |
| 168 | + matrix: |
| 169 | + # run 3 copies of the current job in parallel |
| 170 | + containers: [1, 2, 3, 4, 5] |
| 171 | + steps: |
| 172 | + - uses: actions/checkout@v2 |
| 173 | + - uses: actions/cache@v2 |
| 174 | + with: |
| 175 | + path: ${{ env.CACHE_NODE_MODULES_PATH }} |
| 176 | + key: node_modules-${{ hashFiles('**/package-lock.json') }} |
| 177 | + - uses: actions/cache@v2 |
| 178 | + with: |
| 179 | + path: ${{ env.CACHE_DIST_PATH }} |
| 180 | + key: dist-${{ github.run_id }} |
| 181 | + |
| 182 | + # because of "record" and "parallel" parameters |
| 183 | + # these containers will load balance all found tests among themselves |
| 184 | + - name: full e2e on firebase |
| 185 | + if: ${{ needs.firebase_preview.outputs.output_url }} |
| 186 | + continue-on-error: true |
| 187 | + run: npx nx run ngx-bootstrap-docs-e2e:e2e -- --configuration firebase --runner cloud --cypressConfig ./apps/ngx-bootstrap-docs-e2e/cypress-full.json --record --group full --baseUrl=${{ needs.firebase_preview.outputs.output_url }}/ngx-bootstrap/ --parallel |
| 188 | + |
| 189 | + - name: full e2e on local |
| 190 | + if: ${{ !needs.firebase_preview.outputs.output_url }} |
| 191 | + continue-on-error: true |
| 192 | + run: npx nx run ngx-bootstrap-docs-e2e:e2e -- --configuration production --runner cloud --cypressConfig ./apps/ngx-bootstrap-docs-e2e/cypress-full.json --record --group full --parallel |
0 commit comments