Skip to content

Commit

Permalink
PR CI 추가 (#227)
Browse files Browse the repository at this point in the history
* PR CI 추가

* test

* Fix: 코멘트 작성할 수 있는 권한 추가

* test를 위한 코드 제거

* eslint 적용

* Chore: 불 달기
  • Loading branch information
Zeniuus authored Nov 5, 2023
1 parent a07b7b0 commit fa2f4d9
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dev-ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
branches:
- main
workflow_dispatch:
workflow_dispatch: # for manual trigger

permissions:
id-token: write
Expand Down
106 changes: 106 additions & 0 deletions .github/workflows/pr-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: pr-ci
on:
pull_request:
on:
- synchronize
workflow_dispatch: # for manual trigger

permissions:
id-token: write
pull-requests: write

jobs:
backend-ci:
runs-on: ubuntu-latest
services:
postgresql:
image: postgres:14.5-alpine
ports:
- 15432:5432
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: scc_test

defaults:
run:
working-directory: app-server

steps:
- uses: actions/checkout@v3

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: adopt
java-version: 19

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

# https://github.com/actions/cache/blob/main/examples.md#java---gradle
- uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Gradle Check
run: ./gradlew clean check

- uses: actions/upload-artifact@v3
name: Upload Check Report If Failed
if: failure()
with:
name: test report
path: "**/build/reports"
retention-days: 1

- name: Notify CI failure to PR
uses: thollander/actions-comment-pull-request@v2
if: failure()
with:
message: |
:fire::fire::fire: Backend CI Failed. [github action link](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) :fire::fire::fire:
frontend-ci:
runs-on: ubuntu-latest

defaults:
run:
working-directory: app-admin-frontend

steps:
- uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install & Run openapi-generator
run: |
mkdir -p ~/bin/openapitools
curl https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/bin/utils/openapi-generator-cli.sh > ~/bin/openapitools/openapi-generator-cli
chmod u+x ~/bin/openapitools/openapi-generator-cli
export PATH=$PATH:~/bin/openapitools/
mv ~/bin/openapitools/openapi-generator-cli ~/bin/openapitools/openapi-generator
./generate-api-spec.sh
- name: Build
run: |
npm install -f
npm run build:dev
- name: Notify CI failure to PR
uses: thollander/actions-comment-pull-request@v2
if: failure()
with:
message: |
:fire::fire::fire: Frontend CI Failed. [github action link](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) :fire::fire::fire:
2 changes: 1 addition & 1 deletion .github/workflows/prod-ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
tags:
- '[0-9]+.[0-9]+.[0-9]+' # Follow semantic versioning
- '[0-9]+.[0-9]+.[0-9]+-hotfix[0-9]' # For hotfix
workflow_dispatch:
workflow_dispatch: # for manual trigger

permissions:
contents: write
Expand Down
5 changes: 4 additions & 1 deletion app-admin-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
"extends": [
"react-app",
"react-app/jest"
]
],
"rules": {
"react-hooks/exhaustive-deps": "off"
}
},
"browserslist": {
"production": [
Expand Down
1 change: 0 additions & 1 deletion app-admin-frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useState } from 'react';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import HomePage from './page/Home/HomePage';
import LoginPage from './page/Login/LoginPage';
Expand Down
1 change: 0 additions & 1 deletion app-admin-frontend/src/context/AuthContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ interface AuthContextType {
isAuthenticated: () => boolean;
}

const accessToken = getSavedAccessToken();
export default React.createContext<AuthContextType>({
isAuthenticated: () => false,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function AccessibilityAllowedRegionPage() {
installMap(accessibilityAllowedRegion);
})
);
}, []);
});

