Skip to content

Commit

Permalink
feat: migrate on npm and update design system
Browse files Browse the repository at this point in the history
  • Loading branch information
fpasquet committed Jan 4, 2024
1 parent e029c64 commit ab42b19
Show file tree
Hide file tree
Showing 52 changed files with 24,576 additions and 12,873 deletions.
21 changes: 4 additions & 17 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 120
trim_trailing_whitespace = true

[*.js]
indent_size = 2

[*.scss]
indent_size = 2

[*.rb]
indent_size = 2

[Rakefile]
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
11 changes: 11 additions & 0 deletions .github/actions/restore-npm-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: restore-npm-cache
description: Restore NPM Cache
runs:
using: composite
steps:
- name: Restore NPM Cache
uses: actions/cache@v3
with:
path: "**/node_modules"
key: cache-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: cache-node-modules-npm run
115 changes: 115 additions & 0 deletions .github/workflows/checks-and-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Run checks and tests

on: [ pull_request ]

jobs:
setup:
uses: ./.github/workflows/setup-nodejs-and-install-dependencies.yml

validate-markdown:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Validate markdown authors and posts
id: validate_markdown
run: npm run validate-markdown --ci

- name: Add a comment to the PR after failed markdown validation
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request' && failure()
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: validate-markdown
message: |
#### Markdown invalid 🖌
The markdown of the file **${{ steps.validate_markdown.outputs.filePath }}** is invalid !
> ${{ steps.validate_markdown.outputs.reason }}
- name: Remove a comment to the PR after success markdown validation
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request' && success()
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: validate-markdown
delete: true

eslint:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Restore NPM Cache
uses: ./.github/actions/restore-npm-cache

- name: Lint code
run: npm run lint:es

stylelint:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Restore NPM Cache
uses: ./.github/actions/restore-npm-cache

- name: Lint code
run: npm run lint:style

compile:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Restore NPM Cache
uses: ./.github/actions/restore-npm-cache

- name: Run Compile TypeScript
run: npx tsc

test:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Restore NPM Cache
uses: ./.github/actions/restore-npm-cache

- name: Run Tests
run: npm run test

build:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Restore NPM Cache
uses: ./.github/actions/restore-npm-cache

- name: Build Design System
run: npm run build

build-storybook:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Restore NPM Cache
uses: ./.github/actions/restore-npm-cache

- name: Build Storybook
run: npm run build:storybook
24 changes: 9 additions & 15 deletions .github/workflows/deploy-storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,23 @@ on:
branches:
- master
jobs:
setup:
uses: ./.github/workflows/setup-nodejs-and-install-dependencies.yml

build-and-deploy-storybook:
runs-on: ubuntu-latest
needs: setup
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install modules
run: yarn install --frozen-lockfile
- name: Checkout Repository
uses: actions/checkout@v4

- name: Build Storybook
run: yarn build:storybook
run: npm run build:storybook

- name: Deploy Storybook
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
66 changes: 6 additions & 60 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ env:
AWS_DEFAULT_REGION: eu-west-2

jobs:
setup:
uses: ./.github/workflows/setup-nodejs-and-install-dependencies.yml

deploy:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -41,66 +45,8 @@ jobs:
echo "GTM_ID=${{ secrets.GTM_ID_PRODUCTION }}" >> $GITHUB_ENV
echo "GOOGLE_SITE_VERIFICATION==${{ secrets.GOOGLE_SITE_VERIFICATION }}" >> $GITHUB_ENV
- name: Setup node
uses: actions/setup-node@v3
with:
bundler-cache: true
node-version: 16

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "yarnCacheDir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.yarnCacheDir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install modules
run: yarn install --frozen-lockfile

- name: Validate markdown authors and posts
id: validate_markdown
run: yarn validate-markdown --ci

- name: Add a comment to the PR after failed markdown validation
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request' && failure()
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: validate-markdown
message: |
#### Markdown invalid 🖌
The markdown of the file **${{ steps.validate_markdown.outputs.filePath }}** is invalid !
> ${{ steps.validate_markdown.outputs.reason }}
- name: Remove a comment to the PR after success markdown validation
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request' && success()
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: validate-markdown
delete: true

- name: Run ESLint
run: yarn lint:es

- name: Run Stylelint
run: yarn lint:style

- name: Run Compile TypeScript
run: yarn tsc

- name: Run Test
run: yarn test

- name: Build
run: yarn prerender
run: npm run prerender
env:
NODE_ENV: production
BASE_URL: ${{ env.BASE_URL }}
Expand Down Expand Up @@ -140,7 +86,7 @@ jobs:
aws cloudfront create-invalidation --distribution-id "${{ secrets.CLOUDFRONT_DISTRIBUTION }}" --paths "/*"
- name: Indexing on Algolia
run: yarn indexation:algolia
run: npm run indexation:algolia
env:
ALGOLIA_APP_ID: ${{ env.ALGOLIA_APP_ID }}
ALGOLIA_API_INDEXING_KEY: ${{ env.ALGOLIA_API_INDEXING_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: PR Closed

on:
pull_request_target:
types: [closed]
types: [ closed ]

env:
AWS_DEFAULT_REGION: eu-west-2
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/setup-nodejs-and-install-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Setup Node.js and install dependencies

on:
workflow_call:
inputs:
node-version:
required: false
description: Node version to setup
type: string
default: 20.x
runner:
required: false
description: Job runner
type: string
default: ubuntu-latest

jobs:
setup-nodejs-and-install-dependencies:
runs-on: ${{ inputs.runner }}

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: npm

- name: Cache dependencies
uses: actions/cache@v3
id: manager-cache-node-modules
with:
path: "**/node_modules"
key: cache-node-modules-${{ hashFiles('**/package-lock.json') }}

- name: Install dependencies
if: steps.manager-cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: '3'
services:
node:
image: node:18-alpine
image: node:20-alpine
user: node:node
working_dir: /var/www/app
volumes:
- .:/var/www/app
command: ['sh', '-c', 'yarn --production=false --frozen-lockfile && npx --yes concurrently "yarn start:storybook" "yarn start:dev"']
command: ['sh', '-c', 'npm ci && npx --yes concurrently "npm run start:storybook" "npm run start:dev"']
ports:
- 6009:6009
- 5173:5173
Expand Down
Loading

0 comments on commit ab42b19

Please sign in to comment.