Skip to content

Commit

Permalink
first commit [no ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
YaroShkvorets committed Nov 9, 2024
1 parent df0cdee commit 488240d
Show file tree
Hide file tree
Showing 110 changed files with 4,919 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# [optional] to query network subgraph for validation
THEGRAPH_STUDIO_KEY=<YOUR_STUDIO_KEY>
25 changes: 25 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
# pull_request:
# types: [opened, synchronize, reopened]
workflow_dispatch:

name: Format on PR

jobs:
format-files:
name: Check JSON formatting
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install dependencies
run: bun install --no-save

- name: Check formatting
run: bun format:check
124 changes: 124 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
on:
push:
branches:
- main
workflow_dispatch:

name: Validate, generate and publish registry

jobs:
upload-registry:
name: Upload to Cloudflare Pages
runs-on: ubuntu-latest
permissions:
contents: 'write'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install dependencies
run: bun install --no-save

- name: Validate schema
run: bun validate:schema

- name: Generate registry types
run: bun generate:types

- name: Validate logic
run: |
if [ -z "${{ env.THEGRAPH_STUDIO_KEY }}" ]; then
echo "Error: secrets.THEGRAPH_STUDIO_KEY is not set - can't validate networks"
exit 1
fi
bun validate:networks
- name: Generate registry
run: bun generate:public

- name: Format
run: bun format

- name: Get version
id: get_version
run: |
VERSION=$(jq -r '.version' package.json)
echo "REGISTRY_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Check if tag exists
id: check_tag
run: |
if git fetch --tags && git tag -l | grep -q "v${{ env.REGISTRY_VERSION }}"; then
echo "Error: Registry v${{ env.REGISTRY_VERSION }} already exists. Bump up the version in package.json to publish"
exit 1
fi
- name: Publish
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy public --project-name=graphregistry

- name: Get commit log
run: |
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"- %s (@%an) [%h](https://github.com/$GITHUB_REPOSITORY/commit/%H)" --no-merges)
else
CHANGELOG=$(git log --pretty=format:"- %s (@%an) [%h](https://github.com/$GITHUB_REPOSITORY/commit/%H)" --no-merges ${PREV_TAG}..HEAD)
fi
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
echo "$CHANGELOG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Commit and Push Changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "generate registry v${{ env.REGISTRY_VERSION }} [no ci]" || echo "No changes to commit"
git push
- name: Create tag
run: |
git tag "v${{ env.REGISTRY_VERSION }}"
git push origin "v${{ env.REGISTRY_VERSION }}"
IFS='.' read -r MAJOR MINOR PATCH <<< "${{ env.REGISTRY_VERSION }}"
echo "MAJOR=$MAJOR" >> $GITHUB_ENV
echo "MINOR=$MINOR" >> $GITHUB_ENV
echo "PATCH=$PATCH" >> $GITHUB_ENV
- name: Create GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ env.REGISTRY_VERSION }}"
release_name: "v${{ env.REGISTRY_VERSION }}"
body: |
### Networks Registry v${{ env.REGISTRY_VERSION }}
- ${{ env.REGISTRY_ROOT_URL }}/TheGraphNetworksRegistry.json
- ${{ env.REGISTRY_ROOT_URL }}/TheGraphNetworksRegistry_v${{ env.MAJOR }}_x_x.json
- ${{ env.REGISTRY_ROOT_URL }}/TheGraphNetworksRegistry_v${{ env.MAJOR }}_${{ env.MINOR }}_x.json
- ${{ env.REGISTRY_ROOT_URL }}/TheGraphNetworksRegistry_v${{ env.MAJOR }}_${{ env.MINOR }}_${{ env.PATCH }}.json
### Schema v${{ env.MAJOR }}.${{ env.MINOR }}
- ${{ env.REGISTRY_ROOT_URL }}/TheGraphNetworksRegistrySchema_v${{ env.MAJOR }}_${{ env.MINOR }}.json
### Changes
${{ env.CHANGELOG }}
env:
THEGRAPH_STUDIO_KEY: ${{ secrets.THEGRAPH_STUDIO_KEY }}
REGISTRY_ROOT_URL: "https://graphregistry.pages.dev"
38 changes: 38 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:

name: Validate on PR

jobs:
validate-json:
name: Validate JSON files
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install dependencies
run: bun install --no-save

- name: Validate schema
run: bun validate:schema

- name: Validate logic
run: bun validate:networks

- name: Generate registry types
run: bun generate:types

- name: Generate registry
run: bun generate:registry

- name: Validate resulting registry against the schema
run: bun validate:registry

32 changes: 32 additions & 0 deletions .github/workflows/validate_urls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
# pull_request:
# types: [opened, synchronize, reopened]
workflow_dispatch:

name: Validate URLs

jobs:
validate-urls:
name: Validate URLs
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install dependencies
run: bun install --no-save

- name: Validate schema
run: bun validate:schema

- name: Validate logic
run: bun validate:networks

- name: Validate URLs
run: bun validate:urls

29 changes: 29 additions & 0 deletions .github/workflows/version_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:

name: Check version on PR

jobs:
validate-json:
name: Check version
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Get version
id: get_version
run: |
VERSION=$(jq -r '.version' package.json)
echo "REGISTRY_VERSION=v${VERSION}" >> $GITHUB_ENV
- name: Check if tag exists
id: check_tag
run: |
TAG="${{ env.REGISTRY_VERSION }}"
if git fetch --tags && git tag -l | grep -q "$TAG"; then
echo "Error: Registry $TAG already exists. Bump up the version in package.json to publish"
exit 1
fi
132 changes: 132 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

.DS_Store

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
5 changes: 5 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
plugins: [
require.resolve("./src/prettier/plugin-no-trailing-slash.cjs"),
],
};
Loading

0 comments on commit 488240d

Please sign in to comment.