Skip to content

Commit

Permalink
添加构建测试
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed May 30, 2024
1 parent 88bfb99 commit 154a6ca
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 17 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Run build test

on:
pull_request:
branches:
- dev

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Check out git repository
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install Dependencies
run: npm ci

- name: Eslint check
run: npm run lint

- name: Test Build
run: npm run build-test
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"rd": "react-devtools",
"menu": "adb shell input keyevent 82",
"bundle-android": "react-native bundle --platform android --dev true --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
"build-test": "react-native bundle --platform android --dev true --entry-file index.js --bundle-output index.android.bundle --assets-dest res",
"pack:android:debug": "./gradlew assembleDebug",
"pack": "npm run pack:android",
"pack:android": "cd android && gradlew.bat assembleRelease",
Expand Down
4 changes: 2 additions & 2 deletions src/components/MetadataEditModal/MetadataForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default forwardRef<MetadataFormType, {}>((props, ref) => {
}).finally(() => {
matcheingPic.delete(path)
})
}, [data.albumName, data.name, data.singer, t])
}, [data.albumName, data.interval, data.name, data.singer, isUnmounted, t])
const handleOnlineMatchLyric = useCallback(() => {
let path = filePath.current
if (matcheingLrc.has(path)) return
Expand Down Expand Up @@ -164,7 +164,7 @@ export default forwardRef<MetadataFormType, {}>((props, ref) => {
}).finally(() => {
matcheingLrc.delete(path)
})
}, [data.albumName, data.name, data.singer, t])
}, [data.albumName, data.interval, data.name, data.singer, isUnmounted, t])
const handleUpdatePic = useCallback((path: string) => {
setData(data => {
return { ...data, pic: path }
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/ChoosePath/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default memo(({
}, [])
useEffect(() => {
checkExternalStoragePath()
}, [])
}, [checkExternalStoragePath])

const refresh = () => {
void onRefreshDir(path)
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default forwardRef<PopupType, PopupProps>(({
},
] as const
}
}, [position])
}, [position, statusBarHeight])

return (
<Modal onHide={onHide} keyHide={keyHide} bgHide={bgHide} bgColor="rgba(50,50,50,.2)" ref={modalRef}>
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const buildData = (key: string, value: any, datas: Array<[string, string]>) => {
datas.push([key, partKeyArrPrefix + JSON.stringify(partKeys)])
}

// 1.4.0 之前的数据分片存储方式,存在key的内容与分隔符冲突的问题
// 1.4.0 开始改用数组存储,不再使用分隔符的方式
const handleGetDataOld = async<T>(partKeys: string): Promise<T> => {
const keys = partKeys.replace(partKeyPrefixRxp, '').split(keySplit)

Expand Down
2 changes: 1 addition & 1 deletion src/screens/Home/Views/Mylist/MusicList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default () => {
const handleScrollToInfo = useCallback((info: LX.Music.MusicInfo) => {
listRef.current?.scrollToInfo(info)
handleExitSearch()
}, [])
}, [handleExitSearch])
const onLayout = useCallback((e: LayoutChangeEvent) => {
layoutHeightRef.current = e.nativeEvent.layout.height
}, [])
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default ({ componentId }: Props) => {
if (settingState.setting['player.startupPushPlayDetailScreen']) {
navigations.pushPlayDetailScreen(componentId, true)
}
}, [])
}, [componentId])

return (
<PageContent>
Expand Down
8 changes: 4 additions & 4 deletions src/screens/PlayDetail/Horizontal/Lyric.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default () => {
// }, [playMusicInfo])

// const imgWidth = useMemo(() => layout.width * 0.75, [layout.width])
const handleScrollToActive = (index = lineRef.current.line) => {
const handleScrollToActive = useCallback((index = lineRef.current.line) => {
if (index < 0) return
if (flatListRef.current) {
// console.log('handleScrollToActive', index)
Expand Down Expand Up @@ -130,7 +130,7 @@ export default () => {
} catch {}
}
}
}
}, [line])

const handleScroll = ({ nativeEvent }: NativeSyntheticEvent<NativeScrollEvent>) => {
scrollInfoRef.current = nativeEvent
Expand Down Expand Up @@ -207,7 +207,7 @@ export default () => {
}, 100)
}
})
}, [lyricLines])
}, [handleScrollToActive, lyricLines])

