From 75cb96743c39c74a7a5878387f8b4792c9622c46 Mon Sep 17 00:00:00 2001 From: Andy Wu Date: Sat, 16 Mar 2024 10:10:01 -0700 Subject: [PATCH] [feat] add ci workflow triggered by pr [feat] enable ESLint --- .eslintrc.js | 33 ++++++++++++++++++++++++++++ .github/workflows/on_pr.yml | 43 +++++++++++++++++++++++++++++++++++++ package.json | 6 ++++-- 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 .eslintrc.js create mode 100644 .github/workflows/on_pr.yml diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..96ec2a0 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,33 @@ +module.exports = { + "env": { + "browser": true, + "es2021": true + }, + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended" + ], + "overrides": [ + { + "env": { + "node": true + }, + "files": [ + ".eslintrc.{js,cjs}" + ], + "parserOptions": { + "sourceType": "script" + } + } + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + } +} diff --git a/.github/workflows/on_pr.yml b/.github/workflows/on_pr.yml new file mode 100644 index 0000000..136c107 --- /dev/null +++ b/.github/workflows/on_pr.yml @@ -0,0 +1,43 @@ +name: CI workflow on PR + +on: + pull_request: + branches: + - master + - main + +jobs: + + print_timestamp: + runs-on: ubuntu-latest + steps: + - name: Generate timestamp + run: | + echo "TIMESTAMP=$(TZ='America/Los_Angeles' date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV + + - name: Print timestamp + run: | + echo "Execution time (Pacific Time Zone) $TIMESTAMP" + + lint_and_test: + runs-on: ubuntu-latest + needs: print_timestamp + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + + - name: Set up Node.js + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version: '20' + + - name: Install dependencies + run: npm install + + - name: Lint + run: npm run lint + + - name: Test + run: npm test + diff --git a/package.json b/package.json index 3820ddc..a3e9ca3 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,11 @@ "@types/mocha-steps": "^1.3.3", "@types/node": "^20.8.2", "@types/sinon": "^10.0.18", + "@typescript-eslint/eslint-plugin": "^7.2.0", + "@typescript-eslint/parser": "^7.2.0", "chai": "^4.3.10", "chai-as-promised": "^7.1.1", - "eslint": "^8.50.0", + "eslint": "^8.57.0", "mocha": "^10.2.0", "mocha-steps": "^1.3.0", "mochawesome": "^7.1.3", @@ -42,4 +44,4 @@ "url": "https://github.com/storyprotocol/sdk-e2e-tests/issues" }, "homepage": "https://github.com/storyprotocol/sdk-e2e-tests#readme" -} \ No newline at end of file +}