Skip to content

Commit

Permalink
fix: github actions on monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
compojoom committed Dec 19, 2024
1 parent a363a78 commit 7825b1c
Show file tree
Hide file tree
Showing 32 changed files with 170 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build-storybook/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ runs:
steps:
- name: Build Storybook
shell: bash
run: yarn build-storybook -o ./out/storybook
run: yarn workspace @safe-global/web build-storybook -o ./out/storybook
2 changes: 1 addition & 1 deletion .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ runs:
- name: Build
shell: bash
run: yarn build
run: yarn workspace @safe-global/web build
env:
NEXT_PUBLIC_IS_PRODUCTION: ${{ inputs.prod }}
NEXT_PUBLIC_CYPRESS_MNEMONIC: ${{ inputs.e2e_mnemonic }}
Expand Down
12 changes: 6 additions & 6 deletions .github/actions/cache-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ runs:
**/node_modules
/home/runner/.cache/Cypress
${{ github.workspace }}/.yarn/install-state.gz
${{ github.workspace }}/src/types
${{ github.workspace }}/apps/web/src/types
key: ${{ runner.os }}-web-core-modules-${{ hashFiles('**/package.json','**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-web-core-modules-
Expand All @@ -54,7 +54,7 @@ runs:
**/node_modules
/home/runner/.cache/Cypress
${{ github.workspace }}/.yarn/install-state.gz
${{ github.workspace }}/src/types
${{ github.workspace }}/apps/web/src/types
key: ${{inputs.key}}

- name: Restore Next.js
Expand All @@ -63,10 +63,10 @@ runs:
uses: actions/cache/restore@v4
with:
path: |
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-cypress-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
${{ github.workspace }}/apps/web/.next/cache
key: ${{ runner.os }}-nextjs-cypress-${{ hashFiles('apps/web/package.json', 'apps/web/yarn.lock') }}-${{ hashFiles('apps/web/src/**/*', 'apps/web/public/**/*', 'apps/web/*.{js,jsx,cjs,ts,mjs,tsx,json} ') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-
${{ runner.os }}-nextjs-${{ hashFiles('apps/web/package.json', 'apps/web/yarn.lock') }}-
- name: Set composite outputs nc
if: ${{ inputs.mode == 'restore-nc' }}
Expand All @@ -81,5 +81,5 @@ runs:
uses: actions/cache/save@v4
with:
path: |
${{ github.workspace }}/.next/cache
${{ github.workspace }}/apps/web/.next/cache
key: ${{inputs.key}}
3 changes: 2 additions & 1 deletion .github/actions/cypress/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ runs:
tag: ${{ inputs.tag }}
config: baseUrl=http://localhost:8080
install: false
start: yarn serve
start: yarn workspace @safe-global/web serve
working-directory: apps/web
env:
CYPRESS_RECORD_KEY: ${{ inputs.record_key || fromJSON(inputs.secrets).CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ fromJSON(inputs.secrets).GITHUB_TOKEN }}
Expand Down
9 changes: 7 additions & 2 deletions .github/actions/yarn/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ runs:
run: |
echo "Yarn cache hit: ${{ steps.restore-yarn-types.outputs.cache-hit-yarn }}"
- name: Yarn install & after-install generate types
- name: Yarn install
if: steps.restore-yarn-types.outputs.cache-hit-yarn != 'true'
shell: bash
run: |
yarn install --immutable
yarn after-install
- name: Yarn after-install to generate contracts types
if: steps.restore-yarn-types.outputs.cache-hit-yarn != 'true'
shell: bash
run: |
yarn workspace @safe-global/web after-install
- name: Save Yarn Cache & Types
if: steps.restore-yarn-types.outputs.cache-hit-yarn != 'true'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
branches:
- dev
- main
paths:
- apps/web/**

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -56,14 +58,18 @@ jobs:
if: startsWith(github.ref, 'refs/heads/main')
env:
BUCKET: s3://${{ secrets.AWS_STAGING_BUCKET_NAME }}/current
run: bash ./scripts/github/s3_upload.sh
run: |
cd ./apps/web
bash ./scripts/github/s3_upload.sh
# Dev
- name: Deploy to the dev S3
if: startsWith(github.ref, 'refs/heads/dev')
env:
BUCKET: s3://${{ secrets.AWS_DEVELOPMENT_BUCKET_NAME }}
run: bash ./scripts/github/s3_upload.sh
run: |
cd ./apps/web
bash ./scripts/github/s3_upload.sh
### PRs ###

Expand All @@ -80,7 +86,9 @@ jobs:
if: github.event.number
env:
BUCKET: s3://${{ secrets.AWS_REVIEW_BUCKET_NAME }}/walletweb/${{ steps.extract_branch.outputs.branch }}
run: bash ./scripts/github/s3_upload.sh
run: |
cd ./apps/web
bash ./scripts/github/s3_upload.sh
# Comment
- name: Post a deployment link in the PR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
branches:
- main
- dev
paths:
- apps/web/**
release:
types: [ released ]

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Safe Apps e2e

on:
pull_request:
paths:
- apps/web/**
workflow_dispatch:

concurrency:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Smoke tests

on:
pull_request:

paths:
- apps/web/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/lint.yml → .github/workflows/web-lint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Lint
on: [pull_request]
on:
pull_request:
paths:
- apps/web/**

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -24,5 +27,5 @@ jobs:
fail-check: true # optional
github-token: ${{ secrets.GITHUB_TOKEN }} # optional
directory: './' # optional
targets: 'src' # optional
config-path: './eslint.config.mjs'
targets: '/apps/web/src' # optional
config-path: './apps/web/eslint.config.mjs'
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ name: 'Next.js Bundle Analysis'

on:
pull_request:
paths:
- apps/web/**
push:
branches:
- dev

paths:
- apps/web/**
permissions:
contents: read # for checkout repository
actions: read # for fetching base branch bundle stats
Expand All @@ -29,29 +32,36 @@ jobs:
secrets: ${{ toJSON(secrets) }}

- name: Analyze bundle
run: npx -p nextjs-bundle-analysis report
run: |
cd apps/web
npx -p nextjs-bundle-analysis report
- name: Upload bundle
uses: actions/upload-artifact@v4
with:
name: bundle
path: .next/analyze/__bundle_analysis.json
path: apps/web/.next/analyze/__bundle_analysis.json

- name: Download base branch bundle stats
if: success() && github.event.number
run: bash ./scripts/github/download_bundle_analyser_artifact.sh
run: |
cd apps/web
bash ./scripts/github/download_bundle_analyser_artifact.sh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Compare with base branch bundle
if: success() && github.event.number
run: ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare
run: |
cd apps/web
ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare
- name: Get Comment Body
id: get-comment-body
if: success() && github.event.number
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
run: |
cd apps/web
echo "body<<EOF" >> $GITHUB_OUTPUT
echo "$(cat .next/analyze/__bundle_analysis_comment.txt)" >> $GITHUB_OUTPUT
echo EOF >> $GITHUB_OUTPUT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
branches:
- main
types: [closed]
paths:
- apps/web/**

jobs:
tag-release:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: Unit tests
on:
pull_request:
paths:
- apps/web/**

push:
branches:
- main

paths:
- apps/web/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -30,6 +33,7 @@ jobs:
annotations: failed-tests
package-manager: yarn
test-script: yarn test:ci
working-directory: apps/web
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
NEXT_PUBLIC_IS_OFFICIAL_HOST: true
2 changes: 1 addition & 1 deletion apps/web/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const nextConfig = {
cacheGroups: {
...config.optimization.splitChunks.cacheGroups,
customModule: {
test: /[\\/]node_modules[\\/](@safe-global|ethers)[\\/]/,
test: /[\\/]..[\\/]..[\\/]node_modules[\\/](@safe-global|ethers)[\\/]/,
name: 'protocol-kit-ethers',
chunks: 'all',
},
Expand Down
6 changes: 3 additions & 3 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"cmp": "./scripts/cmp.sh",
"routes": "node scripts/generate-routes.js > src/config/routes.ts && prettier -w src/config/routes.ts && cat src/config/routes.ts",
"css-vars": "npx -y tsx ./scripts/css-vars.ts > ./src/styles/vars.css && prettier -w src/styles/vars.css",
"generate-types": "typechain --target ethers-v6 --out-dir src/types/contracts ./node_modules/@safe-global/safe-deployments/dist/assets/**/*.json ./node_modules/@safe-global/safe-modules-deployments/dist/assets/**/*.json ./node_modules/@openzeppelin/contracts/build/contracts/ERC20.json ./node_modules/@openzeppelin/contracts/build/contracts/ERC721.json",
"generate-types": "typechain --target ethers-v6 --out-dir src/types/contracts ../../node_modules/@safe-global/safe-deployments/dist/assets/**/*.json ../../node_modules/@safe-global/safe-modules-deployments/dist/assets/**/*.json ../../node_modules/@openzeppelin/contracts/build/contracts/ERC20.json ../../node_modules/@openzeppelin/contracts/build/contracts/ERC721.json",
"after-install": "yarn generate-types",
"postinstall": "yarn after-install",
"analyze": "cross-env ANALYZE=true yarn build",
Expand Down Expand Up @@ -62,10 +62,10 @@
"@walletconnect/core": "^2.17.2",
"@walletconnect/utils": "^2.17.3",
"@web3-onboard/coinbase": "^2.4.1",
"@web3-onboard/core": "^2.21.4",
"@web3-onboard/core": "2.21.4",
"@web3-onboard/injected-wallets": "^2.11.2",
"@web3-onboard/ledger": "2.3.2",
"@web3-onboard/trezor": "^2.4.2",
"@web3-onboard/trezor": "2.4.3",
"@web3-onboard/walletconnect": "^2.6.1",
"blo": "^1.1.1",
"classnames": "^2.5.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ import type {
SafeInfoExtended,
} from '@safe-global/safe-apps-sdk'
import { Methods, RPC_CALLS } from '@safe-global/safe-apps-sdk'
import type {
Permission,
PermissionRequest,
} from 'node_modules/@safe-global/safe-apps-sdk/dist/types/types/permissions'
import type { Permission, PermissionRequest } from '@safe-global/safe-apps-sdk/dist/types/types/permissions'
import type { SafeSettings } from '@safe-global/safe-apps-sdk'
import AppCommunicator from '@/services/safe-apps/AppCommunicator'
import { Errors, logError } from '@/services/exceptions'
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/safe-apps/PermissionsPrompt.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ReactElement } from 'react'
import type { PermissionRequest } from 'node_modules/@safe-global/safe-apps-sdk/dist/types/types/permissions'
import type { PermissionRequest } from '@safe-global/safe-apps-sdk/dist/types/types/permissions'
import { Button, Dialog, DialogActions, DialogContent, Divider, Typography } from '@mui/material'

import { ModalDialogTitle } from '@/components/common/ModalDialog'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { faker } from '@faker-js/faker'
import { id, zeroPadValue } from 'ethers'
import { JsonRpcProvider } from 'ethers'
import cloneDeep from 'lodash/cloneDeep'
import type { Delay, TransactionAddedEvent } from 'node_modules/@gnosis.pm/zodiac/dist/cjs/types/Delay'
import type { Delay, TransactionAddedEvent } from '@gnosis.pm/zodiac/dist/cjs/types/Delay'
import type { TransactionReceipt } from 'ethers'

import {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/features/recovery/services/recovery-sender.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getModuleInstance, KnownContracts } from '@gnosis.pm/zodiac'
import type { SafeInfo } from '@safe-global/safe-gateway-typescript-sdk'
import type { SafeTransaction } from '@safe-global/safe-core-sdk-types'
import type { TransactionAddedEvent } from 'node_modules/@gnosis.pm/zodiac/dist/cjs/types/Delay'
import type { TransactionAddedEvent } from '@gnosis.pm/zodiac/dist/cjs/types/Delay'
import type { Eip1193Provider, TransactionResponse } from 'ethers'

import { didReprice, didRevert } from '@/utils/ethers-utils'
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/features/recovery/services/recovery-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import memoize from 'lodash/memoize'
import { getMultiSendCallOnlyDeployment } from '@safe-global/safe-deployments'
import type { SafeInfo } from '@safe-global/safe-gateway-typescript-sdk'
import type { Delay } from '@gnosis.pm/zodiac'
import type { TransactionAddedEvent } from 'node_modules/@gnosis.pm/zodiac/dist/cjs/types/Delay'
import type { TransactionAddedEvent } from '@gnosis.pm/zodiac/dist/cjs/types/Delay'
import { toBeHex, type JsonRpcProvider, type TransactionReceipt } from 'ethers'
import { trimTrailingSlash } from '@/utils/url'
import { sameAddress } from '@/utils/addresses'
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/features/swap/helpers/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DataDecoded, Order as SwapOrder } from '@safe-global/safe-gateway-typescript-sdk'
import { formatUnits } from 'ethers'
import type { AnyAppDataDocVersion, latest, LatestAppDataDocVersion } from 'node_modules/@cowprotocol/app-data'
import type { AnyAppDataDocVersion, latest, LatestAppDataDocVersion } from '@cowprotocol/app-data'

import { TradeType, UiOrderType } from '@/features/swap/types'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
Permission,
PermissionCaveat,
PermissionRequest,
} from 'node_modules/@safe-global/safe-apps-sdk/dist/types/types/permissions'
} from '@safe-global/safe-apps-sdk/dist/types/types/permissions'

