Skip to content

Remove ofLen from @prosopo/util #5593

Remove ofLen from @prosopo/util

Remove ofLen from @prosopo/util #5593

# Build and publish the provider image
name: provider_image
on:
pull_request:
branches: [main, dev, staging, release/*]
types:
- opened # when a PR is opened
- synchronize # when a PR is pushed to
- reopened # when a PR is reopened
- ready_for_review # when a PR is marked as ready for review (e.g. taken off draft mode)
workflow_dispatch:
permissions:
contents: read
pull-requests: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
GITHUB_TOKEN: ${{ secrets.PROSOPONATOR_PAT }}
GH_TOKEN: ${{ secrets.PROSOPONATOR_PAT }}
CARGO_TERM_COLOR: always
NODE_OPTIONS: "--max-old-space-size=4096"
NODE_ENV: "test"
defaults:
run:
shell: bash
jobs:
check:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- name: Print contexts
uses: prosopo/captcha/.github/actions/print_contexts@gha
with:
INPUTS_CONTEXT: ${{ toJson(inputs) }}
NEEDS_CONTEXT: ${{ toJson(needs) }}
VARS_CONTEXT: ${{ toJson(vars) }}
SECRETS_CONTEXT: ${{ toJson(secrets) }}
- name: Set NX_PARALLEL environment variable
run: echo "NX_PARALLEL=$(nproc)" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: prosopo/captcha/.github/actions/npm@gha
with:
npm_ci_args: '--include=dev'
- uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'
- name: env
run: |
# Copy the .env.production from the dev script to the cli folder and root folder
cp ./dev/scripts/env.production ./packages/cli/.env.production
cp ./dev/scripts/env.production ./.env.production
# Append the development PROVIDER_MNEMONIC from env.development to the .env.production file
grep -PoIe "PROSOPO_PROVIDER_MNEMONIC.*" ./dev/scripts/env.development >> .env.production
- run: NODE_ENV="production" npx turbo run @prosopo/cli#build
- run: NODE_ENV="production" npx turbo run @prosopo/cli#bundle
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# We cannot create the images in a single step because the output of buildx is not compatible with
# `docker load`. https://stackoverflow.com/a/72952846/1178971
# create the provider image for AMD64
- name: Build the Provider Container
uses: docker/build-push-action@v5
with:
context: ${{github.workspace}}
file: ${{github.workspace}}/docker/images/provider/src/Dockerfile
platforms: linux/amd64
push: false
tags: prosopo/provider:dev
outputs: type=docker,dest=provider-amd64.tar
# load the AMD64 image
- name: Load the Provider Container
run: docker load -i provider-amd64.tar
# Generate a mnemonic for the provider image
- name: Generate mnemonic and add to env file
run: |
PROSOPO_ROOT_DIR=$(pwd) NODE_ENV="production" npx tsx dev/scripts/src/scripts/generateMnemonic.ts --env
# Check that the version command works when running the bundle in the provider image
- name: Check provider bundle runs
run: |
set -euxo pipefail # stop on errors, print commands, fail on pipe fails
# Run container and capture exit code
CONTAINER="$(docker run -d -v "./.env.production:/usr/src/app/.env.production" prosopo/provider:dev /bin/sh -c 'NODE_ENV=production npx provider version')"
# Wait for container to complete
sleep 20s
# Get container exit code
EXIT_CODE="$(docker wait "$CONTAINER" || echo "timeout")"
# Capture logs
docker logs "$CONTAINER" > provider.log 2>&1
cat provider.log
# Check if container exited successfully
if [ "$EXIT_CODE" != "0" ]; then
echo "Container failed with exit code: $EXIT_CODE"
echo "Checking for common errors..."
if grep -q "Could not resolve" provider.log; then
echo "ERROR: Missing dependency detected in bundle"
exit 1
else
echo "ERROR: Container failed for unknown reason"
exit 1
fi
fi
# Verify version output is present
if ! grep -qE "\"version\":\".*\"" provider.log; then
echo "ERROR: Version command did not produce expected output"
exit 1
fi
echo "Provider bundle test passed successfully"