Skip to content

Commit

Permalink
release v1.1.0
Browse files Browse the repository at this point in the history
release v1.1.0
  • Loading branch information
onschan authored Aug 19, 2022
2 parents 0392e28 + 1013b1b commit a56ac60
Show file tree
Hide file tree
Showing 285 changed files with 9,447 additions and 1,943 deletions.
25 changes: 17 additions & 8 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,47 @@
name: sonar backend
name: sonarqube backend

on:
pull_request:
branches: [dev]
paths: ["backend/**"]
types: [opened, synchronize, reopened]

defaults:
run:
working-directory: backend

jobs:
build:
name: sonar backend
name: sonarqube backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: checkout source
uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0

- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache SonarCloud packages

- name: Cache SonarQube packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONARQUBE_HOST_URL }}
run: ./gradlew build sonarqube --info
134 changes: 132 additions & 2 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: sonar frontend
name: frontend
on:
pull_request:
branches: [dev]
paths: ["frontend/**"]
paths: ['frontend/**']
types: [opened, synchronize, reopened]

defaults:
run:
working-directory: frontend

jobs:
sonarcloud:
name: sonar frontend
Expand All @@ -15,3 +17,131 @@ jobs:
- uses: actions/checkout@v2
- run: npm ci
- run: npm run build

lhci:
name: Lighthouse CI
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1

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

