feat: add log-level lib #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: pull-request | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
NODE_VERSION: "18" | |
CACHE_KEY: ${{ secrets.CACHE_KEY }} # Change to bust caches | |
PROVIDER_URL: https://eth-mainnet.g.alchemy.com/v2/${{ secrets.ALCHEMY_API_KEY }} | |
IPFS_GATEWAY_URL: https://api.nexusmutual.io | |
COVER_ROUTER_URL: https://api.nexusmutual.io/v2 | |
jobs: | |
version: | |
runs-on: ubuntu-22.04 | |
if: github.base_ref == 'master' | |
outputs: | |
local_version: ${{ steps.local_version.outputs.value }} | |
registry_version: ${{ steps.registry_version.outputs.value }} | |
steps: | |
- name: GitHub context | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Get local version | |
id: local_version | |
run: | | |
version=$(cat ./package.json | jq --raw-output .version) | |
echo $version | |
echo "value=$version" >> $GITHUB_OUTPUT | |
- name: Get registry version | |
id: registry_version | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
run: | | |
package_name="$(cat ./package.json | jq --raw-output .name)" | |
echo $package_name | |
version=$(npm view $package_name version) | |
echo $version | |
echo "value=$version" >> $GITHUB_OUTPUT | |
- name: Validate version | |
uses: actions/github-script@v6 | |
with: | |
result-encoding: string | |
script: | | |
const local_version = '${{ steps.local_version.outputs.value }}'; | |
const registry_version = '${{ steps.registry_version.outputs.value }}'; | |
core.info(`Repository version: ${local_version}`); | |
core.info(`Registry version: ${registry_version}`); | |
if (registry_version === local_version) { | |
core.setFailed('Please bump version before merging'); | |
} | |
checks: | |
runs-on: ubuntu-22.04 | |
needs: [version] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- uses: actions/cache@v3 | |
id: cache | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-${{ env.CACHE_KEY }}-${{ hashFiles('package-lock.json') }} | |
- name: Install dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: Build package | |
run: npm run build | |
- name: Run linter | |
run: npm run lint | |
- name: Check types and typescript | |
run: npm run ts:check | |
- name: Run tests | |
run: npm run test |