Skip to content

Commit

Permalink
Enabled test and lint workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandakan committed Jun 23, 2024
1 parent 6fa818f commit 7cd905d
Show file tree
Hide file tree
Showing 18 changed files with 204 additions and 42 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ module.exports = {
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx']
},
react: {
version: 'detect'
}
}
};
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

Expand All @@ -30,8 +31,6 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
# Used Node v20.12.2 because the latest v20.13 breaks windows builds.
# node-version: 20.12.2
node-version: 20
check-latest: true

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
check-latest: true
Expand All @@ -33,4 +33,4 @@ jobs:
uses: wearerequired/lint-action@v2
with:
eslint: true
# prettier: true
prettier: true
8 changes: 3 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ jobs:
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
check-latest: true

- name: Install dependencies
run: npm ci

# TODO - Commented because test has some incompatibility with typescript files in the project.

# - name: Run Jest tests
# run: npm run test
- name: Run Jest tests
run: npm run test
5 changes: 0 additions & 5 deletions jest.config.js

This file was deleted.

16 changes: 16 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { JestConfigWithTsJest } from 'ts-jest';

Check failure on line 1 in jest.config.ts

View workflow job for this annotation

GitHub Actions / Prettier

jest.config.ts#L1

There are issues with this file's formatting, please run Prettier to fix the errors

const config: JestConfigWithTsJest = {
preset: 'ts-jest',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]sx?$': [
'ts-jest',
{
tsconfig: 'tsconfig.test.json'
}
]
}
};

export default config;
151 changes: 151 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"react-dom": "^18.2.0",
"tailwindcss": "^3.3.2",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"vite": "^5.0.12"
}
Expand Down
9 changes: 9 additions & 0 deletions src/common/isLyricsSynced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export const syncedLyricsRegex =
export const extendedSyncedLyricsLineRegex =
// eslint-disable-next-line no-useless-escape
/(?<extSyncTimeStamp>[\[<]\d+:\d{1,2}\.\d{1,3}[\]>]) ?(?=(?<lyric>[^<>\n]+))/gm;
export const extendedSyncedLyricsRegex =
/(?<extSyncTimeStamp><\d+:\d{1,2}\.\d{1,3}>) ?(?=(?<lyric>[^<>\n]+))/gm;

const isLyricsSynced = (lyrics: string) => {
const bool = syncedLyricsRegex.test(lyrics);
Expand All @@ -11,6 +13,13 @@ const isLyricsSynced = (lyrics: string) => {
return bool;
};

export const isLyricsEnhancedSynced = (syncedLyricsString: string) => {
const isEnhancedSynced = extendedSyncedLyricsRegex.test(syncedLyricsString);
extendedSyncedLyricsRegex.lastIndex = 0;

return isEnhancedSynced;
};

export const isAnExtendedSyncedLyricsLine = (line: string) => {
const bool = extendedSyncedLyricsLineRegex.test(line);
extendedSyncedLyricsLineRegex.lastIndex = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/main/utils/isPathADir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const isPathADir = (pathOrDir: string | Dirent) => {

if (!pathOrDir.isSymbolicLink()) return false;

const symlinkPath = path.join(pathOrDir.path, pathOrDir.name);
const symlinkPath = path.join(pathOrDir.parentPath, pathOrDir.name);

const symlinkStat = fs.statSync(symlinkPath);

Expand All @@ -32,4 +32,3 @@ const isPathADir = (pathOrDir: string | Dirent) => {
};

export default isPathADir;

Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { AppUpdateContext } from '../../contexts/AppUpdateContext';
import storage from '../../utils/localStorage';

import Button from '../Button';
import splitFeaturingArtists from '../../utils/splitFeaturingArtists';

type Props = {
name?: string;
artistId?: string;
};
export const separateArtistsRegex = / and | [Ff](?:ea)?t\. |&|,|;|·| ?\| | ?\/ | ?\\ /gm;

const SeparateArtistsSuggestion = (props: Props) => {
const { bodyBackgroundImage, currentSongData } = useContext(AppContext);
Expand All @@ -34,7 +34,7 @@ const SeparateArtistsSuggestion = (props: Props) => {
}, [artistId, ignoredArtists]);

const separatedArtistsNames = useMemo(() => {
const artists = name.split(separateArtistsRegex);
const artists = splitFeaturingArtists(name);
const filterArtists = artists.filter((x) => x !== undefined && x.trim() !== '');
const trimmedArtists = filterArtists.map((x) => x.trim());

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/LyricsPage/LyricsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import MainContainer from '../MainContainer';
import Button from '../Button';

import { appPreferences } from '../../../../../package.json';
import { isLyricsEnhancedSynced } from '../SongTagsEditingPage/input_containers/SongLyricsEditorInput';
import { LyricData } from '../LyricsEditingPage/LyricsEditingPage';
import { isLyricsEnhancedSynced } from '../../../../common/isLyricsSynced';

const { metadataEditingSupportedExtensions } = appPreferences;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import storage from '../../utils/localStorage';

import Button from '../Button';
import Checkbox from '../Checkbox';
import { separateArtistsRegex } from '../ArtistInfoPage/SeparateArtistsSuggestion';
import splitFeaturingArtists from '../../utils/splitFeaturingArtists';

type Props = {
songTitle?: string;
Expand Down Expand Up @@ -47,7 +47,7 @@ const SongsWithFeaturingArtistsSuggestion = (props: Props) => {
if (featArtistsExec && featArtistsExec.groups?.featArtists) {
const { featArtists: featArtistsStr } = featArtistsExec.groups;

const featArtists = featArtistsStr.split(separateArtistsRegex);
const featArtists = splitFeaturingArtists(featArtistsStr);
const filteredFeatArtists = featArtists.filter((featArtistName) => {
const isArtistAvailable = artistNames.some(
(name) => name.toLowerCase().trim() === featArtistName.toLowerCase().trim()
Expand Down
Loading

0 comments on commit 7cd905d

Please sign in to comment.