diff --git a/.github/actions/prepare-spl-name-service-env/action.yml b/.github/actions/prepare-spl-name-service-env/action.yml new file mode 100644 index 0000000..cf8d34f --- /dev/null +++ b/.github/actions/prepare-spl-name-service-env/action.yml @@ -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- diff --git a/.github/workflows/check-spl-name-service.yml b/.github/workflows/check-spl-name-service.yml new file mode 100644 index 0000000..d1b9abe --- /dev/null +++ b/.github/workflows/check-spl-name-service.yml @@ -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 diff --git a/js/package.json b/js/package.json index 4adbbd5..ff87032 100644 --- a/js/package.json +++ b/js/package.json @@ -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": { @@ -77,5 +78,8 @@ }, "peerDependencies": { "@solana/web3.js": "^1.87.3" + }, + "volta": { + "node": "20.10.0" } }