Skip to content

Merge pull request #830 from securityscorecard/dependabot/npm_and_yar… #2943

Merge pull request #830 from securityscorecard/dependabot/npm_and_yar…

Merge pull request #830 from securityscorecard/dependabot/npm_and_yar… #2943

Workflow file for this run

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: CD
on:
push:
jobs:
unit-tests:
name: '🛟 Run unit tests'
runs-on: ubuntu-latest
strategy:
matrix:
node: ['14', '16', '18']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Cache yarn pnp files
uses: actions/cache@v3
id: cache
with:
path: |
.yarn/cache
.yarn/unplugged
.yarn/install-state.gz
.pnp.cjs
.pnp.loader.mjs
key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/yarn.lock', '**/package.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}-${{ env.cache-name }}-
${{ runner.os }}-node-${{ env.cache-name }}-
${{ runner.os }}-node-
${{ runner.os }}-
- name: Install Packages
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Run Unit Tests
run: yarn test
types:
name: '🪪 Check typings'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Cache yarn pnp files
uses: actions/cache@v3
id: cache
with:
path: |
.yarn/cache
.yarn/unplugged
.yarn/install-state.gz
.pnp.cjs
.pnp.loader.mjs
key: ${{ runner.os }}-node-16-${{ hashFiles('**/yarn.lock', '**/package.json') }}
restore-keys: |
${{ runner.os }}-node-16-${{ env.cache-name }}-
${{ runner.os }}-node-${{ env.cache-name }}-
${{ runner.os }}-node-
${{ runner.os }}-
- name: Install Packages
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Run Types Check
run: yarn types
visual-tests:
name: '🖼 Run visual tests'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Cache yarn pnp files
uses: actions/cache@v3
id: cache
with:
path: |
.yarn/cache
.yarn/unplugged
.yarn/install-state.gz
.pnp.cjs
.pnp.loader.mjs
key: ${{ runner.os }}-node-16-${{ hashFiles('**/yarn.lock', '**/package.json') }}
restore-keys: |
${{ runner.os }}-node-16-${{ env.cache-name }}-
${{ runner.os }}-node-${{ env.cache-name }}-
${{ runner.os }}-node-
${{ runner.os }}-
- name: Install Packages
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Cache storybook build
id: storybook-build-cache
uses: actions/cache@v3
with:
path: storybook-static
key: ${{ hashFiles('**/yarn.lock', '**/package.json', 'src/**', '!.storybook/image-snapshots/**' ,'.storybook/**') }}
- name: Build Storybook
if: steps.storybook-build-cache.outputs.cache-hit != 'true'
run: yarn storybook:build
- name: Run Visual Regressions
run: yarn test:storybook:visual:ci
- name: Tar artifacts
if: failure()
run: tar -cvf visual-test-reports.tar .storybook/image-snapshots
- name: Archive visual artifacts
if: failure()
uses: actions/upload-artifact@v3
with:
name: visual-test-reports
path: visual-test-reports.tar
lint:
name: '🧹 Run lint'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Cache yarn pnp files
uses: actions/cache@v3
id: cache
with:
path: |
.yarn/cache
.yarn/unplugged
.yarn/install-state.gz
.pnp.cjs
.pnp.loader.mjs
key: ${{ runner.os }}-node-16-${{ hashFiles('**/yarn.lock', '**/package.json') }}
restore-keys: |
${{ runner.os }}-node-16-${{ env.cache-name }}-
${{ runner.os }}-node-${{ env.cache-name }}-
${{ runner.os }}-node-
${{ runner.os }}-
- name: Install Packages
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Run Lint
run: yarn lint
lint-css:
name: '🎨 Lint CSS'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Cache yarn pnp files
uses: actions/cache@v3
id: cache
with:
path: |
.yarn/cache
.yarn/unplugged
.yarn/install-state.gz
.pnp.cjs
.pnp.loader.mjs
key: ${{ runner.os }}-node-16-${{ hashFiles('**/yarn.lock', '**/package.json') }}
restore-keys: |
${{ runner.os }}-node-16-${{ env.cache-name }}-
${{ runner.os }}-node-${{ env.cache-name }}-
${{ runner.os }}-node-
${{ runner.os }}-
- name: Install Packages
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Run Lint
run: yarn lint:css
betterer:
name: '🚧 Check Betterer rules'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Cache yarn pnp files
uses: actions/cache@v3
id: cache
with:
path: |
.yarn/cache
.yarn/unplugged
.yarn/install-state.gz
.pnp.cjs
.pnp.loader.mjs
key: ${{ runner.os }}-node-16-${{ hashFiles('**/yarn.lock', '**/package.json') }}
restore-keys: |
${{ runner.os }}-node-16-${{ env.cache-name }}-
${{ runner.os }}-node-${{ env.cache-name }}-
${{ runner.os }}-node-
${{ runner.os }}-
- name: Install Packages
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Run Betterer
run: yarn betterer:ci
build:
name: '🧰 Build package'
runs-on: ubuntu-latest
strategy:
matrix:
node: ['14', '16', '18']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Cache yarn pnp files
uses: actions/cache@v3
id: cache
with:
path: |
.yarn/cache
.yarn/unplugged
.yarn/install-state.gz
.pnp.cjs
.pnp.loader.mjs
key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/yarn.lock', '**/package.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}-${{ env.cache-name }}-
${{ runner.os }}-node-${{ env.cache-name }}-
${{ runner.os }}-node-
${{ runner.os }}-
- name: Install Packages
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Cache build
id: library-build-cache
uses: actions/cache@v3
with:
path: build
key: node-${{ matrix.node }}-${{ hashFiles('**/yarn.lock', '**/package.json', '**/rollup.config.js', 'src/**') }}
- name: Build Step
run: yarn build
- uses: actions/upload-artifact@v3
with:
name: bundle-stats-${{ matrix.node }}
path: stats
get-next-version:
name: '📟 Get next released version'
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'chore(release):')
continue-on-error: true
needs: [unit-tests, visual-tests, types, lint, lint-css, betterer, build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Cache yarn pnp files
uses: actions/cache@v3
id: cache
with:
path: |
.yarn/cache
.yarn/unplugged
.yarn/install-state.gz
.pnp.cjs
.pnp.loader.mjs
key: ${{ runner.os }}-node-16-${{ hashFiles('**/yarn.lock', '**/package.json') }}
restore-keys: |
${{ runner.os }}-node-16-${{ env.cache-name }}-
${{ runner.os }}-node-${{ env.cache-name }}-
${{ runner.os }}-node-
${{ runner.os }}-
- name: Install Packages
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Run Semantic Release
run: yarn semantic-release --dry-run
id: get-next-version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_REGISTRY: https://registry.npmjs.org:8443/
- name: Show release
run: |
echo The new version will be released: ${{steps.get-next-version.outputs.new-release-published}}
echo Number of the new vesion will be: ${{steps.get-next-version.outputs.new-release-version}}
outputs:
new-release-published: ${{ steps.get-next-version.outputs.new-release-published }}
new-release-version: ${{ steps.get-next-version.outputs.new-release-version }}
status: ${{ job.status }}
build-and-publish:
name: '🚀 Publish new version'
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'chore(release):')
needs: get-next-version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org'
scope: '@securityscorecard'
- name: Cache yarn pnp files
uses: actions/cache@v3
id: cache
with:
path: |
.yarn/cache
.yarn/unplugged
.yarn/install-state.gz
.pnp.cjs
.pnp.loader.mjs
key: ${{ runner.os }}-node-16-${{ hashFiles('**/yarn.lock', '**/package.json') }}
restore-keys: |
${{ runner.os }}-node-16-${{ env.cache-name }}-
${{ runner.os }}-node-${{ env.cache-name }}-
${{ runner.os }}-node-
${{ runner.os }}-
- name: Install Packages
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Cache build
id: library-build-cache
uses: actions/cache@v3
with:
path: build
key: node-16-${{ hashFiles('**/yarn.lock', '**/package.json', '**/rollup.config.js', 'src/**') }}
- name: Build Step
if: steps.library-build-cache.outputs.cache-hit != 'true'
run: yarn build
- name: Run Semantic Release
run: yarn semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_REGISTRY: https://registry.npmjs.org:8443/
build-docs:
name: '📒 Build documentation'
if: needs.get-next-version.outputs.new-release-published == 'true' && needs.get-next-version.outputs.status == 'success'
needs: [get-next-version, build-and-publish]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Cache yarn pnp files
uses: actions/cache@v3
id: cache
with:
path: |
.yarn/cache
.yarn/unplugged
.yarn/install-state.gz
.pnp.cjs
.pnp.loader.mjs
key: ${{ runner.os }}-node-16-${{ hashFiles('**/yarn.lock', '**/package.json') }}
restore-keys: |
${{ runner.os }}-node-16-${{ env.cache-name }}-
${{ runner.os }}-node-${{ env.cache-name }}-
${{ runner.os }}-node-
${{ runner.os }}-
- name: Install Packages
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Cache storybook build
id: storybook-build-cache
uses: actions/cache@v3
with:
path: docs-build
key: docs-${{ hashFiles('**/yarn.lock', '**/package.json', 'src/**', '!.storybook/image-snapshots/**' ,'.storybook/**') }}
restore-keys: |
docs-
- name: Build Storybook
if: steps.storybook-build-cache.outputs.cache-hit != 'true'
run: yarn build-storybook -o ./docs-build/${{ needs.get-next-version.outputs.new-release-version }}
- name: Generate redirect index
env:
VERSION: ${{ needs.get-next-version.outputs.new-release-version }}
run: |
yarn node ./scripts/generate-index.js
- name: Upload Storybook artifact
uses: actions/upload-artifact@v3
with:
name: storybook
path: ./docs-build
retention-days: 1
deploy-docs:
name: '📤 Deploy documentation'
needs: [get-next-version, build-docs]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: gh-pages
- name: Download Storybook artifact
uses: actions/download-artifact@v3
with:
name: storybook
- name: Commit storybook
run: |
git config --global user.name "Continuous Integration"
git config --global user.email "[email protected]"
git add -A
git commit -m "Publish docs for ${{ needs.get-next-version.outputs.new-release-version }}"
git push