Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test (#587) #588

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report-버그-수정-템플릿-.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Bug report(버그 수정 템플릿)
about: 버그 제보 관련 템플릿
title: "[BUG]"
labels: "\U0001F41B 버그"
assignees: ''

---

### 버그 사항
해당 버그를 **자세하게** 적어주세요 😊


### 버그 simulation
버그를 발견하게 된 상황을 단계별로 적어주세요 😊


### 원하던 상황
원했던 상황을 자세하게 적어주세요 😊


### **Screenshots**
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request-기능-개발-템플릿-.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Feature request(기능 개발 템플릿)
about: 기능 이슈 관련 템플릿
title: ''
labels: ''
assignees: ''
---

## ✨ 추가 기능

<!-- 어떤 기능을 개발 -->

## 📆 일정 추정

<!-- 기능 구현에 소요되는 시간, 구현 시작/종료일 등 -->

## 📃 세부 사항

<!-- 사용할 기술, 패턴 등
기능 구현 시 다른 사람들이 알아야 할 점 -->

## ✅ 투두리스트

- [ ] item
- [ ] item

## 🔗 참고 자료
19 changes: 19 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## 🔥 연관 이슈

close: #

## 📝 작업 요약

수행할 작업을 1~2줄 사이로 요약해주세요.

## ⏰ 소요 시간

기능 구현에 소요된 시간을 적어주세요. (추정했던 시간과 다르다면 이유도 함께)

## 🔎 작업 상세 설명

주요 기능 및 로직에 관해 설명해주세요.

## 🌟 논의 사항

크루들과 이야기 해보고 싶은 부분을 적어주세요.
56 changes: 56 additions & 0 deletions .github/workflows/backend-pr-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Pull request comment (BE)
on:
issue_comment:
types: [created, edited, deleted]

defaults:
run:
working-directory: backend

jobs:
pull_request_comment:
# This job only runs for pull request comments
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
- name: Send Slack notification When Review Completed
if: contains(github.event.comment.body, 'be-리뷰완') # check the comment if it contains the keywords
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_BE_CHANNEL }} # Slack 채널 ID
payload: |
{
"text": "",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "리뷰 완료했습니다👍\n<${{ github.event.comment.html_url }}|리뷰어의 코멘트 확인하러 가기>"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }} # Slack 토큰

- name: Send Slack notification When Re-review Requested
if: contains(github.event.comment.body, 'be-리뷰요청')
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_BE_CHANNEL }}
payload: |
{
"text": "",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "리뷰 반영 최종 완료!✅ 확인 부탁드립니다😃\n<${{ github.event.comment.html_url }}|피드백 반영 확인하러 가기>"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }}
58 changes: 58 additions & 0 deletions .github/workflows/backend-pr-deadline-slack-bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Notify Pull Request Deadline (BE)

on:
pull_request:
types:
- opened
branches: ['dev']
paths:
- 'backend/**'

jobs:
pull_request_open:
runs-on: ubuntu-latest
name: New pr to repo
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Remove "https://" from PR URL
id: remove_https
run: |
PR_URL="${{ github.event.pull_request.html_url }}"
PR_URL="http://${PR_URL#https://}"
echo "::set-output name=pr_url::$PR_URL"

- name: Set environment variable
run: echo "PR_CREATED_AT_UTC=${{ github.event.pull_request.created_at }}" >> $GITHUB_ENV
- name: Convert UTC to KST
run: |
UTC_TIME=$PR_CREATED_AT_UTC
KST_TIME=$(date -u -d "$UTC_TIME 9 hour" "+%Y-%m-%dT%H:%M:%SZ")
echo "PR_CREATED_AT_KST=$KST_TIME" >> $GITHUB_ENV

- name: Calculate deadline
id: deadline
run: node .github/workflows/scripts/calculatePRDeadline.js
env:
PR_CREATED_AT_KST: ${{ env.PR_CREATED_AT_KST }}