const installMap = (accessibilityAllowedRegion: AccessibilityAllowedRegionDTO) => {
if (map == null) {
Expand Down
21 changes: 6 additions & 15 deletions app-admin-frontend/src/page/Challenge/ChallengePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {AdminChallengeDTO} from "../../api";
import {formatDate} from "../../util/date";
import {MultiSelect2} from "@blueprintjs/select";
import {adminChallengeActionConditionTypeOptions} from "../../model/challenge";
import {MultiSelectItem} from "../../component/MultiSelect";

declare global {
interface Window {
Expand All @@ -18,25 +17,17 @@ declare global {
}

function ChallengePage() {
const [isLoading, setIsLoading] = useState(false);
const [challenge, setChallenge] = useState<AdminChallengeDTO>();

function withLoading(promise: Promise<any>): Promise<any> {
setIsLoading(true);
return promise.finally(() => setIsLoading(false));
}

const { id: _rawChallengeId } = useParams();
const challengeId = _rawChallengeId!
useEffect(() => {
withLoading(
AdminApis.challenge.challengesChallengeIdGet(challengeId)
.then((res) => {
const challenge = res.data;
setChallenge(challenge);
})
);
}, []);
AdminApis.challenge.challengesChallengeIdGet(challengeId)
.then((res) => {
const challenge = res.data;
setChallenge(challenge);
})
});

return (
challenge == null
Expand Down
2 changes: 1 addition & 1 deletion app-admin-frontend/src/page/ClubQuest/ClubQuestPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function ClubQuestPage() {
installMap(clubQuest);
})
);
}, []);
});
useEffect(() => {
const timeout = setTimeout(() => {
withLoading(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function CreateAccessibilityAllowedRegionPage() {
return promise.finally(() => setIsLoading(false));
}

useEffect(installMapOnce, []);
useEffect(installMapOnce);

function installMapOnce() {
if (map) {
Expand Down Expand Up @@ -116,9 +116,9 @@ function CreateAccessibilityAllowedRegionPage() {
disabled={isLoading}
/>
</div>
<Button icon="confirm" text="확정하기 (정보 등록 허용 지역 생성)" onClick={createAccessibilityAllowedRegion} disabled={isLoading || boundaryVertices.length == 0 || !regionName}></Button>
<Button icon="trash" text="마지막 점 없애기" onClick={onDeleteLastVertex} disabled={isLoading || boundaryVertices.length == 0}></Button>
<Button icon="trash" text="모든 점 없애기" onClick={onDeleteAllVertices} disabled={isLoading || boundaryVertices.length == 0}></Button>
<Button icon="confirm" text="확정하기 (정보 등록 허용 지역 생성)" onClick={createAccessibilityAllowedRegion} disabled={isLoading || boundaryVertices.length === 0 || !regionName}></Button>
<Button icon="trash" text="마지막 점 없애기" onClick={onDeleteLastVertex} disabled={isLoading || boundaryVertices.length === 0}></Button>
<Button icon="trash" text="모든 점 없애기" onClick={onDeleteAllVertices} disabled={isLoading || boundaryVertices.length === 0}></Button>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function CreateChallengePage() {
const [goal, setGoal] = useState<number>(1);
const [milestonesText, setMilestonesText] = useState<string>('');
const getMilestones = (): number[] => {
if (milestonesText.trim() == '') {
if (milestonesText.trim() === '') {
return [];
}
return milestonesText.split(',').map(it => Number(it.trim())).sort((n1,n2) => n1 - n2);
Expand Down Expand Up @@ -72,7 +72,7 @@ function CreateChallengePage() {
name: challengeName,
isPublic,
invitationCode: isPublic ? undefined : invitationCode,
passcode: passcode == null || passcode == '' ? undefined : passcode!.trim(),
passcode: passcode == null || passcode === '' ? undefined : passcode!.trim(),
startsAtMillis: startsAtDate.getTime(),
endsAtMillis: endsAtDate?.getTime(),
goal,
Expand All @@ -97,8 +97,8 @@ function CreateChallengePage() {
const isFormValid = () => {
const request = getCreateChallengeRequestDTO();
return (
request.name != ''
&& (isPublic || (request.invitationCode != null && request.invitationCode != ''))
request.name !== ''
&& (isPublic || (request.invitationCode != null && request.invitationCode !== ''))
&& goal > 0
&& (getMilestones().length === 0 || getMilestones()[getMilestones().length - 1] < goal)
);
Expand Down Expand Up @@ -154,7 +154,7 @@ function CreateChallengePage() {
disabled={isLoading || isPublic}
/>
{
!isPublic && (invitationCode == null || invitationCode == '')
!isPublic && (invitationCode == null || invitationCode === '')
? (
<span style={{'color': 'red'}}>비공개 챌린지는 초대 코드를 지정해야 합니다.</span>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function CreateClubQuestPage() {
return promise.finally(() => setIsLoading(false));
}

useEffect(installMapOnce, []);
useEffect(installMapOnce);
useEffect(() => {
createOrUpdateQuestCenterIndicator();
}, [questCenter, questRadius]);
Expand Down

0 comments on commit fa2f4d9

Please sign in to comment.