NodeJS SDK Test workflow on workflow_dispatch #436
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This job is to test different npm profiles in master branch against Pull Request raised | |
# This workflow targets cucumber-js | |
name: NodeJS SDK Test workflow on workflow_dispatch | |
on: | |
workflow_dispatch: | |
inputs: | |
commit_sha: | |
description: 'The full commit id to build' | |
required: true | |
package_url: | |
description: 'Staging package url' | |
required: false | |
jobs: | |
comment-run: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
max-parallel: 3 | |
matrix: | |
node: ['14', '16', '18', '20'] | |
os: [ macos-latest, windows-latest, ubuntu-latest ] | |
name: Cucumber-js Repo ${{ matrix.node }} - ${{ matrix.os }} Sample | |
env: | |
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} | |
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} | |
PACKAGE_URL: ${{ github.event.inputs.package_url }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.inputs.commit_sha }} | |
- uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 | |
id: status-check-in-progress | |
env: | |
job_name: Cucumber-js Repo ${{ matrix.node }} - ${{ matrix.os }} Sample | |
commit_sha: ${{ github.event.inputs.commit_sha }} | |
with: | |
github-token: ${{ github.token }} | |
script: | | |
const result = await github.rest.checks.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: process.env.job_name, | |
head_sha: process.env.commit_sha, | |
status: 'in_progress' | |
}).catch((err) => ({status: err.status, response: err.response})); | |
console.log(`The status-check response : ${result.status} Response : ${JSON.stringify(result.response)}`) | |
if (result.status !== 201) { | |
console.log('Failed to create check run') | |
} | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node }} | |
- name: Register user with Verdaccio | |
run: | | |
curl -X PUT http://localhost:4873/-/user/org.couchdb.user:dummy \ | |
-H "Content-Type: application/json" \ | |
-d '{ | |
"name": "dummy", | |
"password": "dummy", | |
"email": "dummy@gmail.com" | |
}' | |
- name: Set up npm authentication | |
run: | | |
echo "//localhost:4873/:_auth=$(echo -n 'dummy:dummy' | base64)" >> ~/.npmrc | |
echo "email=dummy@gmail.com" >> ~/.npmrc | |
echo "always-auth=true" >> ~/.npmrc | |
npx verdaccio@5.32.2 & | |
for i in {1..30}; do | |
if curl -sf http://localhost:4873/-/ping > /dev/null; then break; fi | |
echo "Waiting for Verdaccio to be ready..."; sleep 2; | |
done | |
npm config set registry http://localhost:4873 | |
- name: Setup staging npm package | |
if: ${{ github.event.inputs.package_url != '' }} | |
run: | | |
echo 'Publishing tar.gz to local registry' | |
curl -o staging_package.tgz "$PACKAGE_URL" | |
npm publish staging_package.tgz --registry http://localhost:4873/ | |
shell: bash | |
- name: Install dependencies | |
run: npm install | |
- name: Run sample tests | |
run: npm run sample-test | |
- name: Run local tests | |
run: npm run sample-local-test | |
- if: always() | |
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 | |
id: status-check-completed | |
env: | |
conclusion: ${{ job.status }} | |
job_name: Cucumber-js Repo ${{ matrix.node }} - ${{ matrix.os }} Sample | |
commit_sha: ${{ github.event.inputs.commit_sha }} | |
with: | |
github-token: ${{ github.token }} | |
script: | | |
const result = await github.rest.checks.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: process.env.job_name, | |
head_sha: process.env.commit_sha, | |
status: 'completed', | |
conclusion: process.env.conclusion | |
}).catch((err) => ({status: err.status, response: err.response})); | |
console.log(`The status-check response : ${result.status} Response : ${JSON.stringify(result.response)}`) | |
if (result.status !== 201) { | |
console.log('Failed to create check run') | |
} |