Skip to content

Commit

Permalink
feat: update dependencies and configurations (#101)
Browse files Browse the repository at this point in the history
* feat: update dependencies and configurations

* ci: removal of npm

* ci: updated actions versions

* ci: added more robust installation step

* ci: move corepack to earlier

* ci: remove checks and package env

* chore: remove deps from lock file

* chore: cleanup names and remove setup-node cache
  • Loading branch information
Swiftwork committed Jun 3, 2024
1 parent bbf59ef commit eaec03c
Show file tree
Hide file tree
Showing 36 changed files with 13,478 additions and 17,041 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

[*.{js,ts,jsx,tsx,html,css,json,yml,yaml,md}]
quote_type = single
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 120
49 changes: 0 additions & 49 deletions .eslintrc.js

This file was deleted.

98 changes: 98 additions & 0 deletions .github/actions/install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Reference https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a

name: 'Install dependencies'
description: 'Run yarn install with node_modules linker and cache enabled'
inputs:
cwd:
description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()"
required: false
default: '.'
cache-npm-cache:
description: 'Cache npm global cache folder often used by node-gyp, prebuild binaries (invalidated on lock/os/node-version)'
required: false
default: 'true'
cache-node-modules:
description: 'Cache node_modules, might speed up link step (invalidated lock/os/node-version/branch)'
required: false
default: 'false'
cache-install-state:
description: 'Cache yarn install state, might speed up resolution step when node-modules cache is activated (invalidated lock/os/node-version/branch)'
required: false
default: 'false'

runs:
using: 'composite'
steps:
- name: ⚙️ Expose yarn config as "$GITHUB_OUTPUT"
id: yarn-config
shell: bash
working-directory: ${{ inputs.cwd }}
env:
YARN_ENABLE_GLOBAL_CACHE: 'false'
run: |
CACHE_FOLDER=$(yarn config get cacheFolder) || { echo "Failed to get Yarn cache folder"; exit 1; }
echo "CACHE_FOLDER=$CACHE_FOLDER" >> $GITHUB_OUTPUT
CURRENT_NODE_VERSION="node-$(node --version)" || { echo "Failed to get Node version"; exit 1; }
echo "CURRENT_NODE_VERSION=$CURRENT_NODE_VERSION" >> $GITHUB_OUTPUT
CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's,/,-,g') || { echo "Failed to get current branch"; exit 1; }
echo "CURRENT_BRANCH=$CURRENT_BRANCH" >> $GITHUB_OUTPUT
NPM_GLOBAL_CACHE_FOLDER=$(npm config get cache) || { echo "Failed to get NPM global cache folder"; exit 1; }
echo "NPM_GLOBAL_CACHE_FOLDER=$NPM_GLOBAL_CACHE_FOLDER" >> $GITHUB_OUTPUT
- name: ♻️ Show exposed yarn-config
shell: bash
run: |
echo "Cache folder: ${{ steps.yarn-config.outputs.CACHE_FOLDER }}"
echo "Current Node Version: ${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}"
echo "Current Branch: ${{ steps.yarn-config.outputs.CURRENT_BRANCH }}"
echo "NPM Global Cache: ${{ steps.yarn-config.outputs.NPM_GLOBAL_CACHE_FOLDER }}"
- name: ♻️ Restore yarn cache
uses: actions/cache@v4
id: yarn-download-cache
with:
path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }}
key: yarn-download-cache-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}
restore-keys: |
yarn-download-cache-
- name: ♻️ Restore node_modules
if: inputs.cache-node-modules == 'true'
id: yarn-nm-cache
uses: actions/cache@v4
with:
path: ${{ inputs.cwd }}/**/node_modules
key: yarn-nm-cache-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}

- name: ♻️ Restore global npm cache folder
if: inputs.cache-npm-cache == 'true'
id: npm-global-cache
uses: actions/cache@v4
with:
path: ${{ steps.yarn-config.outputs.NPM_GLOBAL_CACHE_FOLDER }}
key: npm-global-cache-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}

- name: ♻️ Restore yarn install state
if: inputs.cache-install-state == 'true' && inputs.cache-node-modules == 'true'
id: yarn-install-state-cache
uses: actions/cache@v4
with:
path: ${{ inputs.cwd }}/.yarn/ci-cache
key: yarn-install-state-cache-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}

