|
| 1 | +# This job is to test different npm profiles in main branch against Pull Requests raised |
| 2 | +# This workflow targets Jest-js |
| 3 | + |
| 4 | +name: Jest Appium SDK Test workflow on workflow_dispatch |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + commit_sha: |
| 10 | + description: 'The full commit id to build' |
| 11 | + required: true |
| 12 | + package_url: |
| 13 | + description: 'Staging package url' |
| 14 | + required: false |
| 15 | + |
| 16 | +jobs: |
| 17 | + comment-run: |
| 18 | + runs-on: ${{ matrix.os }} |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + max-parallel: 3 |
| 22 | + matrix: |
| 23 | + node: ['14', '16', '18', '20'] |
| 24 | + os: [ macos-latest, windows-latest, ubuntu-latest ] |
| 25 | + name: Jest-js Repo ${{ matrix.node }} - ${{ matrix.os }} Sample |
| 26 | + env: |
| 27 | + BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} |
| 28 | + BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} |
| 29 | + PACKAGE_URL: ${{ github.event.inputs.package_url }} |
| 30 | + |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v3 |
| 33 | + with: |
| 34 | + ref: ${{ github.event.inputs.commit_sha }} |
| 35 | + - uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 |
| 36 | + id: status-check-in-progress |
| 37 | + env: |
| 38 | + job_name: Jest-js Repo ${{ matrix.node }} - ${{ matrix.os }} Sample |
| 39 | + commit_sha: ${{ github.event.inputs.commit_sha }} |
| 40 | + with: |
| 41 | + github-token: ${{ github.token }} |
| 42 | + script: | |
| 43 | + const result = await github.rest.checks.create({ |
| 44 | + owner: context.repo.owner, |
| 45 | + repo: context.repo.repo, |
| 46 | + name: process.env.job_name, |
| 47 | + head_sha: process.env.commit_sha, |
| 48 | + status: 'in_progress' |
| 49 | + }).catch((err) => ({status: err.status, response: err.response})); |
| 50 | + console.log(`The status-check response : ${result.status} Response : ${JSON.stringify(result.response)}`) |
| 51 | + if (result.status !== 201) { |
| 52 | + console.log('Failed to create check run') |
| 53 | + } |
| 54 | + - name: Setup node |
| 55 | + uses: actions/setup-node@v3 |
| 56 | + with: |
| 57 | + node-version: ${{ matrix.node }} |
| 58 | + |
| 59 | + - name: Setup staging npm package |
| 60 | + if: ${{ github.event.inputs.package_url != '' }} |
| 61 | + run: | |
| 62 | + echo 'Publishing tar.gz to local registry' |
| 63 | + curl -o staging_package.tgz "$PACKAGE_URL" |
| 64 | + |
| 65 | + verdaccio & |
| 66 | + npm config set registry http://localhost:4873 |
| 67 | + npm install -g npm-cli-adduser && npm-cli-adduser -u dummy -p dummy -e [email protected] -r http://localhost:4873 |
| 68 | + npm publish staging_package.tgz --registry http://localhost:4873/ |
| 69 | + shell: bash |
| 70 | + |
| 71 | + - name: Install dependencies for android |
| 72 | + run: | |
| 73 | + cd android |
| 74 | + npm install |
| 75 | +
|
| 76 | + - name: Run sample tests for android |
| 77 | + run: | |
| 78 | + cd android |
| 79 | + npm run sample-test |
| 80 | +
|
| 81 | + - name: Run local tests for android |
| 82 | + run: | |
| 83 | + cd android |
| 84 | + npm run sample-local-test |
| 85 | +
|
| 86 | + - name: Install dependencies for ios |
| 87 | + run: | |
| 88 | + cd ios |
| 89 | + npm install |
| 90 | +
|
| 91 | + - name: Run sample tests for ios |
| 92 | + run: | |
| 93 | + cd ios |
| 94 | + npm run sample-test |
| 95 | +
|
| 96 | + - name: Run local tests for ios |
| 97 | + run: | |
| 98 | + cd ios |
| 99 | + npm run sample-local-test |
| 100 | +
|
| 101 | + - if: always() |
| 102 | + uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 |
| 103 | + id: status-check-completed |
| 104 | + env: |
| 105 | + conclusion: ${{ job.status }} |
| 106 | + job_name: Jest-js Repo ${{ matrix.node }} - ${{ matrix.os }} Sample |
| 107 | + commit_sha: ${{ github.event.inputs.commit_sha }} |
| 108 | + with: |
| 109 | + github-token: ${{ github.token }} |
| 110 | + script: | |
| 111 | + const result = await github.rest.checks.create({ |
| 112 | + owner: context.repo.owner, |
| 113 | + repo: context.repo.repo, |
| 114 | + name: process.env.job_name, |
| 115 | + head_sha: process.env.commit_sha, |
| 116 | + status: 'completed', |
| 117 | + conclusion: process.env.conclusion |
| 118 | + }).catch((err) => ({status: err.status, response: err.response})); |
| 119 | + console.log(`The status-check response : ${result.status} Response : ${JSON.stringify(result.response)}`) |
| 120 | + if (result.status !== 201) { |
| 121 | + console.log('Failed to create check run') |
| 122 | + } |
0 commit comments