diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 619ba1f5e0..0000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,8 +0,0 @@ -# This is a comment. -# Each line is a file pattern followed by one or more owners. - -# These owners will be the default owners for everything in -# the repo. Unless a later match takes precedence, -# @thyhjwb6, @m7kvqbe1 and @jpveooys will be requested for -# review when someone opens a pull request. -* @thyhjwb6 @m7kvqbe1 @jpveooys diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 97aa6d2588..4958fbab08 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,11 +3,8 @@ updates: - package-ecosystem: npm directory: "/" schedule: - interval: weekly + interval: monthly open-pull-requests-limit: 5 - reviewers: - - m7kvqbe1 - - thyhjwb6 labels: - "Type: Dependencies" commit-message: diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml deleted file mode 100644 index eade300a8f..0000000000 --- a/.github/workflows/automerge.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Dependabot Automerge - -on: - workflow_run: - types: - - completed - workflows: - - 'Build & Test' - branches: - - 'dependabot/**' - -jobs: - Test_visual_regression: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' && github.actor == 'dependabot[bot]' }} - steps: - - name: Git clone repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Cache Node modules - uses: actions/cache@v2 - with: - path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/yarn.lock') }} - - name: Build icon-library - run: | - yarn install --frozen-lockfile - yarn --cwd packages/icon-library build - - name: Build design-tokens - run: | - yarn --cwd packages/design-tokens build - - name: Run visual regression tests - run: | - yarn --cwd packages/react-component-library chromatic --project-token=${{secrets.CHROMATIC_TOKEN}} - Automerge: - name: Merge Dependabot PR's - runs-on: ubuntu-latest - needs: [Test_visual_regression] - steps: - - name: Auto merge Dependabot minor and patch version bumps - uses: defencedigital/design-system-mergeme-action@master - with: - GITHUB_TOKEN: ${{ secrets.MERGE_BOT }} - PRESET: DEPENDABOT_MINOR diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 4e11f0a1f4..70c25fe199 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -12,16 +12,16 @@ jobs: runs-on: ubuntu-latest steps: - name: Git clone repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Cache Node modules - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }} - name: Cache Cypress binary - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.cache/Cypress key: cypress-${{ runner.os }}-cypress-${{ hashFiles('**/yarn.lock') }} @@ -43,7 +43,7 @@ jobs: tar -czvf dist.tar.gz distil distdt - name: Persist artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: dist path: ./dist.tar.gz @@ -52,7 +52,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Git clone repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Run audit run: yarn run audit @@ -63,13 +63,13 @@ jobs: if: ${{ github.event_name == 'pull_request' }} steps: - name: Git clone repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Cache Node modules - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }} - name: check commits run: | @@ -80,13 +80,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Git clone repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Cache Node modules - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }} - name: Get dependencies & run lint run: | @@ -98,16 +98,16 @@ jobs: needs: [Build_icon_library, Lint_react-component-library] steps: - name: Git clone repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Cache Node modules - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }} - name: Attach workspace - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: dist @@ -121,7 +121,7 @@ jobs: - name: SonarCloud Scan uses: defencedigital/design-system-sonarcloud-action@master - if: ${{ github.actor != 'dependabot[bot]' }} + if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && github.actor != 'dependabot[bot]' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} @@ -134,16 +134,16 @@ jobs: browser: ['chrome', 'firefox'] steps: - name: Git clone repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Cache Node modules - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }} - name: Cache Cypress binary - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.cache/Cypress key: cypress-${{ runner.os }}-cypress-${{ hashFiles('**/yarn.lock') }} @@ -151,7 +151,7 @@ jobs: cypress-${{ runner.os }}-cypress- - name: Attach workspace - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: dist @@ -183,16 +183,16 @@ jobs: needs: [Build_icon_library, Lint_react-component-library] steps: - name: Git clone repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Cache Node modules - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }} - name: Attach workspace - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: dist @@ -206,42 +206,53 @@ jobs: needs: [Build_icon_library] steps: - name: Git clone repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Cache Node modules - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }} - name: Jest design-tokens run: | yarn --cwd packages/design-tokens build yarn --cwd packages/design-tokens test - Test_visual_regression: + Build_storybook: runs-on: ubuntu-latest - needs: [Build_icon_library, Test_react-component-library] - # https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ - if: ${{ github.actor != 'dependabot[bot]' }} + needs: [Build_icon_library] steps: - name: Git clone repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Cache Node modules - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }} - name: Attach workspace - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: dist - - name: Run visual regression tests + - name: Build Storybook + env: + CHROMATIC_SHA: ${{ github.event.pull_request.head.sha || github.sha }} + CHROMATIC_BRANCH: ${{ github.head_ref || github.ref_name }} + CHROMATIC_SLUG: ${{ github.event.pull_request.head.repo.full_name || github.repository }} run: | tar -xzf dist.tar.gz && mv distil packages/icon-library/dist && mv distdt packages/design-tokens/dist - yarn --cwd packages/react-component-library chromatic --project-token=${{secrets.CHROMATIC_TOKEN}} --ci + yarn --cwd packages/react-component-library storybook:static + echo "$CHROMATIC_SHA" > packages/react-component-library/.static_storybook/sha + echo "$CHROMATIC_BRANCH" > packages/react-component-library/.static_storybook/branch + echo "$CHROMATIC_SLUG" > packages/react-component-library/.static_storybook/slug + + - name: Upload Storybook artefact + uses: actions/upload-artifact@v3 + with: + name: storybook-static + path: packages/react-component-library/.static_storybook diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000000..b923582056 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,38 @@ +name: 'CodeQL security scan' + +on: + push: + branches: [master] + pull_request: + branches: [master] + schedule: + - cron: '16 9 * * 5' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: ['typescript'] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/npmsmoketest.yml b/.github/workflows/npmsmoketest.yml deleted file mode 100644 index acfb32cbbc..0000000000 --- a/.github/workflows/npmsmoketest.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: NPM Smoke Test - -on: - push: - branches: - - master - pull_request: - -jobs: - NPM_smoketest: - runs-on: ubuntu-latest - - steps: - - name: Git clone repository - uses: actions/checkout@v2 - - - name: Cache Node modules - uses: actions/cache@v2 - with: - path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/yarn.lock') }} - - - name: Install Dependencies - run: | - yarn install - - - name: Build design-tokens - run: yarn --cwd packages/design-tokens build - - - name: Build icon-library - run: yarn --cwd packages/icon-library build - - - name: Build react-component-library - run: yarn --cwd packages/react-component-library build - - - name: Update CRA template to use local packages - run: | - TEMPLATE=packages/cra-template-defencedigital/template.json - PACKAGES=( - design-tokens - fonts - icon-library - react-component-library - ) - for i in "${PACKAGES[@]}"; - do - contents="$(jq '.package.dependencies."@defencedigital/'$i'" = "file:'$GITHUB_WORKSPACE'/packages/'$i'"' $TEMPLATE)" \ - && echo "${contents}" > $TEMPLATE - done - cat $TEMPLATE - - - name: Create boilerplate app - run: | - if [ -d "$RUNNER_TEMP/my-app" ]; then rm -Rf $RUNNER_TEMP/my-app ; fi - npx create-react-app $RUNNER_TEMP/my-app --template file:../${{ github.event.repository.name }}/packages/cra-template-defencedigital - - - name: Build boilerlate app - run: | - cd $RUNNER_TEMP/my-app - grep version node_modules/@defencedigital/**/package.json - yarn build - - - name: Lint boilerlate app - run: | - cd $RUNNER_TEMP/my-app - yarn lint diff --git a/.github/workflows/post_build_and_test.yml b/.github/workflows/post_build_and_test.yml new file mode 100644 index 0000000000..21ccafc511 --- /dev/null +++ b/.github/workflows/post_build_and_test.yml @@ -0,0 +1,65 @@ +name: Post Build & Test + +on: + workflow_run: + types: + - completed + workflows: + - 'Build & Test' + +jobs: + Test_visual_regression: + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion == 'success' + steps: + - name: Git clone repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Cache Node modules + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: | + yarn install --frozen-lockfile + + # Based on + # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow + - name: Download pre-built Storybook + uses: actions/github-script@v6 + with: + script: | + const { downloadStorybookArtifact } = await import('${{ github.workspace }}/scripts/github-actions/downloadStorybookArtifact.mjs') + await downloadStorybookArtifact({ github, context }) + + - name: Unzip pre-built Storybook + run: | + unzip storybook-static.zip -d packages/react-component-library/.static_storybook + echo "CHROMATIC_SHA=$(> $GITHUB_ENV + echo "CHROMATIC_BRANCH=$(> $GITHUB_ENV + echo "CHROMATIC_SLUG=$(> $GITHUB_ENV + + - name: Fetch original ref + run: | + git fetch origin "+$CHROMATIC_SHA" + + - name: Run visual regression tests + run: | + cd packages/react-component-library + npm exec --no -- chromatic --project-token=${{secrets.CHROMATIC_TOKEN}} --storybook-build-dir=.static_storybook + + Automerge: + name: Merge Dependabot PR's + runs-on: ubuntu-latest + if: github.actor == 'dependabot[bot]' + needs: [Test_visual_regression] + steps: + - name: Auto merge Dependabot minor and patch version bumps + uses: defencedigital/design-system-mergeme-action@master + with: + GITHUB_TOKEN: ${{ secrets.MERGE_BOT }} + PRESET: DEPENDABOT_MINOR diff --git a/.github/workflows/project_issues.yml b/.github/workflows/project_issues.yml deleted file mode 100644 index bf20229bf2..0000000000 --- a/.github/workflows/project_issues.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Project Automation - move issues - -on: - issues: - types: [labeled] - -jobs: - Move_labelled_issues: - runs-on: ubuntu-latest - steps: - - name: Move small/med labeled issues to Candidates column - uses: defencedigital/design-system-moveissue-action@master - with: - action-token: "${{ secrets.GHA_ISSUES_TOKEN }}" - project-url: "https://github.com/defencedigital/mod-uk-design-system/projects/6" - column-name: "Candidates for Ready" - label-name: "Size: Small,Size: Medium" - columns-to-ignore: "Ready,In Progress,In Review,Done" diff --git a/.github/workflows/project_notify.yml b/.github/workflows/project_notify.yml deleted file mode 100644 index 2e140bf3e9..0000000000 --- a/.github/workflows/project_notify.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Project Automation - notify - -on: - schedule: - - cron: '0 8 * * 1-5' - -jobs: - Notify: - runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Send slack message for triage issues - env: - TRIAGE_URL: https://github.com/defencedigital/mod-uk-design-system/issues?q=is%3Aissue+is%3Aopen+label%3A%22Status%3A+Awaiting+triage%22 - run: | - - result=$(( gh issue list --repo defencedigital/mod-uk-design-system -l 'Status: Awaiting triage' ) 2>&1) - - slack_triage () { - curl -X POST -H 'Content-type: application/json' --data '{"text":"There are <'$TRIAGE_URL'|Triage issues> to review this morning"}' ${{ secrets.SLACK_WEBHOOK }} - } - slack_notriage () { - curl -X POST -H 'Content-type: application/json' --data '{"text":"There are no issues to Triage this morning"}' ${{ secrets.SLACK_WEBHOOK }} - } - - if [[ `echo $result` == *"Awaiting triage"* ]]; then slack_triage ; else slack_notriage; fi - - - name: Send slack message for stale issues - env: - STALE_URL: https://github.com/defencedigital/mod-uk-design-system/issues?q=is%3Aissue+is%3Aopen+label%3A%22Status%3A+Stale%22 - run: | - - result=$(( gh issue list --repo defencedigital/mod-uk-design-system -l 'Status: Stale' ) 2>&1) - - slack_stale () { - curl -X POST -H 'Content-type: application/json' --data '{"text":"There are <'$STALE_URL'|Stale issues> to review this morning"}' ${{ secrets.SLACK_WEBHOOK }} - } - slack_nostale () { - curl -X POST -H 'Content-type: application/json' --data '{"text":"There are no Stale issues to review this morning"}' ${{ secrets.SLACK_WEBHOOK }} - } - - if [[ `echo $result` == *"Status: Stale"* ]]; then slack_stale ; else slack_nostale; fi diff --git a/.github/workflows/project_stale_issues.yml b/.github/workflows/project_stale_issues.yml deleted file mode 100644 index b0afd0b5b0..0000000000 --- a/.github/workflows/project_stale_issues.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Project Automation - stale issues - -on: - schedule: - - cron: '0 1 * * 1' - -jobs: - Update_stale_issues: - runs-on: ubuntu-latest - steps: - - name: Add label & comment to stale issues - uses: actions/stale@v3 - with: - stale-issue-message: 'This issue has been marked as stale because it has been open for 60 days with no activity' - days-before-stale: 60 - days-before-close: -1 - stale-issue-label: 'Status: Stale' - exempt-issue-labels: 'Release: Next major' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 1792ee13df..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,89 +0,0 @@ -name: Release - -on: - schedule: - - cron: '0 4 * * 1-5' - -jobs: - release: - name: 'Release & Publish' - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v2 - with: - # pulls all commits (needed for lerna / semantic release to correctly version) - fetch-depth: 0 - token: ${{ secrets.GH_TOKEN }} - - - name: Pull all tags - # pulls all tags (needed for lerna / semantic release to correctly version) - run: git fetch --all --tags - - - name: Setup Node.js - uses: actions/setup-node@v1 - with: - node-version: 16 - registry-url: 'https://registry.npmjs.org' - - - name: Install dependencies - run: yarn install - - - name: Get version from lerna.json before release step - id: initversion - run: | - echo "::set-output name=version::$(grep '"version":' lerna.json | cut -d\" -f4)" - - - name: Check for package changes - id: changes - run: | - npx lerna changed 2>&1 | tail -1 |tee outfile - echo "::set-output name=changed::$(cat outfile)" - - - name: GitHub Release - id: release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GIT_AUTHOR_NAME: ${{ secrets.GH_NAME }} - GIT_AUTHOR_EMAIL: ${{ secrets.GH_EMAIL }} - GIT_COMMITTER_NAME: ${{ secrets.GH_NAME }} - GIT_COMMITTER_EMAIL: ${{ secrets.GH_EMAIL }} - if: contains(steps.changes.outputs.changed, 'ready to publish') - run: "yarn lerna:run-version --yes --create-release github -m \"chore(Release): %v [skip ci]\" --conventional-commits" - - - name: Get version from package.json after release step - id: extractver - run: | - echo "::set-output name=version::$(grep '"version":' lerna.json | cut -d\" -f4)" - - - name: Confirm version changes - run: | - echo "the initial version is ${{steps.initversion.outputs.version}}" - echo "the updated version is ${{steps.extractver.outputs.version}}" - - - name: Publish NPM packages - if: steps.initversion.outputs.version != steps.extractver.outputs.version - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - run: | - npm publish --tag latest ./packages/design-tokens - npm publish --tag latest ./packages/eslint-config-react - npm publish --tag latest ./packages/fonts - npm publish --tag latest ./packages/icon-library - npm publish --tag latest ./packages/react-component-library - npm publish --tag latest ./packages/cra-template-defencedigital - - - name: Publish Storybook - if: steps.initversion.outputs.version != steps.extractver.outputs.version - run: | - curl -X POST -d {} ${{ secrets.STORYBOOK_TOKEN }} - - - name: Send notification on failure - if: failure() - env: - SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }} - uses: defencedigital/design-system-slacknotify-action@master - with: - channel_id: C02H226CT33 - status: FAILED - color: danger diff --git a/README.md b/README.md index 8e33b32b5e..1fecce836d 100644 --- a/README.md +++ b/README.md @@ -1,128 +1 @@ -# MOD.UK [Design System](https://design-system.digital.mod.uk/) - - ![Build & Test Master](https://github.com/defencedigital/mod-uk-design-system/workflows/Build%20&%20Test%20Master/badge.svg) - [![GitHub release](https://img.shields.io/github/release/royal-navy/design-system.svg)](https://github.com/defencedigital/mod-uk-design-system/releases) [![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://github.com/design-system/blob/master/LICENSE) [![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=defencedigital_mod-uk-design-system&metric=coverage)](https://sonarcloud.io/dashboard?id=defencedigital_mod-uk-design-system) [![Storybook](https://cdn.jsdelivr.net/gh/storybookjs/brand@master/badge/badge-storybook.svg)](http://storybook.design-system.digital.mod.uk) - -Build web applications that meet the Defence Digital service standards. - -Visit the [Roadmap board](https://github.com/defencedigital/mod-uk-design-system/projects/7) to view the high-level objectives for the MOD.UK Design System. To check on issues currently being completed, view our [Tactical board](https://github.com/defencedigital/mod-uk-design-system/projects/6) instead. - -## Releases & versioning - -All packages are published to the [NPM registry](https://www.npmjs.com/search?q=%40defencedigital) and we adhere to [semantic versioning](https://semver.org/). - -## Supported technologies - -The following view layer libraries are currently supported: - -- React - -## Component usage guidelines - -Please refer to the [component demo pages](https://design-system.digital.mod.uk/components) and [Storybook](http://storybook.design-system.digital.mod.uk/) to see interactive examples, code snippets and details on how best to consume each of the components. - -## Installation & quick start - -### Installation - -To install and save to your project's package.json dependencies, run: - -``` -# with npm -npm install @defencedigital/fonts @defencedigital/react-component-library styled-components - -# ...or with yarn -yarn add @defencedigital/fonts @defencedigital/react-component-library styled-components -``` - -Note: [`styled-components`](https://styled-components.com/) is a required [peer dependency](https://nodejs.org/en/blog/npm/peer-dependencies/) and is installed with the above command. - -### Quick start - -Here's a quick example application to get you started: - -```javascript -import React from 'react' -import ReactDOM from 'react-dom' -import '@defencedigital/fonts' -import { GlobalStyleProvider, Button } from '@defencedigital/react-component-library' - -function App() { - return ( - - - - ) -} - -ReactDOM.render(, document.querySelector('#app')) -``` - -## Monorepo & package management - ->Splitting up large codebases into separate independently versioned packages is extremely useful for code sharing. However, making changes across many repositories is messy and difficult to track, and testing across repositories gets complicated really fast. -> ->To solve these (and many other) problems, some projects will organize their codebases into multi-package repositories (sometimes called monorepos). - -Each package folder has it's own npm package.json and can act like a stand alone project. Yarn workspaces detects dependencies that are held within the monorepo and creates a link between them, so you can work on a react component and see instant updates in Storybook. - -Manage dependencies for packages like normal, but remember to use `yarn add` instead of `npm install`. - -## Run locally - -You'll need [Git](https://help.github.com/articles/set-up-git/) and [Node.js](https://nodejs.org/en/) installed to get this project running. - -Note: You will need the [active LTS (Long-term support)](https://github.com/nodejs/Release#release-schedule) Node.js version for this project (as specified in [.nvmrc](./.nvmrc)) - -### Fork repository (optional) -If you're an external contributor make sure to [fork this project first](https://help.github.com/articles/fork-a-repo/) - -### Clone repository -``` -git clone git@github.com:Royal-Navy/design-system.git # or clone your own fork - -cd design-system -``` - -### Using nvm (optional) -If you work across multiple Node.js projects there's a good chance they require different Node.js and npm versions. - -To enable this we use [nvm (Node Version Manager)](https://github.com/creationix/nvm) to switch between versions easily. - -1. [Install nvm](https://github.com/creationix/nvm#installation) -2. Run `nvm install` in the project directory (this will use [.nvmrc](./.nvmrc)) - -## Scripts - -The top level project contains scripts that are then executed for all packages. - -- `lint` Checks syntax and simple errors in javascript files. -- `test` Runs Jest tests in all the packages. -- `build` Runs the build script in all packages. - -## Git hooks - -Git commit hooks trigger linting of all staged files when a change is committed. - -## Prettier - -We have configured a set of Prettier options to enforce consistent code formatting. - -## Browser support - -The MOD.UK Design System currently supports all major evergreen browsers. - -## Licensing - -The defencedigital/mod-uk-design-system is licensed under the [Apache License 2.0](https://github.com/defencedigital/mod-uk-design-system/blob/master/LICENSE). - -## Contributing -Read the [contributing guidelines](docs/contributing.md). - -## Thanks - - - -We use [Chromatic](https://www.chromaticqa.com/) for visual regression testing. +# This repo is for testing GitHub Actions only. diff --git a/packages/react-component-library/src/components/Button/Button.stories.tsx b/packages/react-component-library/src/components/Button/Button.stories.tsx index f9c9c56365..1dc1c254ac 100644 --- a/packages/react-component-library/src/components/Button/Button.stories.tsx +++ b/packages/react-component-library/src/components/Button/Button.stories.tsx @@ -27,7 +27,7 @@ Default.args = { export const Primary = Template.bind({}) Primary.args = { variant: BUTTON_VARIANT.PRIMARY, - children: 'Primary', + children: 'Primary changed', } export const PrimaryDisabled = Template.bind({}) @@ -35,7 +35,7 @@ PrimaryDisabled.storyName = 'Primary, disabled' PrimaryDisabled.args = { variant: BUTTON_VARIANT.PRIMARY, isDisabled: true, - children: 'Primary, disabled', + children: 'Primary, disabled, changed', } export const PrimaryLoading = Template.bind({}) diff --git a/scripts/github-actions/downloadStorybookArtifact.mjs b/scripts/github-actions/downloadStorybookArtifact.mjs new file mode 100644 index 0000000000..211f91e3f8 --- /dev/null +++ b/scripts/github-actions/downloadStorybookArtifact.mjs @@ -0,0 +1,22 @@ +import fs from 'fs' + +export const downloadStorybookArtifact = async ({ github, context }) => { + const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id, + }) + + const matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name === 'storybook-static' + })[0] + + const download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }) + + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/storybook-static.zip`, Buffer.from(download.data)) +} diff --git a/sonar-project.properties b/sonar-project.properties index 371c363f69..368f4be54d 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,7 +1,8 @@ -sonar.organization=defencedigital -sonar.projectKey=defencedigital_mod-uk-design-system +sonar.projectKey=jpveooys_github-actions-testing +sonar.organization=jpveooys + # This is the name and version displayed in the SonarCloud UI. -sonar.projectName=mod-uk-design-system +sonar.projectName=github-actions-testing #sonar.projectVersion=1.0 # Path to sources diff --git a/test-pr-fork b/test-pr-fork new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/test-pr-fork @@ -0,0 +1 @@ + diff --git a/yarn.lock b/yarn.lock index 7ebf7d8ad0..4f472160dc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -830,9 +830,9 @@ babel-plugin-dynamic-import-node "^2.3.3" "@babel/plugin-transform-modules-commonjs@^7.16.7", "@babel/plugin-transform-modules-commonjs@^7.8.3": - version "7.17.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.17.7.tgz#d86b217c8e45bb5f2dbc11eefc8eab62cf980d19" - integrity sha512-ITPmR2V7MqioMJyrxUo2onHNC3e+MvfFiFIR0RP21d3PtlVb6sfzoxNKiphSZUOM9hEIdzCcZe83ieX3yoqjUA== + version "7.17.9" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.17.9.tgz#274be1a2087beec0254d4abd4d86e52442e1e5b6" + integrity sha512-2TBFd/r2I6VlYn0YRTz2JdazS+FoUuQ2rIFHoAxtyP/0G3D82SBLaRq9rnUkpqlLg03Byfl/+M32mpxjO6KaPw== dependencies: "@babel/helper-module-transforms" "^7.17.7" "@babel/helper-plugin-utils" "^7.16.7" @@ -2985,7 +2985,7 @@ global "^4.4.0" regenerator-runtime "^0.13.7" -"@storybook/addons@6.5.0-alpha.55", "@storybook/addons@^6.5.0-alpha.49": +"@storybook/addons@6.5.0-alpha.55": version "6.5.0-alpha.55" resolved "https://registry.yarnpkg.com/@storybook/addons/-/addons-6.5.0-alpha.55.tgz#28228ac7d13994d05d2b6ceaaf1d7cad5b9fc755" integrity sha512-XOjVXc+v3UNPnS3jmySlYoznK9SE+SgwLxJ9GMnIsDCRBQLT7duebTJHl74p0nmgGHj7h64x652PyCNi5M721Q== @@ -3002,6 +3002,23 @@ global "^4.4.0" regenerator-runtime "^0.13.7" +"@storybook/addons@^6.5.0-alpha.49": + version "6.5.0-alpha.59" + resolved "https://registry.yarnpkg.com/@storybook/addons/-/addons-6.5.0-alpha.59.tgz#e7e338fde3f2ee7229a80a8571500f2bd4d8e287" + integrity sha512-9JRvNxoZKBMFP5zpvA4leG2krxle1vq6U/vDQZiCPGqr5Tz5X2t/2utHpa4vakNuUD0GI2GqIc9inuqeGy8TsA== + dependencies: + "@storybook/api" "6.5.0-alpha.59" + "@storybook/channels" "6.5.0-alpha.59" + "@storybook/client-logger" "6.5.0-alpha.59" + "@storybook/core-events" "6.5.0-alpha.59" + "@storybook/csf" "0.0.2--canary.7c6c115.0" + "@storybook/router" "6.5.0-alpha.59" + "@storybook/theming" "6.5.0-alpha.59" + "@types/webpack-env" "^1.16.0" + core-js "^3.8.2" + global "^4.4.0" + regenerator-runtime "^0.13.7" + "@storybook/api@6.5.0-alpha.49": version "6.5.0-alpha.49" resolved "https://registry.yarnpkg.com/@storybook/api/-/api-6.5.0-alpha.49.tgz#c845a06dbaba99f9442d377f9b739592ed4d768f" @@ -3071,6 +3088,29 @@ ts-dedent "^2.0.0" util-deprecate "^1.0.2" +"@storybook/api@6.5.0-alpha.59": + version "6.5.0-alpha.59" + resolved "https://registry.yarnpkg.com/@storybook/api/-/api-6.5.0-alpha.59.tgz#81d11a7cbe2693cffa5a6099d8983a53e1a2841f" + integrity sha512-SOVQQ793N8A8W0HqWPVZ3K1yCU3i9el7nip7NXu630gTW3zS7aK96R1SnIi0IVGAz8r8YPLNvsCdDxohvTZyVw== + dependencies: + "@storybook/channels" "6.5.0-alpha.59" + "@storybook/client-logger" "6.5.0-alpha.59" + "@storybook/core-events" "6.5.0-alpha.59" + "@storybook/csf" "0.0.2--canary.7c6c115.0" + "@storybook/router" "6.5.0-alpha.59" + "@storybook/semver" "^7.3.2" + "@storybook/theming" "6.5.0-alpha.59" + core-js "^3.8.2" + fast-deep-equal "^3.1.3" + global "^4.4.0" + lodash "^4.17.21" + memoizerific "^1.11.3" + regenerator-runtime "^0.13.7" + store2 "^2.12.0" + telejson "^5.3.3" + ts-dedent "^2.0.0" + util-deprecate "^1.0.2" + "@storybook/babel-plugin-require-context-hook@1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@storybook/babel-plugin-require-context-hook/-/babel-plugin-require-context-hook-1.0.1.tgz#0a4ec9816f6c7296ebc97dd8de3d2b7ae76f2e26" @@ -3314,6 +3354,15 @@ ts-dedent "^2.0.0" util-deprecate "^1.0.2" +"@storybook/channels@6.5.0-alpha.59": + version "6.5.0-alpha.59" + resolved "https://registry.yarnpkg.com/@storybook/channels/-/channels-6.5.0-alpha.59.tgz#475d1bbe438eacb02d0b0dcc7be9ed3db1f5ac99" + integrity sha512-Dbr2DOSrtifUaHdAqEY7Ng/93q8apCtF/s+DF1ZE7R5NLPPaNSqm+ieqAWpbPhSFSW1ynAcSj/th9LWZgkZ9bQ== + dependencies: + core-js "^3.8.2" + ts-dedent "^2.0.0" + util-deprecate "^1.0.2" + "@storybook/client-api@6.5.0-alpha.49": version "6.5.0-alpha.49" resolved "https://registry.yarnpkg.com/@storybook/client-api/-/client-api-6.5.0-alpha.49.tgz#248e9ad2c4ca2f1927348e8cd925a02cf46cf0cc" @@ -3390,6 +3439,14 @@ core-js "^3.8.2" global "^4.4.0" +"@storybook/client-logger@6.5.0-alpha.59": + version "6.5.0-alpha.59" + resolved "https://registry.yarnpkg.com/@storybook/client-logger/-/client-logger-6.5.0-alpha.59.tgz#a0a63c43cfc8013cd4861c66de2f4fa73bf6d295" + integrity sha512-86N5wvjJAS1/oIyIMgU5/PSSPeAcptrsrIZY96Dpg9y6gaupPkFc0JzBuFUAinVpIHzr3E/8FjTmac6DaQ1ncA== + dependencies: + core-js "^3.8.2" + global "^4.4.0" + "@storybook/components@6.5.0-alpha.49": version "6.5.0-alpha.49" resolved "https://registry.yarnpkg.com/@storybook/components/-/components-6.5.0-alpha.49.tgz#1b513395531ccc61431f5a053e16ae72a1458847" @@ -3664,6 +3721,13 @@ dependencies: core-js "^3.8.2" +"@storybook/core-events@6.5.0-alpha.59": + version "6.5.0-alpha.59" + resolved "https://registry.yarnpkg.com/@storybook/core-events/-/core-events-6.5.0-alpha.59.tgz#c09eaf9d840e13cf4b43a3f78464d34449d14a81" + integrity sha512-cX1qgrA5CHFCRjwENbh92kdX3Qu17nCv4dgJ1g6I48M9Nut5+SGHJiMH6FqqBsoiR7eqScrDR1gh11eTHsW7HQ== + dependencies: + core-js "^3.8.2" + "@storybook/core-server@6.5.0-alpha.49": version "6.5.0-alpha.49" resolved "https://registry.yarnpkg.com/@storybook/core-server/-/core-server-6.5.0-alpha.49.tgz#89f9521a2c628d6196de193639fb377a68ee3932" @@ -3827,6 +3891,13 @@ dependencies: lodash "^4.17.15" +"@storybook/csf@0.0.2--canary.7c6c115.0": + version "0.0.2--canary.7c6c115.0" + resolved "https://registry.yarnpkg.com/@storybook/csf/-/csf-0.0.2--canary.7c6c115.0.tgz#91724e34be7b168acddb8df7e7821ed371ce31ff" + integrity sha512-LRIDJp2JionBqZ4/c2DncDk5jGzd3sua92jGbQVRtVyIGdaAVDuNtqXY9Fh+yzO7QE03Cm+BEs59Yat5J7EdEQ== + dependencies: + lodash "^4.17.15" + "@storybook/csf@0.0.2--canary.87bc651.0": version "0.0.2--canary.87bc651.0" resolved "https://registry.yarnpkg.com/@storybook/csf/-/csf-0.0.2--canary.87bc651.0.tgz#c7b99b3a344117ef67b10137b6477a3d2750cf44" @@ -4183,6 +4254,15 @@ core-js "^3.8.2" regenerator-runtime "^0.13.7" +"@storybook/router@6.5.0-alpha.59": + version "6.5.0-alpha.59" + resolved "https://registry.yarnpkg.com/@storybook/router/-/router-6.5.0-alpha.59.tgz#ee031bdf91c9509c2a6c8d3f6fccdcb6ee2df64b" + integrity sha512-OfIXWKVZWMbRFR+LotUrgJFW0WZHq0PCYor2CvUNQqxAHi2EMeJh0TteqUJPmAxdjk2nt2gFMJBKh4WA/hCmqQ== + dependencies: + "@storybook/client-logger" "6.5.0-alpha.59" + core-js "^3.8.2" + regenerator-runtime "^0.13.7" + "@storybook/semver@^7.3.2": version "7.3.2" resolved "https://registry.yarnpkg.com/@storybook/semver/-/semver-7.3.2.tgz#f3b9c44a1c9a0b933c04e66d0048fcf2fa10dac0" @@ -4297,6 +4377,15 @@ core-js "^3.8.2" regenerator-runtime "^0.13.7" +"@storybook/theming@6.5.0-alpha.59": + version "6.5.0-alpha.59" + resolved "https://registry.yarnpkg.com/@storybook/theming/-/theming-6.5.0-alpha.59.tgz#001f146772cf0e3df2cc58ac38ec584f7ec10ea7" + integrity sha512-kTISuyJhN1fTE2l1rAqIvJcgOlpVRIiomrRE4RNiiGc4Yu7guNyxTFe945Wokw+JubKkwzLEvkHXTzC9H0f95g== + dependencies: + "@storybook/client-logger" "6.5.0-alpha.59" + core-js "^3.8.2" + regenerator-runtime "^0.13.7" + "@storybook/ui@6.5.0-alpha.49": version "6.5.0-alpha.49" resolved "https://registry.yarnpkg.com/@storybook/ui/-/ui-6.5.0-alpha.49.tgz#bb860f536880585cd46209ac4ee1296cb944fffa" @@ -4722,9 +4811,9 @@ integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= "@types/lodash@^4.14.149", "@types/lodash@^4.14.161", "@types/lodash@^4.14.167": - version "4.14.180" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.180.tgz#4ab7c9ddfc92ec4a887886483bc14c79fb380670" - integrity sha512-XOKXa1KIxtNXgASAnwj7cnttJxS4fksBRywK/9LzRV5YxrF80BXZIGeQSuoESQ/VkUj30Ae0+YcuHc15wJCB2g== + version "4.14.181" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.181.tgz#d1d3740c379fda17ab175165ba04e2d03389385d" + integrity sha512-n3tyKthHJbkiWhDZs3DkhkCzt2MexYHXlX0td5iMplyfwketaOeKboEVBqzceH7juqvEg3q5oUoBFxSLu7zFag== "@types/mdast@^3.0.0": version "3.0.10"