import { PermissionStatus } from '@/components/safe-apps/types'
import useLocalStorage from '@/services/local-storage/useLocalStorage'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export function firebaseMessagingSw() {
self.registration.showNotification(notification.title || '', {
icon: ICON_PATH,
body: notification.body,
image: notification.image,
data,
})
})
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/store/batchSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const batchSlice = createSlice({
state[chainId][safeAddress].push({
id: Math.random().toString(36).slice(2),
timestamp: Date.now(),
// @ts-expect-error
txDetails,
})
},
Expand Down
9 changes: 9 additions & 0 deletions apps/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
"@/*": [
"./src/*"
],
"@safe-global/safe-apps-sdk/*": [
"../../node_modules/@safe-global/safe-apps-sdk/*"
],
"@gnosis.pm/zodiac/*": [
"../../node_modules/@gnosis.pm/zodiac/*"
],
"@cowprotocol/app-data": [
"../../node_modules/@cowprotocol/app-data"
],
"@/public/*": [
"./public/*"
]
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"@safe-global/safe-core-sdk-types/ethers": "6.13.4",
"@safe-global/protocol-kit/ethers": "6.13.4",
"@safe-global/api-kit/ethers": "6.13.4",
"@gnosis.pm/zodiac/ethers": "6.13.4"
"@gnosis.pm/zodiac/ethers": "6.13.4",
"@cowprotocol/events": "1.3.0"
},
"devDependencies": {
"husky": "^9.1.6",
Expand Down
Loading

0 comments on commit 7825b1c

Please sign in to comment.