Skip to content

Commit

Permalink
Merge pull request #51 from hirosystems/beta
Browse files Browse the repository at this point in the history
release ordinals API v0.1.0
  • Loading branch information
rafaelcr committed May 15, 2023
2 parents fa35f7d + d9ad8e4 commit f3152e3
Show file tree
Hide file tree
Showing 70 changed files with 7,247 additions and 3,452 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/node_modules
**/tmp
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# STACKS_API_ENDPOINT=
# STACKS_EXPLORER_ENDPOINT=
# See src/env.ts for environment variable documentation.
63 changes: 42 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,27 @@ name: CI
on:
push:
branches:
- main
- master
- develop
- beta
tags-ignore:
- "**"
- '**'
paths-ignore:
- "**/CHANGELOG.md"
- "**/package.json"
- '**/CHANGELOG.md'
- '**/package.json'
pull_request:
workflow_dispatch:

# Cancel previous runs for the same workflow
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version-file: ".nvmrc"
node-version-file: '.nvmrc'

- name: Cache node modules
uses: actions/cache@v2
Expand All @@ -55,14 +50,23 @@ jobs:

test:
runs-on: ubuntu-latest

env:
API_HOST: 127.0.0.1
API_PORT: 3000
PGHOST: 127.0.0.1
PGPORT: 5432
PGUSER: postgres
PGPASSWORD: postgres
PGDATABASE: postgres
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version-file: ".nvmrc"
node-version-file: '.nvmrc'

- name: Cache node modules
uses: actions/cache@v2
Expand All @@ -84,36 +88,53 @@ jobs:
- name: Setup integration environment
run: |
sudo ufw disable
npm run testenv:run -- -d
npm run testenv: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 testenv:stop
if: always()

build-publish:
runs-on: ubuntu-latest
needs:
- lint
- test
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
with:
token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
fetch-depth: 0
persist-credentials: false

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v3.2.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 }}
SEMANTIC_RELEASE_PACKAGE: ${{ github.event.repository.name }}
with:
semantic_version: 19
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
conventional-changelog-conventionalcommits
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Docker Meta
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v3
with:
images: |
hirosystems/${{ github.event.repository.name }}
Expand All @@ -124,16 +145,16 @@ jobs:
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@v2
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build/Tag/Push Image
uses: docker/build-push-action@v3
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/main' || steps.semantic.outputs.new_release_version != '') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
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) }}
16 changes: 16 additions & 0 deletions .github/workflows/new-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Add issues to API project

on:
issues:
types:
- opened

jobs:
add-to-project:
name: Add issue to project
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@main
with:
project-url: https://github.com/orgs/hirosystems/projects/11
github-token: ${{ secrets.GH_TOKEN }}
71 changes: 71 additions & 0 deletions .github/workflows/vercel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Vercel

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

on:
push:
branches:
- develop
- beta
pull_request:

jobs:
vercel:
runs-on: ubuntu-latest

env:
VERCEL_ENV: ${{ github.ref_name == 'master' && 'production' || 'preview' }}
VERCEL_PROD: ${{ github.ref_name == 'master' && '--prod' || '' }}

environment:
name: ${{ github.ref_name == 'master' && 'Production' || 'Preview' }}
url: ${{ github.ref_name == 'master' && 'https://ordinals-api.vercel.app/' || 'https://ordinals-api-pbcblockstack-blockstack.vercel.app/' }}

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- 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 ci --audit=false

- name: Install Vercel CLI
run: npm install --global vercel@latest

- name: Pull Vercel environment information
run: vercel pull --yes --environment=${{ env.VERCEL_ENV }} --token=${{ secrets.VERCEL_TOKEN }}

- name: Build project artifacts
run: vercel build ${{ env.VERCEL_PROD }} --token=${{ secrets.VERCEL_TOKEN }}

- name: Deploy project artifacts to Vercel
id: deploy
run: vercel deploy ${{ env.VERCEL_PROD }} --prebuilt --token=${{ secrets.VERCEL_TOKEN }} | awk '{print "deployment_url="$1}' >> $GITHUB_OUTPUT

- name: Add comment with Vercel deployment URL
if: ${{ github.event_name == 'pull_request' }}
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: vercel
message: |
Vercel deployment URL: ${{ steps.deploy.outputs.deployment_url }} :rocket:
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ dist/**/*
# ignore yarn.lock
yarn.lock
.vercel
.git-info
13 changes: 0 additions & 13 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
{
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"main",
{
"name": "beta",
"prerelease": true
},
{
"name": "alpha",
"prerelease": true
}
],
"plugins": [
[
"@semantic-release/commit-analyzer",
Expand All @@ -24,7 +12,6 @@
"preset": "conventionalcommits"
}
],
"@semantic-release/npm",
"@semantic-release/github",
"@semantic-release/changelog",
"@semantic-release/git"
Expand Down
50 changes: 49 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,48 @@
"env": {
"NODE_ENV": "development",
"TS_NODE_SKIP_IGNORE": "true"
}
},
"killBehavior": "polite",
},
{
"type": "node",
"request": "launch",
"name": "Run: readonly",
"runtimeArgs": [
"-r",
"ts-node/register"
],
"args": [
"${workspaceFolder}/src/index.ts"
],
"outputCapture": "std",
"internalConsoleOptions": "openOnSessionStart",
"env": {
"NODE_ENV": "development",
"TS_NODE_SKIP_IGNORE": "true",
"RUN_MODE": "readonly"
},
"killBehavior": "polite",
},
{
"type": "node",
"request": "launch",
"name": "Run: writeonly",
"runtimeArgs": [
"-r",
"ts-node/register"
],
"args": [
"${workspaceFolder}/src/index.ts"
],
"outputCapture": "std",
"internalConsoleOptions": "openOnSessionStart",
"env": {
"NODE_ENV": "development",
"TS_NODE_SKIP_IGNORE": "true",
"RUN_MODE": "writeonly"
},
"killBehavior": "polite",
},
{
"type": "node",
Expand All @@ -31,6 +72,13 @@
],
"outputCapture": "std",
"console": "integratedTerminal",
"preLaunchTask": "npm: testenv:run",
"postDebugTask": "npm: testenv:stop",
"env": {
"PGHOST": "localhost",
"PGUSER": "postgres",
"PGPASSWORD": "postgres",
},
},
]
}
37 changes: 37 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "npm: testenv:run",
"type": "shell",
"command": "npm run testenv:run -- -d",
"isBackground": true,
"problemMatcher": {
"pattern": {
"regexp": ".",
"file": 1,
"location": 2,
"message": 3
},
"background": {
"activeOnStart": true,
"beginsPattern": ".",
"endsPattern": "."
}
}
},
{
"label": "npm: testenv:stop",
"type": "shell",
"command": "npm run testenv:stop",
"presentation": {
"echo": true,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
}
]
}
Loading

0 comments on commit f3152e3

Please sign in to comment.