IBM/scc-node-sdk

View on GitHub
.github/workflows/main.yaml

Summary

Maintainability
Test Coverage
name: CI/CD Pipeline
on:
  push:
    branches: [main]
  pull_request:
  workflow_dispatch:

jobs:
  verify:
    runs-on: ubuntu-latest
    if: "!startsWith(github.event.head_commit.message, 'chore') && !startsWith(github.ref, 'refs/tags/v')"
    strategy:
      matrix:
        node-version: [14.x, 16.x, 18.x]
    steps:
      - uses: actions/checkout@v1

      - name: installing dependencies
        run: npm install

      - name: verifying packages
        run: npm run check-packages

  test:
    runs-on: ubuntu-latest
    if: "!startsWith(github.event.head_commit.message, 'chore') && !startsWith(github.ref, 'refs/tags/v')"
    strategy:
      matrix: 
        node-version: [14.x, 16.x, 18.x]
    steps:
      - uses: actions/checkout@v1

      - name: installing dependencies
        run: npm install

      - name: building project
        run: npm run build

      - name: running unit tests
        run: npm run test-unit-travis

      - name: publishing code coverage report to codeclimate
        env:
          CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
        run: |
          curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
          chmod +x ./cc-test-reporter
          ./cc-test-reporter before-build
          build/publishCodeCoverage.sh

      - name: running integration tests
        env:
          SCC_ENV: ${{ secrets.SCC_ENV }}
          SECURITY_AND_COMPLIANCE_CENTER_API_IAM_PROFILE_ID: ${{ secrets.SCC_IAM_PROFILE_ID }}          
        run: scripts/testScript.sh

  release:
    runs-on: ubuntu-latest
    needs: [verify, test]
    if: "github.event_name == 'push' && github.ref == 'refs/heads/main' && !startsWith(github.event.head_commit.message, 'chore')"
    steps:
      - name: setup extensions
        uses: actions/checkout@v1

      - name: setup nodejs
        uses: actions/setup-node@v2
        with:
          node-version: '18'

      - name: release using semantic-release
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
          GITHUB_TOKEN: ${{ secrets.ADMIN_TOKEN }}
          GIT_AUTHOR_NAME: sccdeveloper
          GIT_AUTHOR_EMAIL: scccomm@in.ibm.com
          GIT_COMMITTER_NAME: sccdeveloper
          GIT_COMMITTER_EMAIL: scccomm@in.ibm.com
        run: |
          pip install --user bumpversion
          npm install @semantic-release/changelog
          npm install @semantic-release/exec
          npm install @semantic-release/git
          npm install @semantic-release/github
          npx semantic-release

  documentation:
    runs-on: ubuntu-latest
    if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')"
    steps:
      - name: setup extensions
        uses: actions/checkout@v1

      - name: setup nodejs
        uses: actions/setup-node@v2
        with:
          node-version: '18'

      - name: installing dependencies
        run: npm install

      - name: generate typedoc
        run: scripts/typedoc/generate_typedoc.sh
      
      - name: deploy node pages to gh-pages
        run: |
          git config --global user.email "scccomm@in.ibm.com"
          git config --global user.name "sccdeveloper"
          git config --global user.password "${{ secrets.ADMIN_TOKEN }}"
          cd v4/dist
          git init
          git add .
          git commit -m "Deploy to GitHub pages"
          git branch -m gh-pages
          git remote add origin https://github.com/ibm/scc-node-sdk
          git push -f origin gh-pages
        env:
          GITHUB_TOKEN: ${{ secrets.ADMIN_TOKEN }}
          GIT_AUTHOR_NAME: sccdeveloper
          GIT_AUTHOR_EMAIL: scccomm@in.ibm.com
          GIT_COMMITTER_NAME: sccdeveloper
          GIT_COMMITTER_EMAIL: scccomm@in.ibm.com