From d3470ee263bfa8ab833a677c546d31b2483472dc Mon Sep 17 00:00:00 2001 From: Vladimir Borovik Date: Mon, 1 Jul 2024 16:54:08 +0300 Subject: [PATCH 1/3] chore: ci for v1 to be able to update v1 sdk (security issues) --- .github/workflows/pr-check-v1.yml | 106 ++++++++++++++++++++++++++++++ .github/workflows/release-v1.yml | 74 +++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 .github/workflows/pr-check-v1.yml create mode 100644 .github/workflows/release-v1.yml diff --git a/.github/workflows/pr-check-v1.yml b/.github/workflows/pr-check-v1.yml new file mode 100644 index 0000000..c8bc7f3 --- /dev/null +++ b/.github/workflows/pr-check-v1.yml @@ -0,0 +1,106 @@ +name: CI + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +on: + pull_request: + branches: + - v1 + +jobs: + setup: + name: Setup + runs-on: ubuntu-20.04 + + steps: + - name: Load current commit + uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + + - name: Setup Node.js + uses: volta-cli/action@v4 + + - name: Restore cache + uses: actions/cache@v3 + id: yarn-cache + if: github.event_name == 'pull_request' || github.event_name == 'push' + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + + - name: Install dependencies + if: steps.yarn-cache.outputs.cache-hit != 'true' + run: | + yarn --frozen-lockfile --no-progress + + static-checks: + name: Static checks + needs: setup + runs-on: ubuntu-20.04 + + steps: + - name: Load current commit + uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + + - name: Setup Node.js + uses: volta-cli/action@v4 + + - name: Restore cache + uses: actions/cache@v3 + id: yarn-cache + if: github.event_name == 'pull_request' || github.event_name == 'push' + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + + - name: Install dependencies + if: steps.yarn-cache.outputs.cache-hit != 'true' + run: | + yarn --frozen-lockfile --no-progress + + - name: Prettier check + run: yarn prettier:check + + - name: Linter + run: yarn lint + + - name: Type check + run: yarn typecheck + + tests: + name: Unit tests + needs: setup + runs-on: ubuntu-20.04 + + steps: + - name: Load current commit + uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + + - name: Setup Node.js + uses: volta-cli/action@v4 + + - name: Restore cache + uses: actions/cache@v3 + id: yarn-cache + if: github.event_name == 'pull_request' || github.event_name == 'push' + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + + - name: Install dependencies + if: steps.yarn-cache.outputs.cache-hit != 'true' + run: | + yarn --frozen-lockfile --no-progress + + - name: Run unit tests + run: yarn test diff --git a/.github/workflows/release-v1.yml b/.github/workflows/release-v1.yml new file mode 100644 index 0000000..c03d2b6 --- /dev/null +++ b/.github/workflows/release-v1.yml @@ -0,0 +1,74 @@ +name: Publish package + +on: + push: + tags: + - v1.*.* + +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: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: 'https://npm.pkg.github.com' + 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.GITHUB_TOKEN }} From 56bd4f261b328c25d2802e58aec1ec46436674c0 Mon Sep 17 00:00:00 2001 From: Vladimir Borovik Date: Mon, 1 Jul 2024 17:00:04 +0300 Subject: [PATCH 2/3] fix build --- .github/workflows/pr-check-v1.yml | 2 +- tsconfig.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-check-v1.yml b/.github/workflows/pr-check-v1.yml index c8bc7f3..c0b28df 100644 --- a/.github/workflows/pr-check-v1.yml +++ b/.github/workflows/pr-check-v1.yml @@ -2,7 +2,7 @@ name: CI concurrency: group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref != 'refs/heads/v1' }} on: pull_request: diff --git a/tsconfig.json b/tsconfig.json index 7e56ad8..a9859c3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,8 +3,8 @@ "compilerOptions": { "target": "ES2021", "lib": ["ES2021"], - "module": "ESNext", - "moduleResolution": "Node", + "module": "NodeNext", + "moduleResolution": "NodeNext", "strict": true, "esModuleInterop": true, "skipLibCheck": true, From c78af1e3b68cb6ef4b299dc41bb02a5ceb81a215 Mon Sep 17 00:00:00 2001 From: Vladimir Borovik Date: Mon, 1 Jul 2024 17:42:24 +0300 Subject: [PATCH 3/3] fix build --- jest.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest.config.ts b/jest.config.ts index 900780d..b4d6aef 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -170,7 +170,7 @@ export default { transformIgnorePatterns: [ // "/node_modules/", // "\\.pnp\\.[^\\/]+$", - 'node_modules/.pnpm/(?!axios)' + '/node_modules/.pnpm/(?!(axios|@1inch\\+limit-order-sdk)@)', ] // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them