- name: 📥 Install dependencies
shell: bash
working-directory: ${{ inputs.cwd }}
run: yarn install --immutable --inline-builds
env:
# Overrides/align yarnrc.yml options (v3, v4) for a CI context
YARN_ENABLE_GLOBAL_CACHE: 'false' # Use local cache folder to keep downloaded archives
YARN_ENABLE_MIRROR: 'false' # Prevent populating global cache for caches misses (local cache only)
YARN_NM_MODE: 'hardlinks-local' # Reduce node_modules size
# Might speed up resolution step when node_modules present
YARN_INSTALL_STATE_PATH: ${{ steps.yarn-install-state-cache.outputs.cache-hit == 'true' && '.yarn/ci-cache/install-state.gz' || '.yarn/install-state.gz' }}
# Other environment variables
HUSKY: '0' # By default do not run HUSKY install
110 changes: 50 additions & 60 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,50 @@
name: Continuous Delivery

on:
push:
branches:
- master
- release/*

jobs:
delivery:
name: Node 18.x
runs-on: ubuntu-latest

steps:
- name: Check out source code
uses: actions/checkout@v2-beta
with:
fetch-depth: 0

- name: Set global git user and email
run: |
git config --global user.name "GitHub Action"
git config --global user.email "action@github.com"
- name: Set up Node.js version 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: https://npm.pkg.github.com
scope: trutoo

- name: Append npm registry authentication to .npmrc
run: |
echo -e '\n//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}\n' >> ${NPM_CONFIG_USERCONFIG}
- name: Install dependencies using CI
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Used in .npmrc to install packages from github

- name: Run tests on package
run: npm test

- name: Update coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Build and publish package to GitHub Packages and GitHub Release
run: npm run release
env:
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Used to verify access through semantic release
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Used by standard npm publish
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Used for github releases through semantic release

- name: Publish package to NPM
run: npm publish --access public --@trutoo:registry=https://registry.npmjs.org
if: env.VERSION != null # Only if semantic-release publishes the package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # Used by standard npm publish
name: Continuous Delivery

on:
push:
branches:
- main
- release/*

jobs:
delivery:
name: Node 20.x
runs-on: ubuntu-latest

steps:
- name: ☁️ Check out source code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: ⚙️ Set global git user and email
run: |
git config --global user.name "GitHub Action"
git config --global user.email "action@github.com"
- name: ⚙️ Enable corepack
shell: bash
run: corepack enable

- name: ⚙️ Set up Node.js version 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: 📥 Install dependencies
uses: ./.github/actions/install

- name: 🧪 Run tests on package
run: yarn test

- name: 📝 Update coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: 🚀 Build and publish package to GitHub Packages and GitHub Release
run: yarn release
env:
NPM_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} # Used to verify access through semantic release
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} # Used by standard npm publish
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Used for github releases through semantic release
98 changes: 49 additions & 49 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
name: Continuous Integration

on:
push:
branches:
- develop
- feature/*
- release/*
- hotfix/*
- renovate/*
pull_request:
branches:
- master

jobs:
integration:
name: Node ${{ matrix.node }}
runs-on: ubuntu-latest

strategy:
matrix:
node: [16.x, 17.x, 18.x]

steps:
- name: Check out source code
uses: actions/checkout@v2-beta

- name: Set up Node.js version ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
registry-url: https://npm.pkg.github.com
scope: trutoo

- name: Install dependencies using CI
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Used in .npmrc to install packages from github

- name: Run tests on package
run: npm test

- name: Update coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Build package
run: npm run build
name: Continuous Integration

on:
push:
branches:
- develop
- feature/*
- release/*
- hotfix/*
- renovate/*
pull_request:
branches:
- main

jobs:
integration:
name: Node ${{ matrix.node }}
runs-on: ubuntu-latest

strategy:
matrix:
node: [18.x, 20.x]

steps:
- name: ☁️ Check out source code
uses: actions/checkout@v4

- name: ⚙️ Enable corepack
shell: bash
run: corepack enable

- name: ⚙️ Set up Node.js version ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- name: 📥 Install dependencies
uses: ./.github/actions/install

- name: 🧪 Run tests on package
run: yarn test

- name: 📝 Update coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: 📦 Build package
run: yarn build
Loading

0 comments on commit eaec03c

Please sign in to comment.