[web3.js][experimental] A GitHub Actions workflow that builds the new code with Turborepo (#28916)

* Enable remote cache for Turborepo

* Rename `build` to `compile` and `package` to `build`

* Add a workflow that builds on PRs and pushes with Turborepo

* Explain how to connect to Turborepo remote caching

* Upgrade to pnpm 7
This commit is contained in:
Steven Luscher 2022-11-21 21:47:32 -08:00 committed by GitHub
parent 20d8b5e98b
commit 2aca4160ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 79 additions and 10 deletions

49
.github/workflows/web3-experimental.yml vendored Normal file
View File

@ -0,0 +1,49 @@
name: Web3.js Experimental
on:
push:
branches: ["master"]
paths:
- "web3.js-experimental/**"
pull_request:
types: [opened, synchronize]
paths:
- "web3.js-experimental/**"
jobs:
build:
name: Build
timeout-minutes: 15
runs-on: ubuntu-latest
defaults:
run:
working-directory: web3.js-experimental
# To use Turborepo Remote Caching, set the following environment variables for the job.
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: pnpm/action-setup@v2.0.1
with:
version: 7
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 16
cache: "pnpm"
cache-dependency-path: "web3.js-experimental/pnpm-lock.yaml"
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build

View File

@ -1,2 +1,3 @@
dist/ dist/
node_modules/ node_modules/
.turbo

View File

@ -0,0 +1,16 @@
# Solana JavaScript API
## Development Environment Setup
### Speed up build times with remote caching
Cache build artifacts remotely so that you, others, and the CI server can take advantage of each others' build efforts.
1. Log the Turborepo CLI into the Solana Vercel account
```shell
pnpm turbo login
```
2. Link the repository to the remote cache
```shell
pnpm turbo link
```

View File

@ -18,11 +18,11 @@
"web3" "web3"
], ],
"scripts": { "scripts": {
"build": "tsup", "build": "turbo run compile:js compile:typedefs lint verifyTreeShakability:browser verifyTreeShakability:native verifyTreeShakability:node",
"build:typedefs": "tsc -p ./tsconfig.declarations.json", "compile:js": "tsup",
"dev": "pnpm run build --watch", "compile:typedefs": "tsc -p ./tsconfig.declarations.json",
"dev": "pnpm run compile:js --watch",
"lint": "eslint 'src/**'", "lint": "eslint 'src/**'",
"package": "turbo build build:typedefs lint verifyTreeShakability:browser verifyTreeShakability:native verifyTreeShakability:node",
"verifyTreeShakability:browser": "agadoo dist/index.browser.esm.js", "verifyTreeShakability:browser": "agadoo dist/index.browser.esm.js",
"verifyTreeShakability:native": "agadoo dist/index.node.esm.js", "verifyTreeShakability:native": "agadoo dist/index.node.esm.js",
"verifyTreeShakability:node": "agadoo dist/index.native.esm.js" "verifyTreeShakability:node": "agadoo dist/index.native.esm.js"

View File

@ -1,27 +1,30 @@
{ {
"$schema": "https://turbo.build/schema.json", "$schema": "https://turbo.build/schema.json",
"pipeline": { "pipeline": {
"build": { "compile:js": {
"outputs": ["dist/**"] "outputs": ["dist/**"]
}, },
"build:typedefs": { "compile:typedefs": {
"dependsOn": ["build"], "dependsOn": ["compile:js"],
"outputs": ["dist/**"] "outputs": ["dist/**"]
}, },
"lint": { "lint": {
"outputs": [] "outputs": []
}, },
"verifyTreeShakability:browser": { "verifyTreeShakability:browser": {
"dependsOn": ["build"], "dependsOn": ["compile:js"],
"outputs": [] "outputs": []
}, },
"verifyTreeShakability:native": { "verifyTreeShakability:native": {
"dependsOn": ["build"], "dependsOn": ["compile:js"],
"outputs": [] "outputs": []
}, },
"verifyTreeShakability:node": { "verifyTreeShakability:node": {
"dependsOn": ["build"], "dependsOn": ["compile:js"],
"outputs": [] "outputs": []
} }
},
"remoteCache": {
"signature": true
} }
} }