diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 7e1f1b4..09a587d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1,3 @@ .github/* @browserstack/asi-devs + +* @browserstack/automate-public-repos diff --git a/.github/workflows/Semgrep.yml b/.github/workflows/Semgrep.yml new file mode 100644 index 0000000..0347afd --- /dev/null +++ b/.github/workflows/Semgrep.yml @@ -0,0 +1,48 @@ +# Name of this GitHub Actions workflow. +name: Semgrep + +on: + # Scan changed files in PRs (diff-aware scanning): + # The branches below must be a subset of the branches above + pull_request: + branches: ["master", "main"] + push: + branches: ["master", "main"] + schedule: + - cron: '0 6 * * *' + + +permissions: + contents: read + +jobs: + semgrep: + # User definable name of this GitHub Actions job. + permissions: + contents: read # for actions/checkout to fetch code + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results + name: semgrep/ci + # If you are self-hosting, change the following `runs-on` value: + runs-on: ubuntu-latest + + container: + # A Docker image with Semgrep installed. Do not change this. + image: returntocorp/semgrep + + # Skip any PR created by dependabot to avoid permission issues: + if: (github.actor != 'dependabot[bot]') + + steps: + # Fetch project source with GitHub Actions Checkout. + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + # Run the "semgrep ci" command on the command line of the docker image. + - run: semgrep ci --sarif --output=semgrep.sarif + env: + # Add the rules that Semgrep uses by setting the SEMGREP_RULES environment variable. + SEMGREP_RULES: p/default # more at semgrep.dev/explore + + - name: Upload SARIF file for GitHub Advanced Security Dashboard + uses: github/codeql-action/upload-sarif@6c089f53dd51dc3fc7e599c3cb5356453a52ca9e # v2.20.0 + with: + sarif_file: semgrep.sarif + if: always() \ No newline at end of file diff --git a/.github/workflows/reviewing_changes.yml b/.github/workflows/reviewing_changes.yml new file mode 100644 index 0000000..de42df9 --- /dev/null +++ b/.github/workflows/reviewing_changes.yml @@ -0,0 +1,102 @@ +# This job is to test different npm profiles in main branch against Pull Request raised +# This workflow targets codecept-js + +name: NodeJS 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: Codecept-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: Codecept-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: 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 install verdaccio@5.32.2 -g + verdaccio & + npm config set registry http://localhost:4873 + npm install -g npm-cli-adduser && npm-cli-adduser -u dummy -p dummy -e dummy@gmail.com -r http://localhost:4873 + 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: Codecept-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') + } diff --git a/README.md b/README.md index a926032..d72b694 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # Integrating CodeceptJS Node.js with BrowserStack BrowserStack ## Prerequisite -* [Node.js](https://nodejs.org/en/download/) version 12 or higher is installed on your machine. +* [Node.js](https://nodejs.org/en/download/) version 12 or higher is installed on your machine. ## Setup * Clone the repo diff --git a/package.json b/package.json index a2e3926..8766321 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ }, "homepage": "https://github.com/browserstack/codecept-js-browserstack#readme", "devDependencies": { - "codeceptjs": "^3.2.3", + "codeceptjs": "3.6.9", "webdriverio": "^7.17.4", "browserstack-node-sdk": "latest" },