Refactor node packages to yarn workspaces & ditch next.js for CRA. (#161)

* chore: restructure project into yarn workspaces, remove next

* fix tests, remove webapp from terraform

* remove more ui deployment bits

* remove pages, fix FUNDING.yml

* remove isomorphism

* remove next providers

* fix linting issues

* feat: start basis of new web ui system on CRA

* chore: move types to @roleypoly/types package

* chore: move src/common/utils to @roleypoly/misc-utils

* chore: remove roleypoly/ path remappers

* chore: renmove vercel config

* chore: re-add worker-types to api package

* chore: fix type linting scope for api

* fix(web): craco should include all of packages dir

* fix(ci): change api webpack path for wrangler

* chore: remove GAR actions from CI

* chore: update codeql job

* chore: test better github dar matcher in lint-staged
This commit is contained in:
41666 2021-03-12 18:04:49 -05:00 committed by GitHub
parent 49e308507e
commit 2ff6588030
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
328 changed files with 16624 additions and 3525 deletions

2
.github/FUNDING.yml vendored
View file

@ -1,7 +1,7 @@
# These are supported funding model platforms
github: kayteh
patreon: kata
patreon: roleypoly
open_collective: # Replace with a single Open Collective username
ko_fi: roleypoly
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel

View file

@ -98,7 +98,7 @@ jobs:
- run: |
wrangler init
echo 'webpack_config = "src/backend-worker/webpack.config.js"' | tee -a wrangler.toml
echo 'webpack_config = "packages/api/webpack.config.js"' | tee -a wrangler.toml
wrangler build
if: steps.check.outputs.skip == '0'
@ -119,7 +119,6 @@ jobs:
strategy:
matrix:
dockerfile:
- ui
- bot
steps:
- uses: actions/checkout@master
@ -182,12 +181,6 @@ jobs:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Get UI digest
uses: actions/download-artifact@v2
with:
name: ui-digest
path: .digests/ui
- name: Get Bot digest
uses: actions/download-artifact@v2
with:
@ -197,7 +190,7 @@ jobs:
- name: Set digests as addressable
id: digests
env:
IMAGES: ui bot
IMAGES: bot
run: |
set_digest_output() {
echo ::set-output name=$1::@$(cat .digests/$1/digest.txt)

View file

@ -1,24 +1,25 @@
name: 'CodeQL'
name: 'Code Scanning - Action'
on:
push:
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
schedule:
- cron: '23 22 * * 4'
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '30 1 * * 0'
jobs:
analyze:
name: Analyze
CodeQL-Build:
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: ['go', 'javascript']
steps:
- name: Checkout repository
uses: actions/checkout@v2
@ -26,24 +27,21 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below).
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following
# three lines and modify them (or add more) to build your code if your
# project uses a compiled language
#- run: |
# make bootstrap

View file

@ -7,10 +7,6 @@ on:
description: 'One of: stage, prod'
required: true
default: stage
ui_tag:
description: 'tag/digest reference to a UI container build'
required: false
default: ':main'
bot_tag:
description: 'tag/digest reference to a UI container build'
required: false
@ -21,115 +17,9 @@ on:
default: '' # Empty will try using current main branch hash
jobs:
docker_sync:
name: Docker Sync
runs-on: ubuntu-latest
outputs:
ui_tag: ${{ steps.tags.outputs.ui_tag }}
steps:
- uses: actions/checkout@master
- uses: docker/setup-buildx-action@v1
id: buildx
with:
install: true
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GCS_PROJECT_ID }}
service_account_key: ${{ secrets.GCS_TF_KEY }}
export_default_credentials: true
- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: roleypoly
password: ${{ secrets.GHCR_PAT }}
- name: Login to GAR US
uses: docker/login-action@v1
with:
registry: us-docker.pkg.dev
username: _json_key
password: ${{ secrets.GAR_JSON_KEY }}
- name: Login to GAR Europe
uses: docker/login-action@v1
with:
registry: europe-docker.pkg.dev
username: _json_key
password: ${{ secrets.GAR_JSON_KEY }}
- name: Login to GAR Asia
uses: docker/login-action@v1
with:
registry: asia-docker.pkg.dev
username: _json_key
password: ${{ secrets.GAR_JSON_KEY }}
- name: Retag
id: tags
run: |
retag_push() {
docker tag $1 $2
docker push $2
}
get_digest() {
# Finds the digest for any GAR-pushed artifact
docker inspect $1 --format='{{json .RepoDigests}}' | jq -r '[.[] | match("docker.pkg.*(sha256:.*)"; "g")] | .[0] | .captures | .[0] | .string'
}
UI_IMAGE_SRC=ghcr.io/roleypoly/ui${{github.event.inputs.ui_tag}}
UI_IMAGE_DEST_BASE=docker.pkg.dev/roleypoly/roleypoly/ui:${{github.event.inputs.environment}}
docker pull $UI_IMAGE_SRC
retag_push $UI_IMAGE_SRC us-$UI_IMAGE_DEST_BASE
retag_push $UI_IMAGE_SRC europe-$UI_IMAGE_DEST_BASE
retag_push $UI_IMAGE_SRC asia-$UI_IMAGE_DEST_BASE
echo ::set-output name=ui_tag::@$(get_digest $UI_IMAGE_SRC)
deploy_metadata:
name: Make Deployment Metadata
runs-on: ubuntu-latest
outputs:
url: ${{steps.metadata.outputs.url}}
env: ${{steps.metadata.outputs.env}}
steps:
- name: Create deployment metadata
id: metadata
run: |
ENV_URL=
ENV_NAME=
if [[ "${{github.event.inputs.environment}}" == "prod" ]]; then
ENV_URL="https://next.roleypoly.com"
ENV_NAME=Production
elif [[ "${{github.event.inputs.environment}}" == "stage" ]]; then
ENV_URL="https://stage.roleypoly.com"
ENV_NAME=Staging
else
ENV_URL="https://web-${{github.event.inputs.environment}}.roleypoly.com"
ENV_NAME=Preview-${{github.event.inputs.environment}}
fi
echo "url=$ENV_URL"
echo "env=$ENV_NAME"
echo ::set-output name=url::$ENV_URL
echo ::set-output name=env::$ENV_NAME
deploy_terraform:
name: Deploy Terraform
runs-on: ubuntu-latest
needs:
- docker_sync
- deploy_metadata
environment:
name: ${{ needs.deploy_metadata.outputs.env }}
url: ${{ needs.deploy_metadata.outputs.url }}
steps:
- uses: actions/checkout@master
@ -170,7 +60,7 @@ jobs:
working-directory: ./terraform
run: |
echo \
'{"ui_tag": "${{needs.docker_sync.outputs.ui_tag}}", "bot_tag": "${{github.event.inputs.bot_tag}}", "api_path_to_worker": "./worker-dist/backend-worker.js"}' \
'{"bot_tag": "${{github.event.inputs.bot_tag}}", "api_path_to_worker": "./worker-dist/backend-worker.js"}' \
| jq . \
| tee tags.auto.tfvars.json
@ -199,9 +89,8 @@ jobs:
DATA='{
"embeds": [
{
"title": "Roleypoly ${{ needs.deploy_metadata.outputs.env }} Deployment Success",
"description": "Roleypoly was successfully deployed to ${{ needs.deploy_metadata.outputs.env }} at '$(date)'",
"url": "${{ needs.deploy_metadata.outputs.url }}",
"title": "Roleypoly Deployment Success",
"description": "Roleypoly was successfully deployed at '$(date)'",
"color": 4634182,
"author": {
"name": "Deployment Notification",
@ -222,9 +111,8 @@ jobs:
DATA='{
"embeds": [
{
"title": "Roleypoly ${{ needs.deploy_metadata.outputs.env }} Deployment Failed",
"description": "Roleypoly failed to be deployed to ${{ needs.deploy_metadata.outputs.env }} at '$(date)'",
"url": "${{ needs.deploy_metadata.outputs.url }}",
"title": "Roleypoly Deployment Failed",
"description": "Roleypoly failed to be deployed at '$(date)'",
"color": 15291219,
"author": {
"name": "Deployment Notification",

View file

@ -1,45 +0,0 @@
name: GAR Cleanup
on:
schedule:
- cron: '30 6 * * *'
workflow_dispatch: {}
workflow_run:
workflows: ['Deploy']
types:
- completed
jobs:
docker_cleanup:
name: Cleanup Deployed Images
runs-on: ubuntu-latest
strategy:
matrix:
region: [us, europe, asia]
fail-fast: false
steps:
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GCS_PROJECT_ID }}
service_account_key: ${{ secrets.GCS_TF_KEY }}
export_default_credentials: true
- name: Delete stale artifacts
run: |
flags="--format=json --location=${{matrix.region}} --repository=roleypoly"
packagesToPrune=$(gcloud artifacts packages list $flags | jq -r '.[].name')
for package in $packagesToPrune; do
tagsToKeep=$(gcloud artifacts tags list --package=$package $flags | jq -r '.[].version')
versionsToCheck=$(gcloud artifacts versions list --package=$package $flags | jq -r '.[].name')
for version in $versionsToCheck; do
if [[ "$tagsToKeep" =~ .*"$version".* ]]; then
continue
fi
gcloud artifacts versions delete $version --package=$package $flags --quiet
done
done