- name: Send Slack notification When BE PR
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_BE_CHANNEL }} # Slack 채널 ID
payload: |
{
"text": "",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<${{ steps.remove_https.outputs.pr_url }}|${{ github.event.pull_request.title }}>\n코드리뷰 마감시간: ${{ steps.deadline.outputs.DEADLINE }}"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }} # Slack 토큰
71 changes: 71 additions & 0 deletions .github/workflows/backend-pr-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Backend Test When Pull Request

on:
pull_request:
branches:
- main
- dev
paths:
- 'backend/**'
- '.github/**'

defaults:
run:
working-directory: backend

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10

permissions:
checks: write
pull-requests: write

steps:
- name: 레포지토리 체크아웃
uses: actions/checkout@v3

- name: JDK 17 환경 설정
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin

- name: 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 실행 권한 부여
run: chmod +x gradlew

- name: Gradle 테스트 실행
run: ./gradlew --info test

- name: 테스트 결과 PR 코멘트 등록
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: '**/build/test-results/test/TEST-*.xml'

- name: 테스트 실패 시 해당 코드 라인에 Check 등록
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: '**/build/test-results/test/TEST-*.xml'

- name: 테스트 실패 시 Slack 알림
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: 백엔드 테스트 실패 알림
fields: repo, message, commit, author, action, eventName, ref, workflow, job, took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()
112 changes: 112 additions & 0 deletions .github/workflows/frontend-lighthouse-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Run Lighthouse CI When PR

on:
pull_request:
branches: ['dev']
paths:
- 'frontend/**'

defaults:
run:
working-directory: frontend

jobs:
lhci:
permissions: write-all
name: Lighthouse CI
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install packages
run: npm install

- name: Set environment variable
run: |
touch .env
echo VOTOGETHER_BASE_URL=${{ secrets.VOTOGETHER_BASE_URL }} >> .env
echo VOTOGETHER_MOCKING_URL=${{ secrets.VOTOGETHER_MOCKING_URL }} >> .env
echo VOTOGETHER_REST_API_KEY=${{ secrets.VOTOGETHER_REST_API_KEY }} >> .env
echo VOTOGETHER_SERVER_REDIRECT_URL=${{ secrets.VOTOGETHER_SERVER_REDIRECT_URL }} >> .env
echo VOTOGETHER_CHANNEL_TALK_KEY=${{ secrets.VOTOGETHER_CHANNEL_TALK_KEY }} >> .env
echo VOTOGETHER_GOOGLE_TAG_ID=${{ secrets.VOTOGETHER_GOOGLE_TAG_ID }} >> .env
cat .env

- name: Build
run: npm run build
env:
VOTOGETHER_BASE_URL: ${{ env.VOTOGETHER_BASE_URL }}
VOTOGETHER_MOCKING_URL: ${{ env.VOTOGETHER_MOCKING_URL }}
VOTOGETHER_REST_API_KEY: ${{ env.VOTOGETHER_REST_API_KEY }}
VOTOGETHER_SERVER_REDIRECT_URL: ${{ env.VOTOGETHER_SERVER_REDIRECT_URL}}
VOTOGETHER_CHANNEL_TALK_KEY: ${{ env.VOTOGETHER_CHANNEL_TALK_KEY }}
VOTOGETHER_GOOGLE_TAG_ID: ${{ env.VOTOGETHER_GOOGLE_TAG_ID }}

- name: Run Lighthouse CI
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm install -g @lhci/cli
lhci autorun || echo "Fail to Run Lighthouse CI!"

- name: Format lighthouse score
id: format_lighthouse_score
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs');

const results = JSON.parse(fs.readFileSync('./frontend/lhci_reports/manifest.json'));
let comments = '';

results.forEach((result) => {
const { summary, jsonPath } = result;

const details = JSON.parse(fs.readFileSync(jsonPath));
const { audits } = details;

const formatResult = (res) => Math.round(res * 100);

Object.keys(summary).forEach(
(key) => (summary[key] = formatResult(summary[key]))
);

const score = (res) => (res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴');

const comment = [
`⚡️ Lighthouse report!`,
`| Category | Score |`,
`| --- | --- |`,
`| ${score(summary.performance)} Performance | ${summary.performance} |`,
`| ${score(summary.accessibility)} Accessibilty | ${summary.accessibility} |`,
`| ${score(summary.seo)} SEO | ${summary.seo} |`,
`| ${score(summary.pwa)} PWA | ${summary.pwa} |`,
].join('\n');

const detail = [
`| Category | Score |`,
`| --- | --- |`,
`| ${score(audits['first-contentful-paint'].score * 100)} First Contentful Paint | ${audits['first-contentful-paint'].displayValue} |`,
`| ${score(audits['largest-contentful-paint'].score * 100)} Largest Contentful Paint | ${audits['largest-contentful-paint'].displayValue} |`,
`| ${score(audits['total-blocking-time'].score * 100)} Total Blocking Time | ${audits['total-blocking-time'].displayValue} |`,
`| ${score(audits['cumulative-layout-shift'].score * 100)} Cumulative Layout Shift | ${audits['cumulative-layout-shift'].displayValue} |`,
`| ${score(audits['speed-index'].score * 100)} Speed Index | ${audits['speed-index'].displayValue} |`,
].join('\n');

comments += comment + '\n\n' + detail + '\n';
});

core.setOutput('comments', comments)

- name: comment PR
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
message: ${{ steps.format_lighthouse_score.outputs.comments}}
Loading
Loading