Files
stacks-blockchain-api/.github/workflows/stacks-blockchain-api.yml
2021-12-22 13:22:15 -05:00

504 lines
15 KiB
YAML

name: stacks-blockchain-api
on:
push:
branches:
- '**'
tags-ignore:
- '**'
paths-ignore:
- '**/CHANGELOG.md'
- '**/package.json'
pull_request:
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install deps
run: npm install --audit=false
- name: Lint ESLint
run: npm run lint:eslint
- name: Lint Prettier
run: npm run lint:prettier
- name: Lint Unused Exports
run: npm run lint:unused-exports
lint-docs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./docs
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install deps
run: npm install --audit=false
- name: Build schema & docs
run: npm run build
- name: Validate generated types
run: tsc index.d.ts
- name: Lint JSON
run: npm run lint:json
- name: Lint YAML
run: npm run lint:yaml
- name: Lint OpenAPI
run: npm run lint:openapi
- name: Validate schemas
run: npm run validate:schemas
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install deps
run: npm install --audit=false
- name: Install client deps
working-directory: client
run: npm install --audit=false
- name: Install docs deps
working-directory: docs
run: npm install --audit=false
- name: Setup env vars
run: echo "STACKS_CORE_EVENT_HOST=http://0.0.0.0" >> $GITHUB_ENV
- name: Setup integration environment
run: |
sudo ufw disable
npm run devenv:deploy -- -d
npm run devenv:logs -- --no-color &> docker-compose-logs.txt &
- name: Run tests
run: npm run test
- name: Print integration environment logs
run: cat docker-compose-logs.txt
if: failure()
- name: Teardown integration environment
run: npm run devenv:stop
if: always()
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
if: always()
test-bns:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install deps
run: npm install --audit=false
- name: Setup env vars
run: echo "STACKS_CORE_EVENT_HOST=http://0.0.0.0" >> $GITHUB_ENV
- name: Setup integration environment
run: |
sudo ufw disable
npm run devenv:deploy -- -d
npm run devenv:logs -- --no-color &> docker-compose-logs.txt &
- name: Run bns tests
run: npm run test:bns
- name: Print integration environment logs
run: cat docker-compose-logs.txt
if: failure()
- name: Teardown integration environment
run: npm run devenv:stop
if: always()
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
if: always()
test-rosetta:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install deps
run: npm install --audit=false
- name: Setup env vars
run: echo "STACKS_CORE_EVENT_HOST=http://0.0.0.0" >> $GITHUB_ENV
- name: Setup integration environment
run: |
sudo ufw disable
npm run devenv:deploy -- -d
npm run devenv:logs -- --no-color &> docker-compose-logs.txt &
- name: Run tests
run: npm run test:rosetta
- name: Print integration environment logs
run: cat docker-compose-logs.txt
if: failure()
- name: Teardown integration environment
run: npm run devenv:stop
if: always()
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
if: always()
test-rosetta-cli-data:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install deps
run: npm install --audit=false
- name: Setup env vars
run: echo "STACKS_CORE_EVENT_HOST=http://0.0.0.0">> $GITHUB_ENV
- name: Setup cli enviroment variable
run: |
echo STACKS_BLOCKCHAIN_API_HOST=0.0.0.0>> .env
echo STACKS_CORE_PROXY_HOST=0.0.0.0 >> .env
echo STACKS_CORE_RPC_HOST=0.0.0.0 >> .env
echo STACKS_CORE_EVENT_HOST=0.0.0.0 >> .env
echo BTC_RPC_HOST=http://0.0.0.0 >> .env
- name: Setup integration environment
run: |
sudo ufw disable
npm run devenv:deploy -- -d
npm run devenv:logs -- --no-color &> docker-compose-logs.txt &
- name: Run tests
run: sudo npm run test:rosetta-cli:data
- name: Print integration environment logs
run: cat docker-compose-logs.txt
if: failure()
- name: Teardown integration environment
run: npm run devenv:stop
if: always()
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
if: always()
test-rosetta-cli-construction:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install deps
run: npm install --audit=false
- name: Setup env vars
run: echo "STACKS_CORE_EVENT_HOST=http://0.0.0.0">> $GITHUB_ENV
- name: Setup cli enviroment variable
run: |
echo STACKS_BLOCKCHAIN_API_HOST=0.0.0.0>> .env
echo STACKS_CORE_PROXY_HOST=0.0.0.0 >> .env
echo STACKS_CORE_RPC_HOST=0.0.0.0 >> .env
echo STACKS_CORE_EVENT_HOST=0.0.0.0 >> .env
echo BTC_RPC_HOST=http://0.0.0.0 >> .env
- name: Setup integration environment
run: |
sudo ufw disable
npm run devenv:deploy -- -d
npm run devenv:logs -- --no-color &> docker-compose-logs.txt &
- name: Run tests
run: sudo npm run test:rosetta-cli:construction
- name: Print integration environment logs
run: cat docker-compose-logs.txt
if: failure()
- name: Teardown integration environment
run: npm run devenv:stop
if: always()
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
if: always()
test-tokens:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
- name: Install deps
run: npm install
- name: Setup env vars
run: echo "STACKS_CORE_EVENT_HOST=http://0.0.0.0" >> $GITHUB_ENV
- name: Setup integration environment
run: |
sudo ufw disable
npm run devenv:deploy -- -d
npm run devenv:logs -- --no-color &> docker-compose-logs.txt &
- name: Run tokens tests
run: npm run test:tokens
- name: Print integration environment logs
run: cat docker-compose-logs.txt
if: failure()
- name: Teardown integration environment
run: npm run devenv:stop
if: always()
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
if: always()
build-publish:
runs-on: ubuntu-latest
needs:
- lint
- lint-docs
- test
- test-bns
- test-rosetta
- test-rosetta-cli-construction
- test-rosetta-cli-data
- test-tokens
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2.7.0
id: semantic
# Only run on non-PR events or only PRs that aren't from forks
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SEMANTIC_RELEASE_PACKAGE: ${{ github.workflow }}
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
@semantic-release/exec
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker Meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
blockstack/${{ github.workflow }}
hirosystems/${{ github.workflow }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}},value=${{ steps.semantic.outputs.new_release_version }},enable=${{ steps.semantic.outputs.new_release_version != '' }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.semantic.outputs.new_release_version }},enable=${{ steps.semantic.outputs.new_release_version != '' }}
- name: Docker Standalone Meta
id: meta_standalone
uses: docker/metadata-action@v3
with:
images: |
blockstack/${{ github.workflow }}-standalone
hirosystems/${{ github.workflow }}-standalone
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}},value=${{ steps.semantic.outputs.new_release_version }},enable=${{ steps.semantic.outputs.new_release_version != '' }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.semantic.outputs.new_release_version }},enable=${{ steps.semantic.outputs.new_release_version != '' }}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build/Tag/Push Image
uses: docker/build-push-action@v2
with:
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Only push if (there's a new release on main branch, or if building a non-main branch) and (Only run on non-PR events or only PRs that aren't from forks)
push: ${{ (github.ref != 'refs/heads/master' || steps.semantic.outputs.new_release_version != '') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
- name: Build/Tag/Push Standalone Image
uses: docker/build-push-action@v2
with:
context: .
file: docker/stx-rosetta.Dockerfile
tags: ${{ steps.meta_standalone.outputs.tags }}
labels: ${{ steps.meta_standalone.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Only push if (there's a new release on main branch, or if building a non-main branch) and (Only run on non-PR events or only PRs that aren't from forks)
push: ${{ (github.ref != 'refs/heads/master' || steps.semantic.outputs.new_release_version != '') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}