From 8615cbcbf48aafee28a2c63c2794879383f49962 Mon Sep 17 00:00:00 2001 From: jeffgreiner-eaton Date: Wed, 3 Apr 2024 13:11:46 -0400 Subject: [PATCH 1/3] add blui ci workflow --- .circleci/config.yml | 223 ---------------------------- .github/workflows/blui-ci.yml | 267 ++++++++++++++++++++++++++++++++++ karma.conf.js | 2 + package.json | 2 +- scripts/buildLib.sh | 2 +- 5 files changed, 271 insertions(+), 225 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/blui-ci.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index e63f7e1b1..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,223 +0,0 @@ -version: 2.1 -orbs: - codecov: codecov/codecov@3.2.2 - gh: circleci/github-cli@1.0.3 - browser-tools: circleci/browser-tools@1.4.8 -jobs: - build_library: - docker: - - image: cimg/node:18.17.0-browsers - steps: - - checkout - - browser-tools/install-browser-tools - - restore_cache: - keys: - - v2-dependencies-angular-{{ checksum "yarn.lock" }} - - run: - name: Install Dependencies - command: | - yarn install --frozen-lockfile - - save_cache: - name: Save Cache - paths: - - node_modules - key: v2-dependencies-angular-{{ checksum "yarn.lock" }} - - run: - name: Prettier Check - command: | - yarn prettier:check - - run: - name: Lint - command: | - yarn lint - - run: - name: Test - command: | - yarn test:ci - - run: - name: Build Library - command: | - yarn build:lib - - run: - name: Test Artifacts - command: | - yarn test:artifacts - - run: - name: NPM Package - command: | - cd dist && npm pack - # Save the dist folder for use in future jobs. - - persist_to_workspace: - root: . - paths: - - dist - - coverage - coverage_report: - working_directory: ~/angular-component-library - docker: - - image: cimg/node:18.17.0-browsers - steps: - - checkout - - attach_workspace: - at: . - - codecov/upload: - file: './coverage/lcov.info' - token: CODECOV_TOKEN - - # Builds the Showcase md using @brightlayer-ui/angular-components persisted in /dist folder. - build_showcase: - docker: - - image: cimg/node:18.17.0-browsers - environment: - - MASTER_BRANCH: master - steps: - - checkout - - attach_workspace: - at: . - - run: - name: Initialize Submodule - command: | - git submodule init && git submodule update - - restore_cache: - keys: - - v2-dependencies-angular-{{ checksum "showcase/yarn.lock" }} - - run: - name: Install Dependencies - command: | - cd showcase - yarn install --frozen-lockfile - - # Install the packed version of @brightlayer-ui/angular-components - PACKAGED_VERSION=`node -p "require('../dist/package.json').version"` - yarn add ../dist/brightlayer-ui-angular-components-$PACKAGED_VERSION.tgz - - save_cache: - name: Save Cache - paths: - - showcase/node_modules - key: v2-dependencies-angular-{{ checksum "showcase/yarn.lock" }} - - attach_workspace: - at: . - - run: - name: Build Showcase - command: | - cd showcase && yarn build - - # Builds the Documentation site app using @brightlayer-ui/angular-components persisted in /dist folder. - build_documentation_site: - docker: - - image: cimg/node:18.17.0-browsers - environment: - - MASTER_BRANCH: master - steps: - - checkout - - attach_workspace: - at: . - - restore_cache: - keys: - - v2-dependencies-angular-{{ checksum "yarn.lock" }} - - run: - name: Install Dependencies - command: yarn - - attach_workspace: - at: . - - run: - name: Build Documentation Site - command: | - if [ $CIRCLE_BRANCH == $MASTER_BRANCH ]; then - yarn build:demo --base-href=/angular/ -c production - else - yarn build:demo --base-href=/angular-dev/ -c development - fi - cp src/404.html build - cd build - touch .nojekyll - - persist_to_workspace: - root: . - paths: - - build - - deploy_documentation_site: - docker: - - image: cimg/node:18.17.0-browsers - environment: - - MASTER_BRANCH: master - - DEV_BRANCH: dev - - DEV_TARGET: https://github.com/brightlayer-ui-components/angular-dev - - MASTER_TARGET: https://github.com/brightlayer-ui-components/angular - - GH_EMAIL: brightlayer-ui@eaton.com - - GH_NAME: Brightlayer UI Agent - steps: - - checkout - - attach_workspace: - at: . - - run: - name: Deploy Documentation Site - command: | - git config --global user.email "$GH_EMAIL" - git config --global user.name "$GH_NAME" - if [ $CIRCLE_BRANCH == $MASTER_BRANCH ]; then - git clone $MASTER_TARGET out - else - git clone $DEV_TARGET out - fi - cd out - git rm -rf . - cd .. - cp -a build/. out/. - cd out - git add -A - git commit -m "Automated deployment to GitHub Pages: ${CIRCLE_SHA1}" --allow-empty - git push - - publish: - docker: - - image: cimg/node:18.17.0-browsers - steps: - - checkout - - attach_workspace: - at: . - - run: - name: Authenticate with registry - command: | - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc - echo "//registry.yarnpkg.com/:_authToken=$NPM_TOKEN" >> ~/.npmrc - - run: - name: Publish @brightlayer-ui/angular-components - command: | - yarn publish:package -b $CIRCLE_BRANCH - -workflows: - version: 2 - angular_library: - jobs: - - build_library - - build_showcase: - requires: - - build_library - - build_documentation_site: - requires: - - build_library - - deploy_documentation_site: - requires: - - build_documentation_site - filters: - branches: - only: - - master - - dev - - publish: - requires: - - build_documentation_site - - build_showcase - filters: - branches: - only: - - master - - dev - - coverage_report: - requires: - - build_library - filters: - branches: - only: - - master diff --git a/.github/workflows/blui-ci.yml b/.github/workflows/blui-ci.yml new file mode 100644 index 000000000..a51f754ff --- /dev/null +++ b/.github/workflows/blui-ci.yml @@ -0,0 +1,267 @@ +name: CI Run + +on: + push: + branches: [ "dev", "master" ] + pull_request: + branches: [ "dev", "master" ] + pull_request_target: + types: + - opened + branches: + - '*/*' + +permissions: + pull-requests: write + contents: read + +jobs: + prettier_lint: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x] + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - run: yarn install:dependencies + - run: yarn prettier + - run: yarn lint + + unit_test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x] + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - run: yarn install:dependencies + - run: yarn coverage + - name: Upload to Codecov + uses: codecov/codecov-action@v3 + with: + directory: ./coverage/ + files: cobertura-coverage.xml + flags: unittests + name: codecov-report + verbose: true + + build_library: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x] + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - run: yarn --frozen-lockfile + - run: yarn build:lib + - name: Save build + uses: actions/upload-artifact@v3 + with: + name: dist + if-no-files-found: error + path: dist + + test_artifacts: + runs-on: ubuntu-latest + needs: build_library + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Download the dist folder + uses: actions/download-artifact@v3 + with: + name: dist + path: dist + - run: yarn test:artifacts + + npm_pack: + runs-on: ubuntu-latest + needs: build_library + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Download the dist folder + uses: actions/download-artifact@v3 + with: + name: dist + path: dist + - run: npm pack + working-directory: dist + - name: Save npm pack + uses: actions/upload-artifact@v3 + with: + name: tarball + if-no-files-found: error + path: dist + + build_showcase: + runs-on: ubuntu-latest + needs: npm_pack + + strategy: + matrix: + node-version: [18.x] + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - run: yarn initialize + - run: yarn --frozen-lockfile + working-directory: showcase + - name: Download tarball + uses: actions/download-artifact@v3 + with: + name: tarball + path: tarball + - run: | + PACKAGED_VERSION=`node -p "require('./tarball/package.json').version"` + yarn add ./tarball/brightlayer-ui-angular-components-$PACKAGED_VERSION.tgz + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - run: yarn build + working-directory: showcase + + build_ng_doc_site: + runs-on: ubuntu-latest + needs: npm_pack + + strategy: + matrix: + node-version: [18.x] + env: + environment.dev: ${{ github.ref == 'refs/heads/master' && 'dev' }} + environment.prod: ${{ github.ref == 'refs/heads/master' && 'master' }} + base-href: ${{ github.ref == 'refs/heads/master' && '/angular' || '/angular-dev' }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Download tarball + uses: actions/download-artifact@v3 + with: + name: tarball + path: tarball + - run: | + PACKAGED_VERSION=`node -p "require('./tarball/package.json').version"` + yarn add ./tarball/brightlayer-ui-angular-components-$PACKAGED_VERSION.tgz + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - run: yarn --frozen-lockfile + - run: yarn build:lib + - name: Save build + uses: actions/upload-artifact@v3 + with: + name: dist + if-no-files-found: error + path: dist + + deploy_angular_doc_site_dev: + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/dev' }} + needs: build_ng_doc_site + env: + DEV_DEPLOY_TOKEN: ${{secrets.DEV_DEPLOY_TOKEN}} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Download build + uses: actions/download-artifact@v3 + with: + name: dist + path: dist + - name: deploy + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: dist + token: ${{env.DEV_DEPLOY_TOKEN}} + repository-name: brightlayer-ui-components/angular-dev + branch: master + git-config-name: Brightlayer UI Agent + git-config-email: brightlayer-ui@eaton.com + commit-message: "Automated deployment to GitHub Pages ${{github.sha}}" + + deploy_angular_doc_site_prod: + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + needs: build_ng_doc_site + env: + DEV_DEPLOY_TOKEN: ${{secrets.DEV_DEPLOY_TOKEN}} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Download build + uses: actions/download-artifact@v3 + with: + name: dist + path: dist + - name: deploy + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: dist + token: ${{env.DEV_DEPLOY_TOKEN}} + repository-name: brightlayer-ui-components/angular + branch: master + git-config-name: Brightlayer UI Agent + git-config-email: brightlayer-ui@eaton.com + commit-message: "Automated deployment to GitHub Pages ${{github.sha}}" + + publish: + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev') }} + needs: build_library + strategy: + matrix: + node-version: [18.x] + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + BRANCH: ${{ github.ref == 'refs/heads/master' && 'master' || 'dev' }} + steps: + - uses: actions/checkout@v4 + - name: Download dist + uses: actions/download-artifact@v3 + with: + name: dist + path: dist + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + registry-url: 'https://registry.npmjs.org' + - run: yarn --frozen-lockfile + - run: yarn publish:package -b ${{env.BRANCH}} \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index 8636ae117..e7629796a 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -29,6 +29,8 @@ module.exports = function (config) { subdir: '.', reporters: [ { type: 'html' }, + { type: 'lcovonly' }, + { type: 'cobertura' }, { type: 'text-summary' } ] }, diff --git a/package.json b/package.json index ca84e8f15..3c2bbc86c 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "test": "ng test demo", "test:ci": "ng test demo --watch false", "test:artifacts": "bash scripts/buildTest.sh", - "coverage": "yarn test --no-watch --code-coverage", + "coverage": "ng test demo --browsers=ChromeHeadless --no-watch --code-coverage", "publish:package": "cd dist && rm -f *.tgz && set npm_config_yes=true && npx -p @brightlayer-ui/publish blui-publish", "tag:package": "npx -p @brightlayer-ui/tag blui-tag -s -blui-angular-components", "precommit": "yarn initialize && yarn install:dependencies && yarn prettier && yarn lint && yarn test:ci && yarn build && yarn test:artifacts && yarn generate:licenses", diff --git a/scripts/buildLib.sh b/scripts/buildLib.sh index 03923300c..c4b819cda 100644 --- a/scripts/buildLib.sh +++ b/scripts/buildLib.sh @@ -20,6 +20,6 @@ echo -e "${BLUE}Copying Package Resources${NC}" cp -r README.md ./dist/README.md cp -r LICENSE ./dist/LICENSE cp -r CHANGELOG.md ./dist/CHANGELOG.md -cp -r components/LICENSES.json ./dist/LICENSES.json +cp -r LICENSES.json ./dist/LICENSES.json echo -e "${GRAY}Complete${NC}\r\n" From 9792dfde89e811657b8ddb6ae3a396459a400ebf Mon Sep 17 00:00:00 2001 From: jeffgreiner-eaton Date: Wed, 3 Apr 2024 13:26:52 -0400 Subject: [PATCH 2/3] test commit drop circleci from jobs list --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 54b4cae91..35fffcdc4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Brightlayer UI Angular Components - +# test [![](https://img.shields.io/circleci/project/github/etn-ccis/blui-angular-component-library/master.svg?style=flat)](https://circleci.com/gh/etn-ccis/blui-angular-component-library/tree/master) ![npm](https://img.shields.io/npm/v/@brightlayer-ui/angular-components?label=%40brightlayer-ui%2Fangular-components) [![codecov](https://codecov.io/gh/etn-ccis/blui-angular-component-library/branch/master/graph/badge.svg?token=DB9EMVFAFJ)](https://codecov.io/gh/etn-ccis/blui-angular-component-library) From f85f2b18ef12e90c1658c17488780808853279fb Mon Sep 17 00:00:00 2001 From: jeffgreiner-eaton Date: Wed, 3 Apr 2024 13:31:37 -0400 Subject: [PATCH 3/3] revert test commit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35fffcdc4..54b4cae91 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Brightlayer UI Angular Components -# test + [![](https://img.shields.io/circleci/project/github/etn-ccis/blui-angular-component-library/master.svg?style=flat)](https://circleci.com/gh/etn-ccis/blui-angular-component-library/tree/master) ![npm](https://img.shields.io/npm/v/@brightlayer-ui/angular-components?label=%40brightlayer-ui%2Fangular-components) [![codecov](https://codecov.io/gh/etn-ccis/blui-angular-component-library/branch/master/graph/badge.svg?token=DB9EMVFAFJ)](https://codecov.io/gh/etn-ccis/blui-angular-component-library)