Skip to content

Commit

Permalink
feat: monorepo with gateway (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Apr 6, 2022
1 parent 9f5b984 commit 3b8bd4f
Show file tree
Hide file tree
Showing 59 changed files with 8,632 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
@@ -0,0 +1,2 @@
[*]
end_of_line = lf
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
* text=auto eol=lf
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,7 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'kind/bug,need/triage'
assignees: ''
---
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Need Help?
url: https://discord.com/invite/KKucsCpZmY
about: Chat with us in \#nft-storage on IPFS discord.
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,7 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: 'kind/enhancement,need/triage'
assignees: ''
---
17 changes: 17 additions & 0 deletions .github/workflows/conventional-commits.yml
@@ -0,0 +1,17 @@
name: 'Check Conventional Commits'

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 changes: 30 additions & 0 deletions .github/workflows/cron-denylist.yml
@@ -0,0 +1,30 @@
name: Cron sync deny list

on:
schedule:
- cron: '13 0,5,10,15,20 * * *'
workflow_dispatch:
push:
branches:
- main
paths:
- 'packages/edge-gateway/denylist.json'

jobs:
update:
name: Sync deny list with KV store
runs-on: ubuntu-latest
strategy:
matrix:
env: ['staging', 'production']
timeout-minutes: 20
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- uses: bahmutov/npm-install@v1
- name: Run job
env:
CF_API_TOKEN: ${{ secrets.CF_GATEWAY_TOKEN }}
run: node packages/edge-gateway/scripts/cli.js denylist sync --env ${{ matrix.env }}
83 changes: 83 additions & 0 deletions .github/workflows/edge-gateway.yml
@@ -0,0 +1,83 @@
name: edge-gateway
on:
push:
branches:
- main
paths:
- 'packages/edge-gateway/**'
- '.github/workflows/edge-gateway.yml'
pull_request:
paths:
- 'packages/edge-gateway/**'
- '.github/workflows/edge-gateway.yml'
jobs:
test:
runs-on: ubuntu-latest
name: Test
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- uses: bahmutov/npm-install@v1
- run: npx playwright install-deps
- run: yarn test:edge-gateway
deploy-staging:
name: Deploy Staging
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- uses: bahmutov/npm-install@v1
- name: Publish app
# FIXME: uses Node.js 16 not 12 (upcoming release).
# FIXME: update to tag > 1.3.0 when released.
uses: cloudflare/wrangler-action@6f62debcf8abf8e33e41343df9d7ab49612c324d
env:
ENV: 'staging' # inform the build process what the env is
SENTRY_TOKEN: ${{secrets.SENTRY_TOKEN}}
SENTRY_UPLOAD: ${{ secrets.SENTRY_UPLOAD }}
with:
apiToken: ${{secrets.CF_GATEWAY_TOKEN }}
workingDirectory: 'packages/edge-gateway'
environment: 'staging'
release:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
name: Release
runs-on: ubuntu-latest
needs: test
steps:
- uses: GoogleCloudPlatform/release-please-action@v3
id: tag-release
with:
path: packages/edge-gateway
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
monorepo-tags: true
package-name: edge-gateway
- uses: actions/checkout@v2
if: ${{ steps.tag-release.outputs.releases_created }}
- uses: actions/setup-node@v2
if: ${{ steps.tag-release.outputs.releases_created }}
with:
node-version: '16'
registry-url: https://registry.npmjs.org/
- uses: bahmutov/npm-install@v1
if: ${{ steps.tag-release.outputs.releases_created }}
- name: Deploy
if: ${{ steps.tag-release.outputs.releases_created }}
# FIXME: uses Node.js 16 not 12 (upcoming release).
# FIXME: update to tag > 1.3.0 when released.
uses: cloudflare/wrangler-action@6f62debcf8abf8e33e41343df9d7ab49612c324d
env:
ENV: 'production' # inform the build process what the env is
SENTRY_TOKEN: ${{ secrets.SENTRY_TOKEN }}
SENTRY_UPLOAD: ${{ secrets.SENTRY_UPLOAD }}
with:
apiToken: ${{ secrets.CF_GATEWAY_TOKEN }}
workingDirectory: 'packages/edge-gateway'
environment: 'production'
45 changes: 45 additions & 0 deletions .gitignore
@@ -0,0 +1,45 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules

# testing
coverage
.nyc_output

# next.js
.next
out

# production
build

# misc
.DS_Store

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local
.production.env
.env

dist
node_modules
worker
package-lock.json
site/public
.cluster
*.http
.local
.supabase

packages/website/public/robots.txt
packages/website/public/sitemap.xml
packages/api/docker/compose
25 changes: 25 additions & 0 deletions .prettierignore
@@ -0,0 +1,25 @@
node_modules
coverage
out
build
dist
worker
site/public
docs
*.sql
*.sh
*.svg
*.png
CHANGELOG.md
.next
.supabase
.prettierignore
.gitignore
.editorconfig
.gitattributes
**/yarn.lock*
*.toml
packages/client/src/lib/interface.ts
*.mdx
packages/website/public/robots.txt
packages/website/public/sitemap.xml
55 changes: 55 additions & 0 deletions DEVELOPMENT.md
@@ -0,0 +1,55 @@
# nftstorage.link Developer's Guide

This doc should contain everything you need to know to get a working development environment up and running. If it doesn't and you know what's missing, please open a PR or issue to update the guide!

## Pre-requisites

You'll need at least the following:

- Node.js v16+
- [yarn](https://yarnpkg.com/)
- Docker

## Getting Started

We use `yarn` in this project and commit the `yarn.lock` file.

1. Install dependencies.
```bash
# install all dependencies in the mono-repo
yarn
# setup git hooks
npx simple-git-hooks
```
2. Run locally by starting the following processes.
1. API server (`yarn dev` in `/packages/edge-gateway`).
2. Web server (`yarn dev` in `/packages/website`).

## Release

[Release Please](https://github.com/googleapis/release-please) automates CHANGELOG generation, the creation of GitHub releases,
and version bumps for our packages. Release Please does so by parsing your
git history, looking for [Conventional Commit messages](https://www.conventionalcommits.org/),
and creating release PRs.

### What's a Release PR?

Rather than continuously releasing what's landed to our default branch, release-please maintains Release PRs:

These Release PRs are kept up-to-date as additional work is merged. When we're ready to tag a release, we simply merge the release PR.

When the release PR is merged the release job is triggered to create a new tag, a new github release and run other package specific jobs. Only merge ONE release PR at a time and wait for CI to finish before merging another.

Release PRs are created individually for each package in the mono repo.

### How should I write my commits?

Release Please assumes you are using [Conventional Commit messages](https://www.conventionalcommits.org/).

The most important prefixes you should have in mind are:

- `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/)
patch.
- `feat:` which represents a new feature, and correlates to a SemVer minor.
- `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change
(indicated by the `!`) and will result in a SemVer major.

0 comments on commit 3b8bd4f

Please sign in to comment.