Skip to content

Commit

Permalink
Merge pull request #1 from joonatan-aatos/feature/add-github-actions
Browse files Browse the repository at this point in the history
Add CI pipeline
  • Loading branch information
joonatanaatos authored Dec 23, 2023
2 parents 7e3563a + 9ca58b3 commit 7e11b17
Show file tree
Hide file tree
Showing 16 changed files with 323 additions and 22 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/build-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build Project

on: push

jobs:
build-and-push:
runs-on: ubuntu-latest
env:
DOCKER_USERNAME: joonatanaatos
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
strategy:
matrix:
component:
- { dir: 'backend', image: 'joonatanaatos/kuka-soittaa-backend' }
- {
dir: 'admin-panel',
image: 'joonatanaatos/kuka-soittaa-admin-panel',
}
- { dir: 'app' }
steps:
- uses: actions/checkout@v3
- name: Install dependencies for ${{ matrix.component.dir }}
run: |
cd ${{ matrix.component.dir }}
yarn install --frozen-lockfile --non-interactive
- name: Lint ${{ matrix.component.dir }}
run: |
cd ${{ matrix.component.dir }}
yarn lint
- name: Build ${{ matrix.component.dir }}
run: |
cd ${{ matrix.component.dir }}
yarn build
- name: Extract branch name
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
if: matrix.component.image
- name: Push Docker image
uses: docker/build-push-action@v5
with:
push: true
context: ${{ matrix.component.dir }}
tags: ${{ matrix.component.image }}:${{ env.BRANCH_NAME }}
if: matrix.component.image
- name: Push Docker image with latest tag
uses: docker/build-push-action@v5
with:
push: true
context: ${{ matrix.component.dir }}
tags: ${{ matrix.component.image }}:latest
if: github.ref == 'refs/heads/main' && matrix.component.image
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
30 changes: 30 additions & 0 deletions admin-panel/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "react"],
"rules": {
"react/react-in-jsx-scope": "off",
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
]
},
"ignorePatterns": ["build/*"]
}
8 changes: 7 additions & 1 deletion admin-panel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"scripts": {
"start": "PORT=8080 BROWSER=none react-scripts start",
"build": "react-scripts build",
"lint": "eslint . && prettier --check .",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Expand All @@ -46,6 +47,11 @@
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@types/react-toastify": "^4.1.0"
"@types/react-toastify": "^4.1.0",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"eslint": "^8.56.0",
"eslint-plugin-react": "^7.33.2",
"prettier": "^3.1.1"
}
}
2 changes: 1 addition & 1 deletion admin-panel/public/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
5 changes: 3 additions & 2 deletions admin-panel/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import React from 'react';

test("Placeholder", () => {
test('Placeholder', () => {
expect(true).toBe(true);
});
1 change: 1 addition & 0 deletions admin-panel/src/context/AppContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface AppContextInterface {
removeAudio: (id: string) => Promise<void>;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const defaultFunction = (): any =>
console.warn('AppContext function not implemented');

Expand Down
6 changes: 3 additions & 3 deletions admin-panel/src/index.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
2 changes: 1 addition & 1 deletion admin-panel/src/modals/NewCallerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const NewCallerModal = ({ isOpen, onClose }: NewCallerModalProps) => {
const result = await createCaller(formData);
toast.success(`Added caller ${result.name}!`);
await onClose(true);
} catch (e: any) {
} catch (e: unknown) {
toast.error(`Failed to add caller`);
await onClose(false);
}
Expand Down
2 changes: 1 addition & 1 deletion admin-panel/src/modals/NewEventModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const NewEventModal = ({ isOpen, onClose }: NewEventModalProps) => {
`Added event for ${new Date(result.time).toLocaleDateString()}!`,
);
await onClose(true);
} catch (e: any) {
} catch (e: unknown) {
toast.error(`Failed to add caller`);
await onClose(false);
}
Expand Down
5 changes: 3 additions & 2 deletions admin-panel/src/views/EventView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const EventView = () => {
<Container>
<NewEventModal
isOpen={newEventModalOpen}
onClose={async (success) => {
onClose={async (_success) => {
setNewEventModalOpen(false);
}}
/>
Expand All @@ -33,8 +33,9 @@ const EventView = () => {
<DeleteConfirmModal
isOpen={eventToDelete !== null}
onClose={async (success) => {
if (!eventToDelete) return;
if (success) {
await removeEvent(eventToDelete!.id);
await removeEvent(eventToDelete.id);
}
setEventToDelete(null);
}}
Expand Down
10 changes: 2 additions & 8 deletions admin-panel/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
Expand All @@ -20,7 +16,5 @@
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
"include": ["src"]
}
Loading

0 comments on commit 7e11b17

Please sign in to comment.