useEffect(() => {
if (line < 0) return
Expand All @@ -224,7 +224,7 @@ export default () => {
delayScrollTimeout.current = null
handleScrollToActive()
}, 600)
}, [line])
}, [handleScrollToActive, line])

useEffect(() => {
requestAnimationFrame(() => {
Expand Down
8 changes: 4 additions & 4 deletions src/screens/PlayDetail/Vertical/Lyric.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export default () => {
// }, [playMusicInfo])

// const imgWidth = useMemo(() => layout.width * 0.75, [layout.width])
const handleScrollToActive = (index = lineRef.current.line) => {
const handleScrollToActive = useCallback((index = lineRef.current.line) => {
if (index < 0) return
if (flatListRef.current) {
// console.log('handleScrollToActive', index)
Expand Down Expand Up @@ -170,7 +170,7 @@ export default () => {
} catch {}
}
}
}
}, [line])

const handleScroll = ({ nativeEvent }: NativeSyntheticEvent<NativeScrollEvent>) => {
scrollInfoRef.current = nativeEvent
Expand Down Expand Up @@ -247,7 +247,7 @@ export default () => {
}, 100)
}
})
}, [lyricLines])
}, [handleScrollToActive, lyricLines])

useEffect(() => {
if (line < 0) return
Expand All @@ -264,7 +264,7 @@ export default () => {
delayScrollTimeout.current = null
handleScrollToActive()
}, 600)
}, [line])
}, [handleScrollToActive, line])

useEffect(() => {
requestAnimationFrame(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/screens/PlayDetail/Vertical/Pic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default ({ componentId }: { componentId: string }) => {
height: imgWidth,
borderRadius: 2,
}
}, [winHeight, winWidth])
}, [statusBarHeight, winHeight, winWidth])

return (
<View style={styles.container}>
Expand Down
2 changes: 1 addition & 1 deletion src/screens/PlayDetail/components/PlayLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default forwardRef<PlayLineType, PlayLineProps>(({ onPlayLine }, ref) =>
})
// setVisible()
},
}), [])
}))

const handlePlayLine = () => {
onPlayLine(time / 1000)
Expand Down
2 changes: 1 addition & 1 deletion src/screens/SonglistDetail/MusicList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default forwardRef<MusicListType, MusicListProps>(({ componentId }, ref)
})
}
},
}), [])
}))

useEffect(() => {
isUnmountedRef.current = false
Expand Down
2 changes: 2 additions & 0 deletions src/utils/hooks/useAnimateColor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Animated } from 'react-native'
const ANIMATION_DURATION = 800

export const useAnimateColor = (color: string) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
const anim = useMemo(() => new Animated.Value(0), [color])
const [finished, setFinished] = useState(true)
const currentColor = useRef(color)
Expand All @@ -29,6 +30,7 @@ export const useAnimateColor = (color: string) => {
requestAnimationFrame(() => {
currentColor.current = nextColor
})
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [nextColor])

return [animColor, finished] as const
Expand Down
3 changes: 3 additions & 0 deletions src/utils/hooks/useAnimateNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Animated } from 'react-native'
export const DEFAULT_DURATION = 800

export const useAnimateNumber = (val: number, duration = DEFAULT_DURATION, useNativeDriver = true) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
const anim = useMemo(() => new Animated.Value(0), [val])
const [finished, setFinished] = useState(true)
const currentNumber = useRef(val)
Expand All @@ -29,6 +30,7 @@ export const useAnimateNumber = (val: number, duration = DEFAULT_DURATION, useNa
requestAnimationFrame(() => {
currentNumber.current = nextNumber
})
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [nextNumber])

return [animNumber, finished] as const
Expand All @@ -54,6 +56,7 @@ export const useAnimateOnecNumber = (val: number, toVal: number, duration = DEFA
// currentNumber.current = nextNumber
setFinished(true)
})
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

return [animNumber, finished] as const
Expand Down

0 comments on commit 154a6ca

Please sign in to comment.