big overhaul (#474)

* miniflare init

* feat(api): add tests

* chore: more tests, almost 100%

* add sessions/state spec

* add majority of routes and datapaths, start on interactions

* nevermind, no interactions

* nevermind x2, tweetnacl is bad but SubtleCrypto has what we need apparently

* simplify interactions verify

* add brute force interactions tests

* every primary path API route is refactored!

* automatically import from legacy, or die trying.

* check that we only fetch legacy once, ever

* remove old-src, same some historic pieces

* remove interactions & worker-utils package, update misc/types

* update some packages we don't need specific pinning for anymore

* update web references to API routes since they all changed

* fix all linting issues, upgrade most packages

* fix tests, divorce enzyme where-ever possible

* update web, fix integration issues

* pre-build api

* fix tests

* move api pretest to api package.json instead of CI

* remove interactions from terraform, fix deploy side configs

* update to tf 1.1.4

* prevent double writes to worker in GCS, port to newer GCP auth workflow

* fix api.tf var refs, upgrade node action

* change to curl-based script upload for worker script due to terraform provider limitations

* oh no, cloudflare freaked out :(
This commit is contained in:
41666 2022-01-31 20:35:22 -05:00 committed by GitHub
parent b644a38aa7
commit 3291f9aacc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
183 changed files with 9853 additions and 9924 deletions

View file

@ -11,21 +11,10 @@ jobs:
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v2.1.5
- uses: actions/setup-node@v2.5.1
with:
node-version: '16'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2.1.6
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
cache: yarn
- run: yarn install --frozen-lockfile
@ -42,62 +31,45 @@ jobs:
matrix:
worker:
- api
- interactions
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v2.1.5
- uses: actions/setup-node@v2.5.1
with:
node-version: '16'
cache: yarn
- id: 'auth'
uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{ secrets.GCS_TF_KEY }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@master
uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{ secrets.GCS_PROJECT_ID }}
service_account_key: ${{ secrets.GCS_TF_KEY }}
export_default_credentials: true
- name: Check if already deployed
id: check
run: |
gsutil stat gs://roleypoly-artifacts/workers/${{ github.sha }}/${{ matrix.worker }}.js \
gsutil stat gs://roleypoly-artifacts/workers/${{ github.sha }}/index.mjs \
&& echo ::set-output name=skip::1 \
|| echo ::set-output name=skip::0
- run: npm i -g @cloudflare/wrangler
if: steps.check.outputs.skip == '0'
- name: Get yarn cache directory path
if: steps.check.outputs.skip == '0'
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2.1.6
if: steps.check.outputs.skip == '0'
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install --frozen-lockfile
if: steps.check.outputs.skip == '0'
- run: |
wrangler init
echo 'webpack_config = "packages/${{ matrix.worker }}/webpack.config.js"' | tee -a wrangler.toml
wrangler build
mv worker/script.js worker/${{ matrix.worker }}.js
yarn build:api
if: steps.check.outputs.skip == '0'
- id: upload-file
if: github.event_name == 'push' && steps.check.outputs.skip == '0'
uses: google-github-actions/upload-cloud-storage@main
with:
path: worker/${{ matrix.worker }}.js
path: packages/api/dist/index.mjs
destination: roleypoly-artifacts/workers/${{ github.sha }}
credentials: ${{ secrets.GCS_TF_KEY }}
docker_build:
name: Docker Build & Publish
@ -166,7 +138,7 @@ jobs:
needs:
- docker_build
- worker_build
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/miniflare'
runs-on: ubuntu-latest
steps:
- name: Get Bot digest

View file

@ -25,10 +25,10 @@ jobs:
- uses: hashicorp/setup-terraform@v1.3.2
with:
terraform_version: ^1.0.1
terraform_version: ^1.1.4
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@master
uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{ secrets.GCS_PROJECT_ID }}
service_account_key: ${{ secrets.GCS_TF_KEY }}
@ -60,7 +60,7 @@ jobs:
working-directory: ./terraform
run: |
echo \
'{"bot_tag": "${{github.event.inputs.bot_tag}}", "worker_tag": "${{github.event.inputs.worker_tag}}", "api_path_to_worker": "./worker-dist/api.js", "interactions_path_to_worker": "./worker-dist/interactions.js"}' \
'{"bot_tag": "${{github.event.inputs.bot_tag}}", "worker_tag": "${{github.event.inputs.worker_tag}}", "path_to_worker": "./worker-dist/index.mjs"}' \
| jq . \
| tee tags.auto.tfvars.json