|
| 1 | +# Runs the BrowserStack SDK sample against a given commit and reports a status check. |
| 2 | +# Trigger: Actions tab -> "Gauge (Java) SDK sample test" -> Run workflow -> paste the PR's full commit SHA. |
| 3 | +# Requires repo secrets: BROWSERSTACK_USERNAME, BROWSERSTACK_ACCESS_KEY. |
| 4 | +name: Gauge (Java) SDK sample test |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + commit_sha: |
| 10 | + description: 'The full commit id to build' |
| 11 | + required: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + sdk-sample: |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + max-parallel: 3 |
| 19 | + matrix: |
| 20 | + os: [ubuntu-latest] |
| 21 | + java: ['11', '17'] |
| 22 | + name: gauge-java JDK ${{ matrix.java }} sample |
| 23 | + env: |
| 24 | + BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} |
| 25 | + BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + ref: ${{ github.event.inputs.commit_sha }} |
| 30 | + - name: Mark status check in_progress |
| 31 | + uses: actions/github-script@v7 |
| 32 | + env: |
| 33 | + job_name: gauge-java JDK ${{ matrix.java }} sample |
| 34 | + commit_sha: ${{ github.event.inputs.commit_sha }} |
| 35 | + with: |
| 36 | + github-token: ${{ github.token }} |
| 37 | + script: | |
| 38 | + await github.rest.checks.create({ |
| 39 | + owner: context.repo.owner, repo: context.repo.repo, |
| 40 | + name: process.env.job_name, head_sha: process.env.commit_sha, status: 'in_progress' |
| 41 | + }).catch(e => console.log('check create failed:', e.status)); |
| 42 | + - uses: actions/setup-java@v4 |
| 43 | + with: |
| 44 | + distribution: 'temurin' |
| 45 | + java-version: ${{ matrix.java }} |
| 46 | + - name: Install Gauge |
| 47 | + run: | |
| 48 | + npm install -g @getgauge/cli |
| 49 | + gauge install java |
| 50 | + - name: Run sample test |
| 51 | + run: | |
| 52 | + mvn compile |
| 53 | + mvn test |
| 54 | + - name: Mark status check completed |
| 55 | + if: always() |
| 56 | + uses: actions/github-script@v7 |
| 57 | + env: |
| 58 | + conclusion: ${{ job.status }} |
| 59 | + job_name: gauge-java JDK ${{ matrix.java }} sample |
| 60 | + commit_sha: ${{ github.event.inputs.commit_sha }} |
| 61 | + with: |
| 62 | + github-token: ${{ github.token }} |
| 63 | + script: | |
| 64 | + await github.rest.checks.create({ |
| 65 | + owner: context.repo.owner, repo: context.repo.repo, |
| 66 | + name: process.env.job_name, head_sha: process.env.commit_sha, |
| 67 | + status: 'completed', conclusion: process.env.conclusion |
| 68 | + }).catch(e => console.log('check create failed:', e.status)); |
0 commit comments