From 1be392bf27b72f5e2f322b41ed3859a1014e5602 Mon Sep 17 00:00:00 2001 From: usn757 Date: Mon, 27 Jan 2025 11:48:25 +0900 Subject: [PATCH 1/3] first c --- problem01/problem01.js | 8 ++++---- problem02/problem02.js | 4 ++++ problem03/problem03.js | 6 +++--- problem04/problem04.js | 5 ++--- problem05/problem05.js | 4 ++-- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/problem01/problem01.js b/problem01/problem01.js index 4bee421..051397f 100644 --- a/problem01/problem01.js +++ b/problem01/problem01.js @@ -10,13 +10,13 @@ function grade(score) { let result; if (score > 100 || score < 0) { - result = "C"; // 🚨 + result = "Invalid"; // 🚨 } else if (score >= 90) { - result = "B"; // 🚨 - } else if (score >= 80) { result = "A"; // 🚨 - } else { + } else if (score >= 80) { result = "B"; // 🚨 + } else { + result = "C"; // 🚨 } return result; diff --git a/problem02/problem02.js b/problem02/problem02.js index ff7014b..6b635ba 100644 --- a/problem02/problem02.js +++ b/problem02/problem02.js @@ -11,12 +11,16 @@ function checkNumber(num) { switch (true) { case typeof num !== "number" || isNaN(num): // 🚨 result = "μˆ«μžκ°€ μ•„λ‹™λ‹ˆλ‹€."; + break; case num > 0: // 🚨 result = "μ–‘μˆ˜μž…λ‹ˆλ‹€."; + break; case num < 0: // 🚨 result = "μŒμˆ˜μž…λ‹ˆλ‹€."; + break; case num === 0: // 🚨 result = "0μž…λ‹ˆλ‹€."; + break; default: // 🚨 result = "μ•Œ 수 μ—†λŠ” 였λ₯˜μž…λ‹ˆλ‹€."; } diff --git a/problem03/problem03.js b/problem03/problem03.js index 1b59f8c..504de46 100644 --- a/problem03/problem03.js +++ b/problem03/problem03.js @@ -7,10 +7,10 @@ */ /* problem03.js */ function sumExcludingMultiplesOfThreeAndFive(n) { - let sum = 1; // 🚨 + let sum = 0; // 🚨 for (let i = 1; i <= n; i++) { - if (i % 3 !== 0 && i % 5 !== 0) continue; // 🚨 - sum -= i; // 🚨 + if (i % 3 == 0 || i % 5 == 0) continue; // 🚨 + sum += i; // 🚨 } return sum; } diff --git a/problem04/problem04.js b/problem04/problem04.js index 0c25c97..d60af85 100644 --- a/problem04/problem04.js +++ b/problem04/problem04.js @@ -6,13 +6,12 @@ * - ν˜„μž¬ μ½”λ“œλŠ” 잘λͺ»λœ 둜직으둜 인해 ν…ŒμŠ€νŠΈκ°€ μ‹€νŒ¨ν•©λ‹ˆλ‹€. */ function sumUpToTen(n) { - let sum = 1; // 🚨 + let sum = 0; // 🚨 let i = 1; while (i <= n) { if (i > 10) break; // 🚨 - sum -= i; // 🚨 - i++; + sum += i++; // 🚨 } return sum; diff --git a/problem05/problem05.js b/problem05/problem05.js index c74abb6..5eee46b 100644 --- a/problem05/problem05.js +++ b/problem05/problem05.js @@ -6,11 +6,11 @@ * - λͺ¨λ“  쑰건을 ν™•μΈν•œ ν›„ μ΅œν›„μ— `return`을 μ‚¬μš©ν•˜μ„Έμš”. */ function sumOfSmallProducts(n) { - let sum = 1; // 🚨 + let sum = 0; // 🚨 for (let i = 1; i <= n; i++) { for (let j = 1; j <= n; j++) { if (i * j > 10) continue; // 🚨 - sum -= i * j; // 🚨 + sum += i * j; // 🚨 } } return sum; From 208e2933454aa5cac59d429305b22640312bad77 Mon Sep 17 00:00:00 2001 From: usn757 Date: Mon, 27 Jan 2025 11:59:34 +0900 Subject: [PATCH 2/3] second --- problem01/problem01.js | 9 ++++----- problem02/problem02.js | 6 +++--- problem03/problem03.js | 4 ++-- problem05/problem05.js | 4 ++-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/problem01/problem01.js b/problem01/problem01.js index 051397f..9e31b27 100644 --- a/problem01/problem01.js +++ b/problem01/problem01.js @@ -8,15 +8,14 @@ /* problem01.js */ function grade(score) { let result; - if (score > 100 || score < 0) { - result = "Invalid"; // 🚨 + result = "Invalid"; } else if (score >= 90) { - result = "A"; // 🚨 + result = "A"; } else if (score >= 80) { - result = "B"; // 🚨 + result = "B"; } else { - result = "C"; // 🚨 + result = "C"; } return result; diff --git a/problem02/problem02.js b/problem02/problem02.js index 6b635ba..eb4c838 100644 --- a/problem02/problem02.js +++ b/problem02/problem02.js @@ -12,13 +12,13 @@ function checkNumber(num) { case typeof num !== "number" || isNaN(num): // 🚨 result = "μˆ«μžκ°€ μ•„λ‹™λ‹ˆλ‹€."; break; - case num > 0: // 🚨 + case num > 0: result = "μ–‘μˆ˜μž…λ‹ˆλ‹€."; break; - case num < 0: // 🚨 + case num < 0: result = "μŒμˆ˜μž…λ‹ˆλ‹€."; break; - case num === 0: // 🚨 + case num === 0: result = "0μž…λ‹ˆλ‹€."; break; default: // 🚨 diff --git a/problem03/problem03.js b/problem03/problem03.js index 504de46..6989502 100644 --- a/problem03/problem03.js +++ b/problem03/problem03.js @@ -7,9 +7,9 @@ */ /* problem03.js */ function sumExcludingMultiplesOfThreeAndFive(n) { - let sum = 0; // 🚨 + let sum = 0; for (let i = 1; i <= n; i++) { - if (i % 3 == 0 || i % 5 == 0) continue; // 🚨 + if (i % 3 == 0 || i % 5 == 0) continue; sum += i; // 🚨 } return sum; diff --git a/problem05/problem05.js b/problem05/problem05.js index 5eee46b..6dd93fc 100644 --- a/problem05/problem05.js +++ b/problem05/problem05.js @@ -9,8 +9,8 @@ function sumOfSmallProducts(n) { let sum = 0; // 🚨 for (let i = 1; i <= n; i++) { for (let j = 1; j <= n; j++) { - if (i * j > 10) continue; // 🚨 - sum += i * j; // 🚨 + if (i * j > 10) continue; + sum += i * j; } } return sum; From 192710646b8d4ae8f467d05cc3cb7fdc09c033e8 Mon Sep 17 00:00:00 2001 From: usn757 Date: Mon, 27 Jan 2025 16:55:13 +0900 Subject: [PATCH 3/3] gogo --- .github/workflows/test.yml | 54 ++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2a8bedb..2005bdf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,36 +1,56 @@ -name: Node.js CI +name: Node.js CI + Auto Approve on: - # "on" ν‚€μ›Œλ“œλŠ” 이 μ›Œν¬ν”Œλ‘œμš°λ₯Ό μ–Έμ œ μ–΄λ–»κ²Œ μ‹€ν–‰ν• μ§€ μ •μ˜ push: - branches: [ "main" ] - # main λΈŒλžœμΉ˜μ— μƒˆ 컀밋이 ν‘Έμ‹œ(push)될 λ•Œ μžλ™μœΌλ‘œ μ›Œν¬ν”Œλ‘œμš° μ‹€ν–‰ + branches: ["main"] pull_request: - branches: [ "main" ] - # main 브랜치 λŒ€μƒμ˜ ν’€ λ¦¬ν€˜μŠ€νŠΈ(PR)κ°€ 생성, μ—…λ°μ΄νŠΈ, 병합 μ€€λΉ„ λ“± μƒνƒœκ°€ 변경될 λ•Œ μ‹€ν–‰ + branches: ["main"] + pull_request_target: # πŸ”₯ μžλ™ μŠΉμΈμ„ μœ„ν•œ μΆ”κ°€ 이벀트 + types: [opened, reopened, synchronize] workflow_dispatch: - # μˆ˜λ™ μ‹€ν–‰(Dispatch)을 ν—ˆμš© - # GitHub Actions νŽ˜μ΄μ§€μ—μ„œ "Run workflow" λ²„νŠΌμ„ 눌러 직접 트리거 κ°€λŠ₯ + +permissions: + actions: write + pull-requests: read + contents: read # μ½”λ“œ 체크아웃을 μœ„ν•΄ μΆ”κ°€ jobs: - build-and-test: + # ---------------------------------- + # 1. μžλ™ 승인 μž‘μ—… (μ‹ κ·œ κΈ°μ—¬μžμš©) + # ---------------------------------- + auto-approve: + if: github.event_name == 'pull_request_target' # PR λŒ€μƒ μ΄λ²€νŠΈμ—μ„œλ§Œ μ‹€ν–‰ runs-on: ubuntu-latest + steps: + - name: Approve First-Time Contributors + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + RUN_IDS=$(gh api "/repos/${{ github.repository }}/actions/runs?event=pull_request&pull_request=$PR_NUMBER" --jq '.workflow_runs[] | select(.status == "waiting") | .id') + for RUN_ID in $RUN_IDS; do + echo "Approving Run ID: $RUN_ID" + gh api -X POST "/repos/${{ github.repository }}/actions/runs/$RUN_ID/approve" + done + # ---------------------------------- + # 2. κΈ°μ‘΄ λΉŒλ“œ/ν…ŒμŠ€νŠΈ μž‘μ—… (λͺ¨λ“  PR에 적용) + # ---------------------------------- + build-and-test: + needs: auto-approve # μžλ™ 승인 ν›„ μ‹€ν–‰ + runs-on: ubuntu-latest steps: - - name: Check out repository code - uses: actions/checkout@v3 - # ν˜„μž¬ λ¦¬ν¬μ§€ν† λ¦¬μ˜ μ½”λ“œλ₯Ό κ°€μ Έμ˜΄ (μ†ŒμŠ€ μ ‘κ·Ό 및 λΉŒλ“œ/ν…ŒμŠ€νŠΈ μœ„ν•΄ ν•„μš”) + - name: Checkout code + uses: actions/checkout@v4 # v3 β†’ v4둜 μ—…κ·Έλ ˆμ΄λ“œ - name: Use Node.js 22.x - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 # v3 β†’ v4둜 μ—…κ·Έλ ˆμ΄λ“œ with: node-version: 22 - # Node.js 22 버전 ν™˜κ²½μ—μ„œ 슀크립트 μ‹€ν–‰ + cache: "npm" # πŸ”₯ npm 캐싱 μΆ”κ°€ (λΉŒλ“œ 속도 ν–₯상) - name: Install dependencies - run: npm install - # package.json에 λͺ…μ‹œλœ μ˜μ‘΄μ„±(라이브러리 λ“±)을 μ„€μΉ˜ + run: npm ci # npm install β†’ npm ci둜 λ³€κ²½ (μ •ν™•ν•œ 버전 보μž₯) - name: Run tests run: npm test - # Jest λ“±μœΌλ‘œ μž‘μ„±λœ ν…ŒμŠ€νŠΈ 슀크립트λ₯Ό μ‹€ν–‰ \ No newline at end of file