LD4P/sinopia_exporter

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
version: 2.1
orbs:
  node: circleci/node@5.0.2
  docker: circleci/docker@2.5.0
  gh: circleci/github-cli@2.2.0
executors:
  default:
    docker:
      - image: 'cimg/node:20.11'
references:
  publish_params: &publish_params
    docker-password: DOCKER_PASS
    docker-username: DOCKER_USER
  filters:
    branch_only: &branch_only_filter
      branches:
        only:
          - /.*/
      tags:
        ignore:
          - /.*/
    main_only: &main_only_filter
      branches:
        only:
          - main
      tags:
        ignore:
          - /.*/
    release_and_beta_only: &release_and_beta_only_filter
      branches:
        ignore:
          - /.*/
      tags:
        only:
          - /v.[0-9\.]+(-beta)?/
    release_only: &release_only_filter
      branches:
        ignore:
          - /.*/
      tags:
        only:
          - /v.[0-9\.]+/
jobs:
  test:
    executor: default
    steps:
      - checkout
      - node/install-packages
      - run:
          name: Setup Code Climate test-reporter
          command: |
            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
      - run:
          name: Run tests
          command: npm run jest-ci
      - run:
          name: Send coverage report to Code Climate
          command: |
            ./cc-test-reporter after-build --exit-code $?
  dependency-update:
    executor: default
    steps:
      - gh/setup
      - gh/clone
      - run:
          name: Update dependencies
          command: |
            git config user.name "dlss-infra-bot"
            git config user.email "dlss-infrastructure-team-owner@lists.stanford.edu"
            git checkout -b update-dependencies
            repo_url=$(echo $CIRCLE_REPOSITORY_URL | sed -e "s/git@github\.com:/https:\/\/github.com\//" -e "s/\.git//")
            git remote set-url origin $repo_url
            git remote show origin
            npm update
            npm audit fix || echo "Outstanding fixes"
            git add package-lock.json package.json && git commit -m "Update NPM dependencies"
            if [ $? -eq 0 ]; then
              git push origin update-dependencies && gh pr create --title "Update dependencies" --body ""
            fi
workflows:
  build:
    jobs:
      - test:
          filters:
            <<: *branch_only_filter
      - node/run:
          name: lint
          npm-run: lint
          filters:
            <<: *branch_only_filter
      - docker/publish:
          <<: *publish_params
          name: publish-dev
          context: ld4p
          image: ld4p/sinopia_exporter
          tag: latest
          requires:
            - test
            - lint
          filters:
            <<: *main_only_filter
      - docker/publish:
          <<: *publish_params
          name: publish-stage
          context: ld4p
          image: ld4p/sinopia_exporter
          tag: release-stage
          filters:
            <<: *release_and_beta_only_filter
      - docker/publish:
          <<: *publish_params
          name: publish-prod
          context: ld4p
          image: ld4p/sinopia_exporter
          tag: release-prod
          filters:
            <<: *release_only_filter
  dependency-update:
    triggers:
      - schedule:
          # Mondays at 1am
          cron: "0 1 * * 1"
          filters:
            branches:
              only:
                - main
    jobs:
      - dependency-update:
          context: ld4p