diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 26a90cb..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,77 +0,0 @@ -version: 2.1 - -executors: - default: - docker: - - image: circleci/node:10 - working_directory: ~/project - environment: - YARN_CACHE_FOLDER: "~/.cache/yarn" - -commands: - attach_project: - steps: - - attach_workspace: - at: ~/project - -jobs: - install-dependencies: - executor: default - steps: - - checkout - - attach_project - - restore_cache: - keys: - - yarn-packages-v1-{{ .Branch }}-{{ checksum "yarn.lock" }} - - yarn-packages-v1-{{ .Branch }}- - - yarn-packages-v1- - - run: - name: Install project dependencies - command: yarn install --frozen-lockfile - - save_cache: - key: yarn-packages-v1-{{ .Branch }}-{{ checksum "yarn.lock" }} - paths: ~/.cache/yarn - - persist_to_workspace: - root: . - paths: . - - lint-and-typecheck: - executor: default - steps: - - attach_project - - run: - name: Lint files - command: yarn lint - - run: - name: Prettier (for TS files) - command: | - yarn prettier --list-different "**/*.js" "**/*.ts" - - run: - name: Typecheck files - command: | - yarn typescript - - unit-tests: - executor: default - steps: - - attach_project - - run: - name: Run unit tests - command: yarn test --maxWorkers=2 --coverage - - run: - name: Upload test coverage - command: yarn codecov - - store_artifacts: - path: coverage - destination: coverage - -workflows: - lint-and-test: - jobs: - - install-dependencies - - lint-and-typecheck: - requires: - - install-dependencies - - unit-tests: - requires: - - install-dependencies diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..e6f4287 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,27 @@ +name: Setup +description: Setup Node.js and install dependencies + +runs: + using: composite + steps: + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version-file: .nvmrc + + - name: Cache dependencies + id: yarn-cache + uses: actions/cache@v3 + with: + path: | + **/node_modules + .yarn/install-state.gz + key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }} + restore-keys: | + ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} + ${{ runner.os }}-yarn- + + - name: Install dependencies + if: steps.yarn-cache.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile + shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4483756 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: CI +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup + uses: ./.github/actions/setup + + - name: Lint files + run: yarn lint + + - name: Typecheck files + run: yarn typecheck + + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup + uses: ./.github/actions/setup + + - name: Run unit tests + run: yarn test --maxWorkers=2 --coverage + + - name: Upload test coverage + run: yarn codecov + + - name: Store test coverage + uses: actions/upload-artifact@v4 + with: + name: coverage + path: coverage diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..9a2a0e2 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v20 diff --git a/package.json b/package.json index b47eacb..b0eed14 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "scripts": { "test": "jest", "lint": "eslint .", - "typescript": "tsc --noEmit", + "typecheck": "tsc --noEmit", "release": "release-it" }, "publishConfig": { @@ -61,7 +61,8 @@ }, "husky": { "hooks": { - "pre-commit": "yarn lint && yarn typescript && yarn test" + "pre-commit": "yarn lint && yarn typecheck && yarn test" } - } + }, + "packageManager": "yarn@4.3.1" }