Skip to content

Commit

Permalink
LOP v4 (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrvk committed Mar 12, 2024
1 parent c1d6715 commit 09ebe96
Show file tree
Hide file tree
Showing 134 changed files with 8,437 additions and 12,276 deletions.
51 changes: 1 addition & 50 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,3 @@
module.exports = {
root: true,
env: {
node: true
},
ignorePatterns: ['*.mock.ts'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'unused-imports'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended'
],
rules: {
'@typescript-eslint/member-ordering': 'error',
'lines-between-class-members': 'error',
'padding-line-between-statements': [
'error',
{blankLine: 'always', prev: '*', next: 'return'},
{blankLine: 'always', prev: '*', next: 'if'},
{blankLine: 'always', prev: 'if', next: '*'},
{blankLine: 'always', prev: 'for', next: '*'},
{blankLine: 'always', prev: '*', next: 'for'}
],
'@typescript-eslint/adjacent-overload-signatures': 'off',
'no-unused-vars': 'off',
'no-prototype-builtins': 'off',
'max-len': ['error', {code: 160, ignoreComments: true}],
'max-depth': ['error', 3],
'max-lines-per-function': ['error', 255],
'max-params': ['error', 10],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{argsIgnorePattern: '^_'}
],
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': 0,
'no-async-promise-executor': 0,
'no-console': 'error',
'@typescript-eslint/explicit-function-return-type': 'error'
},
overrides: [
{
files: ['src/**/*.spec.ts'],
rules: {
'max-lines-per-function': ['error', 400],
'max-len': ['error', {code: 1130}]
}
}
]
extends: ['@1inch']
}
35 changes: 35 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: PR validation

on:
pull_request:

jobs:
check:
name: Lint, Types & Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm

- name: Install Dependencies
run: pnpm install

- name: Linter
run: pnpm lint

- name: Types
run: pnpm lint:types

- name: Unit tests
run: pnpm test
106 changes: 0 additions & 106 deletions .github/workflows/pr.yml

This file was deleted.

72 changes: 72 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Publish package

on:
push:
tags:
- v*.*.*
workflow_dispatch:

jobs:
publish-to-npm:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
scope: ${{ github.repository_owner }}
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm build

- name: Publish 🚀
run: pnpm publish --no-git-checks --access=public
working-directory: dist
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

publish-to-github:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm build

- name: Auth in GitHub private registry npm
run: |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > .npmrc
echo "@1inch:registry=https://npm.pkg.github.com" >> .npmrc
- name: Publish 🚀
run: pnpm publish --no-git-checks
working-directory: dist
110 changes: 53 additions & 57 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,74 +1,70 @@
name: Publish package
name: Release new version

on:
push:
tags:
- v*.*.*

workflow_dispatch:
inputs:
version:
type: choice
description: Version
options:
- patch
- minor
- major
- prerelease
jobs:
publish-to-npm:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
scope: ${{ github.repository_owner }}

- name: Update package.json
run: |
TAG_NAME=${GITHUB_REF/refs\/tags\//}
PACKAGE_VERSION=${TAG_NAME#v}
echo "Updating package.json to version $PACKAGE_VERSION"
cat <<< $(jq -r ".version=\"$PACKAGE_VERSION\"" package.json) > package.json
cat package.json
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: yarn build

- name: Publish
run: yarn publish
working-directory: dist
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

publish-to-github:
release:
runs-on: ubuntu-latest
permissions:
contents: read
contents: write
packages: write
actions: write
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
# Needed to make possible changelog generation only from latest tag
with:
fetch-depth: 0
fetch-tags: true

- uses: actions/setup-node@v3
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://npm.pkg.github.com'
scope: ${{ github.repository_owner }}
cache: pnpm

- name: Install Dev Dependencies
run: pnpm install -D

- name: Update package.json
- name: Bump package.json version
id: version
run: |
TAG_NAME=${GITHUB_REF/refs\/tags\//}
PACKAGE_VERSION=${TAG_NAME#v}
echo "Updating package.json to version $PACKAGE_VERSION"
cat <<< $(jq -r ".version=\"$PACKAGE_VERSION\"" package.json) > package.json
cat package.json
echo "OLD_VERSION=$(pnpm pkg get version | tr -d '"')" >> "$GITHUB_OUTPUT"
pnpm version ${{ github.event.inputs.version }} --preid rc --git-tag-version=false
echo "NEW_VERSION=$(pnpm pkg get version | tr -d '"')" >> "$GITHUB_OUTPUT"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Generate changelog
run: pnpm changelog:generate -t v${{ steps.version.outputs.OLD_VERSION }} || pnpm changelog:generate

- name: Build
run: yarn build
- name: Create github release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email ci_cd_bot@1inch.io
git config --global user.name "CI/CD Bot"
git add package.json
git commit -m "version v${{ steps.version.outputs.NEW_VERSION }}"
git tag v${{ steps.version.outputs.NEW_VERSION }}
git push
git push --tags
gh release create v${{ steps.version.outputs.NEW_VERSION }} --notes-file CHANGELOG.md
- name: Publish
run: yarn publish
working-directory: dist
- name: Trigger publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run publish.yml -r v${{ steps.version.outputs.NEW_VERSION }}
Loading

0 comments on commit 09ebe96

Please sign in to comment.