Skip to content

Commit

Permalink
feat: Add basic CI for @bonfida/spl-name-service
Browse files Browse the repository at this point in the history
  • Loading branch information
letehaha authored and dr497 committed Dec 5, 2023
1 parent cf9910f commit 52019f0
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/actions/prepare-spl-name-service-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Prepare local env
description: Prepare local environment by setup node, and cache dependencies
outputs:
cache-hit:
description: Whether the dependencies were cached
value: ${{ steps.npm-cache.outputs.cache-hit }}
runs:
using: composite
steps:
- name: Setup Node
# Use Node version specified in Volta config inside package.json
uses: volta-cli/action@v4
- name: Get npm cache directory
shell: bash
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v3
id: npm-cache
with:
path: |
**/node_modules
${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
55 changes: 55 additions & 0 deletions .github/workflows/check-spl-name-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Check spl-name-service

on:
push:
branches: [main]
paths:
- 'js/**'
pull_request:
branches: [main]
paths:
- 'js/**'

defaults:
run:
working-directory: ./js

jobs:
prepare-dependencies:
name: Prepare local deps
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- id: prepare-env
uses: ./.github/actions/prepare-spl-name-service-env
- name: Use cache or install dependencies
if: steps.prepare-env.outputs.cache-hit != 'true'
run: npm ci

test:
name: Test source code
needs: prepare-dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- uses: ./.github/actions/prepare-spl-name-service-env
- name: Make envfile
run: |
rm .env || true;
touch .env;
echo "RPC_URL=${{ secrets.RPC_URL }}" >> .env;
- name: Test source code
run: npm run test

build:
name: Build source code
needs: prepare-dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- uses: ./.github/actions/prepare-spl-name-service-env
- name: Build source code
run: npm run build
4 changes: 4 additions & 0 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"lint:fix": "yarn pretty:fix && eslint . --fix",
"pretty": "prettier --check 'src/*.[jt]s'",
"pretty:fix": "prettier --write 'src/*.[jt]s'",
"test": "jest ./tests",
"doc": "yarn typedoc src/index.ts"
},
"devDependencies": {
Expand Down Expand Up @@ -77,5 +78,8 @@
},
"peerDependencies": {
"@solana/web3.js": "^1.87.3"
},
"volta": {
"node": "20.10.0"
}
}

0 comments on commit 52019f0

Please sign in to comment.