Skip to content

Commit

Permalink
feat: start with namada
Browse files Browse the repository at this point in the history
  • Loading branch information
icfor committed Feb 21, 2024
1 parent 6bcf9eb commit 37e0de7
Show file tree
Hide file tree
Showing 91 changed files with 4,350 additions and 308 deletions.
124 changes: 1 addition & 123 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,126 +23,4 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
- run: yarn --immutable --immutable-cache --check-cache
changed-workspaces:
runs-on: ubuntu-latest
outputs:
projects: ${{ steps.dry-run.outputs.projects }}
projects-web: ${{ steps.dry-run.outputs.projects-web }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 18
- run: yarn --immutable --immutable-cache
- name: Set needs.changed-workspaces.outputs.{projects,projects-web}
id: dry-run
run: |
echo yarn build:ci --dry='json' --filter='[${{ github.event.pull_request.base.sha }}]' | tee -a $GITHUB_STEP_SUMMARY
export DRY_BUILD_JSON=$(
yarn build:ci --dry='json' --filter='[${{ github.event.pull_request.base.sha }}]' | jq '{packages: .packages}'
)
node <<EOF | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
const { packages } = JSON.parse(process.env.DRY_BUILD_JSON);
console.log('projects=' + JSON.stringify(packages.filter(p => /^(?:ui|web.*)$/.test(p))));
EOF
node <<EOF | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
const { packages } = JSON.parse(process.env.DRY_BUILD_JSON);
console.log('projects-web=' + JSON.stringify(packages.filter(p => /^web.*$/.test(p))));
EOF
ts-lint-build:
if: ${{ success() && needs.changed-workspaces.outputs.projects != '[]' }}
needs: changed-workspaces
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: ${{ fromJSON(needs.changed-workspaces.outputs.projects) }}
steps:
- uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 18
- run: yarn --immutable --immutable-cache
- name: ts-check
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
yarn ts-check:ci --filter=${{ matrix.project }} | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: lint
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
yarn lint:ci --filter=${{ matrix.project }} | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: build
if: ${{ needs.changed-workspaces.outputs.projects-web != '[]' }}
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
yarn build:ci --filter=${{ matrix.project }} | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
jest-test:
if: ${{ success() && needs.changed-workspaces.outputs.projects != '[]' }}
needs: changed-workspaces
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4, 5]
shardTotal: [5]
steps:
- uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 18
- run: yarn --immutable --immutable-cache
- name: test
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
yarn test:ci --filter=${{ join(fromJSON(needs.changed-workspaces.outputs.projects), ' --filter=') }} -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --coverage | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
e2e-playwright:
if: ${{ success() && needs.changed-workspaces.outputs.projects-web != '[]' }}
needs: changed-workspaces
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: [web]
browser:
- chromium
# - firefox
# - webkit
# - mobile-chrome
- mobile-safari
shardIndex: [1, 2, 3, 4, 5]
shardTotal: [5]
container:
image: mcr.microsoft.com/playwright:v1.33.0-focal
steps:
- uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 18
- run: yarn --immutable --immutable-cache
- name: Playwright testing
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
yarn playwright test --project=${{ matrix.browser }} --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
env:
CI: 1
DEBUG: pw:webserver
PROJECT_NAME: ${{ matrix.project }}
PLAYWRIGHT_HTML_REPORT: playwright-report/${{ matrix.browser }}/${{ matrix.shardIndex }}
- uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: trace.playwright.dev
path: playwright-report/
retention-days: 7
- run: echo Skipped
17 changes: 17 additions & 0 deletions apps/web-namada/.codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# https://docs.codecov.io/docs/commit-status
coverage:
status:
project:
default:
# basic
target: 0
threshold: 0%
base: 0%
# advanced
branches: []
if_no_uploads: error
if_not_found: success
if_ci_failed: error
only_pulls: false
flags: []
paths: []
9 changes: 9 additions & 0 deletions apps/web-namada/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root: true
extends:
- custom
ignorePatterns:
- '**/node_modules/*'
- '**/out/*'
- '**/.next/*'
- '**/dist/*'
- '**/src/graphql/*'
1 change: 1 addition & 0 deletions apps/web-namada/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Unreleased
13 changes: 13 additions & 0 deletions apps/web-namada/codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
overwrite: true
generates:
./src/graphql/types/general_types.ts:
documents:
- 'src/graphql/general/*'
schema: http://154.91.1.75:8080/v1/graphql
config:
# omitOperationSuffix: true
skipTypeNameForRoot: true
plugins:
- "typescript"
- "typescript-operations"
- "typescript-react-apollo" # To generate custom hooks per query
32 changes: 32 additions & 0 deletions apps/web-namada/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import configFromPreset from 'jest-presets/jest/node/jest-preset';
import nextJest from 'next/jest';
import { pathsToModuleNameMapper } from 'ts-jest';
import tsconfig from './tsconfig.json';

/* Creating a jest configuration for nextjs. */
const createJestConfig = nextJest({
dir: './',
})(configFromPreset);

const exportFunc = async () => {
// Create Next.js jest configuration
const configFromNext = await createJestConfig();
Object.keys(configFromNext.moduleNameMapper).forEach((regExp) => {
if (new RegExp(regExp).test('_.svg')) {
configFromNext.moduleNameMapper[regExp] = 'shared-utils/__mocks__/svg.js';
}
});
// moduleNameMapper overrided by nextjs, so we need to add it here.
const finalConfig = {
...configFromNext,
moduleNameMapper: {
...configFromNext.moduleNameMapper,
...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, {
prefix: '<rootDir>/src/',
}),
},
};
return finalConfig;
};

export default exportFunc;
16 changes: 16 additions & 0 deletions apps/web-namada/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import mockApollo from '@/tests/mocks/mockApollo';
import mockChainConfig from '@/tests/mocks/mockChainConfig';
import mockDayJs from '@/tests/mocks/mockDayJs';
import mockDynamicComponent from '@/tests/mocks/mockDynamicComponent';
import mockI18Next from '@/tests/mocks/mockI18Next';
import mockProfiles from '@/tests/mocks/mockProfiles';
import '@testing-library/jest-dom/extend-expect';
import 'jest-localstorage-mock';

jest.setTimeout(30000);
mockI18Next();
mockApollo();
mockChainConfig();
mockDayJs();
mockDynamicComponent();
mockProfiles();
5 changes: 5 additions & 0 deletions apps/web-namada/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
11 changes: 11 additions & 0 deletions apps/web-namada/next-i18next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { resolve } = require('path');

module.exports = {
i18n: {
defaultLocale: 'en',
locales: ['en', 'zht', 'zhs', 'it', 'pl'],
},
localeDetection: false,
localePath: resolve('../../packages/ui/public/locales'),
};
5 changes: 5 additions & 0 deletions apps/web-namada/next-sitemap.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { readFileSync } = require('fs');
const getSitemap = require('shared-utils/configs/sitemap');

module.exports = getSitemap(JSON.parse(readFileSync('./package.json', 'utf8')).name);
16 changes: 16 additions & 0 deletions apps/web-namada/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { readFileSync } = require('fs');
const { i18n } = require('./next-i18next.config');
const getNextConfig = require('../../packages/shared-utils/configs/next');

const nextConfig = getNextConfig(JSON.parse(readFileSync('./package.json', 'utf8')).name);
nextConfig.i18n = i18n;

nextConfig.rewrites = async () => [
{
source: '/gql',
destination: 'http://154.91.1.75:8080/v1/graphql',
},
];

module.exports = nextConfig;
Loading

0 comments on commit 37e0de7

Please sign in to comment.