Skip to content

Commit

Permalink
Merge pull request #261 from daodaoedu/ci/type-check
Browse files Browse the repository at this point in the history
ci: add typescript check
  • Loading branch information
JohnsonMao authored Jan 28, 2025
2 parents cefa1f6 + 924e189 commit 1161670
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 6 deletions.
48 changes: 45 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,50 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

check:
name: TypeScript Check
runs-on: ubuntu-latest
needs: init

steps:
- name: Git checkout
uses: actions/checkout@v4

- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: |
node_modules
~/.cache/Cypress
key: deps-node-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

- name: TypeScript Check
id: check
run: |
if ! yarn ts:check; then
ERROR_MSG=$(yarn ts:check 2>&1)
echo "check_error<<EOF" >> $GITHUB_OUTPUT
echo "$ERROR_MSG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
exit 1
fi
- name: Send TypeScript Error Notification
if: steps.check.outcome == 'failure'
uses: ./.github/actions/notification
with:
TYPE: failure
TITLE: "❌ TypeScript Error"
DESCRIPTION: "Branch: ${{ env.BRANCH_NAME }}\n\n${{ steps.check.outputs.check_error }}"
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}

lint:
name: Lint
name: ESLint Check
runs-on: ubuntu-latest
needs: init

Expand All @@ -58,7 +100,7 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

- name: lint
- name: ESLint Check
id: lint
continue-on-error: true
run: |
Expand All @@ -74,7 +116,7 @@ jobs:
git add .
git diff --cached --quiet || echo "changes=true" >> $GITHUB_OUTPUT
- name: Send Error Notification
- name: Send ESLint Error Notification
if: steps.lint.outcome == 'failure'
uses: ./.github/actions/notification
with:
Expand Down
48 changes: 45 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,50 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

check:
name: TypeScript Check
runs-on: ubuntu-latest
needs: init

steps:
- name: Git checkout
uses: actions/checkout@v4

- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: |
node_modules
~/.cache/Cypress
key: deps-node-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

- name: TypeScript Check
id: check
run: |
if ! yarn ts:check; then
ERROR_MSG=$(yarn ts:check 2>&1)
echo "check_error<<EOF" >> $GITHUB_OUTPUT
echo "$ERROR_MSG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
exit 1
fi
- name: Send TypeScript Error Notification
if: steps.check.outcome == 'failure'
uses: ./.github/actions/notification
with:
TYPE: failure
TITLE: "❌ TypeScript Error"
DESCRIPTION: "Branch: ${{ env.BRANCH_NAME }}\n\n${{ steps.check.outputs.check_error }}"
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}

lint:
name: Lint
name: ESLint Check
runs-on: ubuntu-latest
needs: init

Expand All @@ -58,7 +100,7 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

- name: lint
- name: ESLint Check
id: lint
continue-on-error: true
run: |
Expand All @@ -74,7 +116,7 @@ jobs:
git add .
git diff --cached --quiet || echo "changes=true" >> $GITHUB_OUTPUT
- name: Send Error Notification
- name: Send ESLint Error Notification
if: steps.lint.outcome == 'failure'
uses: ./.github/actions/notification
with:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"start": "next start",
"sitemap": "next-sitemap",
"lint": "eslint \"{pages,components,shared,constants}/**/*.{ts,tsx,js,jsx}\" --fix",
"ts:check": "tsc --noEmit --incremental false",
"pages:build": "npx @cloudflare/next-on-pages",
"preview": "npm run pages:build && wrangler pages dev",
"deploy": "npm run pages:build && wrangler pages deploy"
Expand Down

0 comments on commit 1161670

Please sign in to comment.