Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tanakaworld committed Apr 8, 2024
1 parent 79a7523 commit 2dd8a50
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 80 deletions.
40 changes: 0 additions & 40 deletions .github/workflows/before-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,43 +34,3 @@ jobs:
name: dist
path: dist
if-no-files-found: error

test-e2e:
name: E2E Test

needs: lint-test-build

runs-on: ubuntu-latest
strategy:
matrix:
browser: [chrome, firefox, edge]

steps:
- uses: actions/checkout@v2
- name: Read .node-version
id: node-version
uses: juliangruber/read-file-action@v1
with:
path: ./.node-version
- name: Use Node.js ${{ steps.node-version.outputs.content }}
uses: actions/setup-node@v2
with:
node-version: ${{ steps.node-version.outputs.content }}
cache: 'npm'
- name: Download Artifact
uses: actions/download-artifact@master
with:
name: dist
path: dist
- name: E2E by Cypress
uses: cypress-io/github-action@v2
with:
browser: ${{ matrix.browser }}
command: npm run e2e:ci
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-${{ matrix.browser }}
path: |
cypress/videos
cypress/screenshots
44 changes: 4 additions & 40 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,12 @@ jobs:
path: dist
if-no-files-found: error

test-e2e:
name: E2E Test
deploy:
name: Deploy

needs: lint-test-build

runs-on: ubuntu-latest
strategy:
matrix:
browser: [chrome, firefox, edge]

steps:
- uses: actions/checkout@v2
Expand All @@ -57,41 +54,8 @@ jobs:
with:
node-version: ${{ steps.node-version.outputs.content }}
cache: 'npm'
- name: Download Artifact
uses: actions/download-artifact@master
with:
name: dist
path: dist
- name: E2E by Cypress
uses: cypress-io/github-action@v2
with:
browser: ${{ matrix.browser }}
command: npm run e2e:ci
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-${{ matrix.browser }}
path: |
cypress/videos
cypress/screenshots
deploy:
name: Deploy

needs: test-e2e

runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.16.0]

steps:
- uses: actions/checkout@master
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@master
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install
run: npm ci
- name: Download Artifact
uses: actions/download-artifact@master
with:
Expand Down
16 changes: 16 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
globals: {
'ts-jest': {
diagnostics: false,
},
},
moduleNameMapper: {
'^~(.*)$': '<rootDir>/src/$1',
},
moduleFileExtensions: ['ts', 'js', 'vue', 'json'],
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(ts?)$',
testPathIgnorePatterns: ['<rootDir>/cypress'],
transform: {
'^.+\\.ts?$': 'ts-jest',
},
};
19 changes: 19 additions & 0 deletions src/utils/date.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const DATE_FORMAT_REGEX = /([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/;

export function getAgeLocal(dateStr: string): number {
if (!dateStr.match(DATE_FORMAT_REGEX)) {
throw new Error('Please set date as yyyy-MM-dd format');
}

const birthday = new Date(dateStr);
const now = new Date();

const birthdayHaveCome =
now.getMonth() > birthday.getMonth() ||
(now.getMonth() === birthday.getMonth() &&
now.getDate() >= birthday.getDate());

return (
now.getFullYear() - birthday.getFullYear() - (birthdayHaveCome ? 0 : 1)
);
}

0 comments on commit 2dd8a50

Please sign in to comment.