Skip to content

Commit

Permalink
Merge pull request #1 from diegofigs/ci/add-ci-workflow
Browse files Browse the repository at this point in the history
ci: add ci workflow
  • Loading branch information
diegofigs authored Feb 2, 2025
2 parents c975641 + 98e21c4 commit f5cd5ae
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 17 deletions.
40 changes: 23 additions & 17 deletions .github/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ const App: React.FC = () => {
throw new Error(`Index generation failed: ${resp.statusText}`);
}
setIndexReady(true);
} catch (err: any) {
setError(err.message);
} catch (err: unknown) {
if (err instanceof Error) {
setError(err.message);
}
}
};
generateIndex();
Expand Down Expand Up @@ -238,8 +240,10 @@ const App: React.FC = () => {
}
const data: SearchResponse = await resp.json();
setGlobalResults(data.data || []);
} catch (err: any) {
setError(err.message);
} catch (err: unknown) {
if (err instanceof Error) {
setError(err.message);
}
} finally {
setGlobalLoading(false);
}
Expand Down Expand Up @@ -270,8 +274,10 @@ const App: React.FC = () => {
}
const data: SearchResponse = await resp.json();
setGames(data.data);
} catch (err: any) {
setError(err.message);
} catch (err: unknown) {
if (err instanceof Error) {
setError(err.message);
}
} finally {
setLoadingGames(false);
}
Expand Down Expand Up @@ -582,16 +588,14 @@ const GlobalSearchResults: React.FC<GlobalSearchResultsProps> = ({
throw new Error(`Launch failed: ${resp.statusText}`);
}
console.log("Game launched:", game.path);
} catch (err: any) {
alert("Failed to launch: " + err.message);
} catch (err: unknown) {
if (err instanceof Error) {
alert("Failed to launch: " + err.message);
}
}
};

const handleKeyDown = (
e: KeyboardEvent<HTMLDivElement>,
game: GameEntry,
_: number,
) => {
const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>, game: GameEntry) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
handleLaunchGame(game);
Expand Down Expand Up @@ -638,7 +642,7 @@ const GlobalSearchResults: React.FC<GlobalSearchResultsProps> = ({
ref={(el) => (refs[idx] = el)}
onClick={() => handleLaunchGame(game)}
tabIndex={0}
onKeyDown={(e) => handleKeyDown(e, game, idx)}
onKeyDown={(e) => handleKeyDown(e, game)}
className={`
cursor-pointer p-3 text-center outline-none
focus:ring-2 focus:ring-offset-2
Expand Down Expand Up @@ -738,9 +742,11 @@ const GamesView: React.FC<GamesViewProps> = ({
throw new Error(`Launch failed: ${resp.statusText}`);
}
console.log("Game launched:", game.path);
} catch (err: any) {
console.error("Failed to launch:", err.message);
alert("Failed to launch game: " + err.message);
} catch (err: unknown) {
if (err instanceof Error) {
console.error("Failed to launch:", err.message);
alert("Failed to launch game: " + err.message);
}
}
};

Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI

on:
pull_request:
push:
branches: [main]

env:
appRoot: .github/app

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.appRoot }}
strategy:
matrix:
node-version: [20]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9.15.2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
cache-dependency-path: ${{ env.appRoot }}/pnpm-lock.yaml
- run: pnpm install
- run: pnpm build
- run: cp -f dist/* ${{ github.workspace }}/remote_game_gallery
- name: Build DB
uses: diegofigs/MiSTer-build-db@v1
with:
db-name: "remote-game-gallery"
dryrun: true
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.appRoot }}
strategy:
matrix:
node-version: [20]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9.15.2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
cache-dependency-path: ${{ env.appRoot }}/pnpm-lock.yaml
- run: pnpm install
- run: pnpm lint

0 comments on commit f5cd5ae

Please sign in to comment.