Skip to content

Commit

Permalink
Merge pull request #13 from valory-xyz/fix/git-workflow
Browse files Browse the repository at this point in the history
Fix git workflow
  • Loading branch information
mohandast52 authored Mar 19, 2024
2 parents 7417791 + 05bd986 commit c94348e
Show file tree
Hide file tree
Showing 15 changed files with 25,715 additions and 73 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"env": {
"browser": true,
Expand All @@ -24,7 +23,8 @@
}
]
}
]
],
"react-hooks/exhaustive-deps": "warn"
}
},
{
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/autonolas-registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Autonolas registry
on:
push:
branches:
- main
paths:
- 'apps/autonolas-registry/**'
pull_request:
paths:
- 'apps/autonolas-registry/**'

jobs:
build:
continue-on-error: False
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install modules
run: yarn
- run: git branch --track main origin/main
- name: Run ESLint
run: yarn nx lint autonolas-registry
# - name: Run Test
# run: yarn nx test autonolas-registry
scan:
name: gitleaks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: '1.17.7'
- run: |
wget https://github.com/zricethezav/gitleaks/releases/download/v8.10.1/gitleaks_8.10.1_linux_x64.tar.gz && \
tar -xzf gitleaks_8.10.1_linux_x64.tar.gz && \
sudo install gitleaks /usr/bin && \
gitleaks detect --source apps/autonolas-registry --report-format json --report-path autonolas-registry.json --exit-code 0 -v
40 changes: 0 additions & 40 deletions .github/workflows/main.yml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/tokenomics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# TODO: figure out how to trigger workflow from vercel for nx

name: Tokenomics
on:
push:
branches:
- main
paths:
- 'apps/tokenomics/**'
pull_request:
paths:
- 'apps/tokenomics/**'

jobs:
build:
continue-on-error: False
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install modules
run: yarn
- run: git branch --track main origin/main
- name: Run ESLint
run: yarn nx lint tokenomics
- name: Run Test
run: yarn nx test tokenomics
scan:
name: gitleaks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: '1.17.7'
- run: |
wget https://github.com/zricethezav/gitleaks/releases/download/v8.10.1/gitleaks_8.10.1_linux_x64.tar.gz && \
tar -xzf gitleaks_8.10.1_linux_x64.tar.gz && \
sudo install gitleaks /usr/bin && \
gitleaks detect --source apps/tokenomics --report-format json --report-path tokenomics.json --exit-code 0 -v
1 change: 0 additions & 1 deletion apps/autonolas-registry/components/ListServices/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ const ListServices = () => {
if (total && currentPage && !searchValue) {
getList();
}
/* eslint-disable-next-line react-hooks/exhaustive-deps */
}, [

Check warning on line 150 in apps/autonolas-registry/components/ListServices/index.jsx

View workflow job for this annotation

GitHub Actions / build

React Hook useEffect has missing dependencies: 'getMySvmServices', 'getSvmServices', and 'list.length'. Either include them or remove the dependency array
account,
chainName,
Expand Down
13 changes: 6 additions & 7 deletions apps/autonolas-registry/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ const { compilerOptions } = require('../../tsconfig.base.json');
module.exports = {
displayName: 'autonolas-registry',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
useESM: true,
},
},
testEnvironment: 'jsdom',
moduleDirectories: ['node_modules'],
moduleNameMapper: {
Expand All @@ -24,7 +18,12 @@ module.exports = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
transform: {
'^.+\\.[tj]sx?$': ['ts-jest', { presets: ['@nx/next/babel'], }],
'^.+\\.[tj]sx?$': ['ts-jest', {
presets: ['@nx/next/babel'],
tsconfig: '<rootDir>/tsconfig.spec.json',
useESM: true,
}
],
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
},
coverageDirectory: '../../coverage/apps/autonolas-registry',
Expand Down
2 changes: 1 addition & 1 deletion apps/autonolas-registry/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/autonolas-registry/jest.config.ts"
"jestConfig": "apps/autonolas-registry/jest.config.js"
}
},
"lint": {
Expand Down
3 changes: 2 additions & 1 deletion apps/tokenomics/components/Layout/Footer.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useRouter } from 'next/router';
import { Grid } from 'antd';
import Link from 'next/link';
import Image from 'next/image';
import {
Footer as CommonFooter,
getExplorerURL,
Expand Down Expand Up @@ -76,7 +77,7 @@ const ContractInfo = () => {
<ContractsInfoContainer>
{!PATHS_NOT_TO_SHOW.includes(pathname) && (
<>
<img
<Image
alt="Etherscan link"
width={18}
height={18}
Expand Down
48 changes: 43 additions & 5 deletions apps/tokenomics/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,47 @@
const { resolve } = require('path');
const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('../../tsconfig.base.json');

module.exports = {
verbose: true,
setupFilesAfterEnv: ['./jest.setup.js'],
displayName: 'tokenomics',
preset: '../../jest.preset.js',
testEnvironment: 'jsdom',
moduleDirectories: ['node_modules'],
moduleNameMapper: {
'\\.(css|less|sass|scss)$': '<rootDir>/__mocks__/styleMock.js',
'\\.(gif|ttf|eot|svg)$': '<rootDir>/__mocks__/fileMock.js',
...pathsToModuleNameMapper(compilerOptions.paths, { prefix: resolve(__dirname, '../..') }),
'^util/(.*)$': '<rootDir>/util/$1',
'^common-util/(.*)$': '<rootDir>/common-util/$1',
'^components/(.*)$': '<rootDir>/components/$1',
'^images/(.*)$': '<rootDir>/public/images/$1',
'^store/(.*)$': '<rootDir>/store/$1',
},
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
transform: {
'^.+\\.[tj]sx?$': ['ts-jest', {
presets: ['@nx/next/babel'],
tsconfig: '<rootDir>/tsconfig.spec.json',
useESM: true,
}],
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
},
coverageDirectory: '../../coverage/apps/tokenomics',
collectCoverageFrom: [
'common-util/**/*.{js,jsx}',
'components/**/*.{js,jsx}',

// ABI will change frequently on backend deployment hence avoiding.
'!common-util/AbiAndAddresses/*.{js,jsx}',

// Contract objects
'!common-util/Contracts/*.{js,jsx}',

// styles are not required to be tested
'!common-util/**/styles.{js,jsx}',
'!components/**/styles.{js,jsx}',
'!components/GlobalStyles/*.{js,jsx}',

// Index page
'!components/index/.jsx',
],
};
2 changes: 1 addition & 1 deletion apps/tokenomics/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/tokenomics/jest.config.ts"
"jestConfig": "apps/tokenomics/jest.config.js"
}
},
"lint": {
Expand Down
11 changes: 0 additions & 11 deletions apps/tokenomics/specs/index.spec.tsx

This file was deleted.

2 changes: 2 additions & 0 deletions apps/tokenomics/tests/test-chains/TestChains.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ describe('test-chains/TestChains.jsx', () => {

// Stringify the remote ABI and compare with the local one
const remoteABI = JSON.stringify(remoteArtifact.abi);
// eslint-disable-next-line jest/no-conditional-expect
expect(localABI).toBe(remoteABI);

// Check the address
const localAddress = localArtifacts[k].addresses[parsedConfig[i].chainId];
// eslint-disable-next-line jest/no-conditional-expect
expect(localAddress).toBe(contracts[j].address);
}
}
Expand Down
8 changes: 4 additions & 4 deletions libs/util-functions/src/lib/sendTransaction/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('pollTransactionDetails()', () => {
await pollTransactionDetails(hash, chainId);
}

await expect(fetchTransactionDetails).rejects.toThrowError(
await expect(fetchTransactionDetails).rejects.toThrow(
'Invalid transaction details'
);
});
Expand All @@ -91,7 +91,7 @@ describe('getIsValidChainId()', () => {

describe('getProvider()', () => {
it('should throw an error if supported chain is empty array', () => {
expect(() => getProvider([], {})).toThrowError(
expect(() => getProvider([], {})).toThrow(
'Supported chains cannot be empty'
);
});
Expand All @@ -103,7 +103,7 @@ describe('getProvider()', () => {
getProvider(SUPPORTED_CHAINS, {});
}

await expect(fetchProvider).rejects.toThrowError(
await expect(fetchProvider).rejects.toThrow(
'No RPC URL found for chainId: 1'
);
});
Expand All @@ -115,7 +115,7 @@ describe('getProvider()', () => {
getProvider(SUPPORTED_CHAINS, mockRpcUrls);
}

await expect(fetchProvider).rejects.toThrowError(
await expect(fetchProvider).rejects.toThrow(
'No RPC URL found for chainId: 11111'
);
});
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"@swc/cli": "~0.1.62",
"@swc/core": "~1.3.85",
"@swc/plugin-styled-components": "^1.5.67",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "14.0.0",
"@types/jest": "^29.4.0",
"@types/node": "18.16.9",
Expand Down
Loading

0 comments on commit c94348e

Please sign in to comment.