Skip to content
This repository has been archived by the owner on Aug 24, 2023. It is now read-only.

Commit

Permalink
chore(ts-tests): refactor ts-tests/* to follow pnpm and turbo works…
Browse files Browse the repository at this point in the history
…pace design (#86)

#### What this PR does / why we need it:

Move `ts-tests/*` to utilize pnpm and turbo mono-repo workspace design.
With this, we managed to keep configs (eslint, prettier, babel jest)
DRY. The PR "workspace-ize" `ts-tests` but ultimately many more PR is
required to break this package into multiple smaller mono repo packages.

Follow-up PRs required to address these:

- [ ] ESLINT will be added back once we move to "testsuite", also part
of #79
- [ ] #78 

---

**What's new?**

As suggested in
#66 (comment) I've
added hardhat compile turbo workflow.

`@birthdayresearch/sticky-turbo-jest` is a turbo-aware `jest-preset`; it
automatically run `dependsOn` script before running jest. By taking
advantage of content-aware hashing from turborepo. `dependsOn` only runs
if the pipeline `inputs` has changed.

When you run your test with `@birthdayresearch/sticky-turbo-jest`
preset, it uses `displayName` from your jest config to figure out which
`pipeline` to use. It will automatically pinpoint the corresponding
`dependsOn` and run all the scripts specified within.

> TLDR, when you run a dependent test, it automatically recompiles your
contract with hardhat when it detects changes in your `contracts/*.sol`
file. If it has the cached version, it will simply "output" the result
instead of rebuilding it.

https://sticky.birthday.dev/packages/sticky-turbo-jest

`package.json`:
```json
  "scripts": {
    "compile": "hardhat compile",
    "test": "jest"
  },
  "jest": {
    "displayName": "test",
    "preset": "@birthdayresearch/sticky-turbo-jest"
  },
```

`turbo.json`:
```json
    "compile": {
      "inputs": ["contracts/**"],
      "outputs": ["artifacts", "cache"]
    },
    "test": {
      "inputs": ["src/**", "**/*.unit.ts", "tests-e2e/**"],
      "dependsOn": ["^build", "compile"]
    },
```

#### Which issue(s) does this PR fixes?:

<!--
(Optional) Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->

Fixes part of #79
  • Loading branch information
fuxingloh authored and canonbrother committed Sep 28, 2022
1 parent e5ba1cc commit 5c7bb96
Show file tree
Hide file tree
Showing 19 changed files with 5,077 additions and 26,443 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,3 @@ jobs:
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # tag=v3.1.0
with:
fail_ci_if_error: true

test_pnpm_e2e: # TODO(fuxingloh): move to PNPM
name: Test (pnpm e2e)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2

- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3.4.1
with:
node-version: 16
cache: 'npm'
cache-dependency-path: 'ts-tests/package-lock.json'
- run: cd ts-tests && npm ci && npm t
3 changes: 2 additions & 1 deletion packages/typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"isolatedModules": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true
"preserveWatchOutput": true,
"resolveJsonModule": true
},
"exclude": ["node_modules", "dist"]
}
Loading

0 comments on commit 5c7bb96

Please sign in to comment.