- name: NPM CI
run: |
npm ci
- name: Build
run: |
npm run build
- name: Lighthouse Run
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
run: |
npm install -g @lhci/cli
lhci autorun || echo "LHCI failed!"
- 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('${{ github.workspace }}/frontend/lhci_reports/manifest.json'));
let comments = "";
const { summary, jsonPath } = results[0];
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)} Accessibility | ${summary.accessibility} |`,
`| ${score(summary[`best-practices`])} Best Practices | ${summary[`best-practices`]} |`,
`| ${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[`speed-index`].score * 100
)} Speed Index | ${
audits[`speed-index`].displayValue
} |`,
`| ${score(
audits[`total-blocking-time`].score * 100
)} Total Blocking Time | ${
audits[`total-blocking-time`].displayValue
} |`,
`| ${score(
audits[`largest-contentful-paint`].score * 100
)} Largest Contentful Paint | ${
audits[`largest-contentful-paint`].displayValue
} |`,
`| ${score(
audits[`cumulative-layout-shift`].score * 100
)} Cumulative Layout Shift | ${
audits[`cumulative-layout-shift`].displayValue
} |`
].join("\n");
comments += comment + "\n" + detail + "\n";
core.setOutput('comments', comments);
- name: Comment PR
uses: unsplash/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: ${{ steps.format_lighthouse_score.outputs.comments}}

cypress-run:
name: Cypress E2E CI
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cypress CI
uses: cypress-io/github-action@v4
with:
browser: chrome
headed: true
build: npm run build
start: npm run start
wait-on: 'http://localhost:3000'
record: true
parallel: true
working-directory: frontend
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}}
COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha}}
continue-on-error: true
31 changes: 26 additions & 5 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ sourceCompatibility = '11'

configurations {
asciidoctorExtensions
cucumberRuntime.extendsFrom(implementation, testImplementation, runtimeOnly)
}

repositories {
Expand Down Expand Up @@ -58,6 +59,11 @@ dependencies {
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation 'org.springframework.restdocs:spring-restdocs-restassured'

//cucumber
testImplementation 'io.cucumber:cucumber-java:6.10.4'
testImplementation 'io.cucumber:cucumber-spring:6.10.4'
testImplementation 'io.cucumber:cucumber-junit-platform-engine:6.10.4'

// slack
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'com.slack.api:slack-app-backend:1.22.2'
Expand Down Expand Up @@ -119,12 +125,27 @@ jacocoTestReport {
}
}

task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = [
'--plugin', 'pretty',
'--plugin', 'html:build/reports/cucumber/cucumber-report.html',
'--glue', 'com.woowacourse.gongcheck',
'src/test/resources/features']
}
}
}

build {
dependsOn cucumber
}

sonarqube {
properties {
property "sonar.projectKey", "woowacourse-teams_2022-gong-check"
property "sonar.organization", "woowacourse-teams"
property "sonar.host.url", "https://sonarcloud.io"
property 'sonar.coverage.jacoco.xmlReportPaths', 'build/reports/jacoco/test/jacocoTestReport.xml'
property 'sonar.language', 'java'
property "sonar.projectKey", "woowacourse-teams_2022-gong-check_AYKm4KvOS_3Pe1LEsoLu"
}
}
3 changes: 3 additions & 0 deletions backend/src/docs/asciidoc/errorCode.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[[ErrorCode]]
== 에러 코드
operation::errorCode[snippets='error-code']
1 change: 1 addition & 0 deletions backend/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ include::task.adoc[]
include::runningTask.adoc[]
include::submission.adoc[]
include::image-upload.adoc[]
include::errorCode.adoc[]
6 changes: 5 additions & 1 deletion backend/src/docs/asciidoc/runningTask.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

=== RunningTask 정보 조회

operation::runningTasks/find/success[snippets='http-request,http-response,path-parameters,response-fields']
operation::runningTasks/connect/success[snippets='http-request,http-response,path-parameters']

=== RunningTask 완료 여부 확인

Expand All @@ -16,3 +16,7 @@ operation::runningTasks/check/success[snippets='http-request,http-response,path-
=== RunningTask 생성

operation::runningTasks/create/success[snippets='http-request,http-response,path-parameters']

=== Section의 RunningTask 모두 체크상태로 변환

operation::runningTasks/allCheck/success[snippets='http-request,http-response,path-parameters']
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.woowacourse.gongcheck.auth.application;

import com.woowacourse.gongcheck.exception.BusinessException;
import com.woowacourse.gongcheck.exception.ErrorCode;
import org.springframework.stereotype.Component;

@Component
Expand All @@ -26,13 +27,15 @@ public Long parseId(final String entranceCode) {
validateIdSize(id);
return id;
} catch (NumberFormatException | BusinessException e) {
throw new BusinessException("유효하지 않은 입장코드입니다.");
String message = String.format("유효하지 않은 입장코드입니다. entranceCode = %s", entranceCode);
throw new BusinessException(message, ErrorCode.H002);
}
}

private void validateIdSize(final Long id) {
if (id < MINIMUM_ID_SIZE) {
throw new BusinessException("유효하지 않은 id입니다.");
String message = String.format("유효하지 않은 id입니다. id = %d", id);
throw new BusinessException(message, ErrorCode.H003);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static com.woowacourse.gongcheck.auth.domain.Authority.HOST;

import com.woowacourse.gongcheck.auth.application.response.GithubProfileResponse;
import com.woowacourse.gongcheck.auth.application.response.SocialProfileResponse;
import com.woowacourse.gongcheck.auth.application.response.TokenResponse;
import com.woowacourse.gongcheck.auth.presentation.request.TokenRequest;
import com.woowacourse.gongcheck.core.domain.host.Host;
Expand All @@ -28,17 +28,17 @@ public HostAuthService(final JwtTokenProvider jwtTokenProvider, final GithubOaut

@Transactional
public TokenResponse createToken(final TokenRequest request) {
GithubProfileResponse githubProfileResponse = githubOauthClient.requestGithubProfileByCode(request.getCode());
boolean alreadyJoin = hostRepository.existsByGithubId(githubProfileResponse.getGithubId());
Host host = findOrCreateHost(alreadyJoin, githubProfileResponse);
SocialProfileResponse socialProfileResponse = githubOauthClient.requestSocialProfileByCode(request.getCode());
boolean alreadyJoin = hostRepository.existsByGithubId(socialProfileResponse.getGithubId());
Host host = findOrCreateHost(alreadyJoin, socialProfileResponse);
String token = jwtTokenProvider.createToken(String.valueOf(host.getId()), HOST);
return TokenResponse.of(token, alreadyJoin);
}

private Host findOrCreateHost(final boolean alreadyJoin, final GithubProfileResponse githubProfileResponse) {
private Host findOrCreateHost(final boolean alreadyJoin, final SocialProfileResponse socialProfileResponse) {
if (alreadyJoin) {
return hostRepository.getByGithubId(githubProfileResponse.getGithubId());
return hostRepository.getByGithubId(socialProfileResponse.getGithubId());
}
return hostRepository.save(githubProfileResponse.toHost());
return hostRepository.save(socialProfileResponse.toHost());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.woowacourse.gongcheck.auth.application;

import com.woowacourse.gongcheck.auth.application.response.SocialProfileResponse;

public interface OAuthClient {
SocialProfileResponse requestSocialProfileByCode(String code);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import lombok.Getter;

@Getter
public class GithubAccessTokenResponse {
public class OAuthAccessTokenResponse {

@JsonProperty("access_token")
private String accessToken;

private GithubAccessTokenResponse() {
private OAuthAccessTokenResponse() {
}

public GithubAccessTokenResponse(final String accessToken) {
public OAuthAccessTokenResponse(final String accessToken) {
this.accessToken = accessToken;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lombok.Getter;

@Getter
public class GithubProfileResponse {
public class SocialProfileResponse {

@JsonProperty("name")
private String nickname;
Expand All @@ -16,10 +16,10 @@ public class GithubProfileResponse {
@JsonProperty("avatar_url")
private String imageUrl;

private GithubProfileResponse() {
private SocialProfileResponse() {
}

public GithubProfileResponse(final String nickname, final String loginName, final String githubId,
public SocialProfileResponse(final String nickname, final String loginName, final String githubId,
final String imageUrl) {
this.nickname = nickname;
this.loginName = loginName;
Expand Down
Loading

0 comments on commit a56ac60

Please sign in to comment.