Skip to content

Commit

Permalink
Merge branch 'main' into 910-add-aria
Browse files Browse the repository at this point in the history
  • Loading branch information
goastler authored Jun 11, 2024
2 parents cccc306 + 9e9f222 commit d0522a0
Show file tree
Hide file tree
Showing 102 changed files with 3,763 additions and 2,926 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
**/ProcaptchaWidget-*.js
**/index-*.js
**/typechain/*
**/detector/src/index.js
.yarn
node_modules
**/node_modules**/
Expand Down
137 changes: 137 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: cypress

on:
pull_request:
branches: [main]
paths:
- 'docker/**'
- 'packages/**'
- 'demos/**'
- 'dev/**'
- 'contracts/**'
- '.github/workflows/tests.yml'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
GH_TOKEN: ${{ github.token }}
NODE_ENV: test

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Print contexts
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
ENV_CONTEXT: ${{ toJson(env) }}
VARS_CONTEXT: ${{ toJson(vars) }}
JOB_CONTEXT: ${{ toJson(job) }}
STEPS_CONTEXT: ${{ toJson(steps) }}
RUNNER_CONTEXT: ${{ toJson(runner) }}
SECRETS_CONTEXT: ${{ toJson(secrets) }}
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
MATRIX_CONTEXT: ${{ toJson(matrix) }}
NEEDS_CONTEXT: ${{ toJson(needs) }}
INPUTS_CONTEXT: ${{ toJson(inputs) }}
run: |
echo "******************************"
echo "github:" "$GITHUB_CONTEXT"
echo "******************************"
echo "env:" "$ENV_CONTEXT"
echo "******************************"
echo "vars:" "$VARS_CONTEXT"
echo "******************************"
echo "job:" "$JOB_CONTEXT"
echo "******************************"
echo "steps:" "$STEPS_CONTEXT"
echo "******************************"
echo "runner:" "$RUNNER_CONTEXT"
echo "******************************"
echo "secrets:" "$SECRETS_CONTEXT"
echo "******************************"
echo "strategy:" "$STRATEGY_CONTEXT"
echo "******************************"
echo "matrix:" "$MATRIX_CONTEXT"
echo "******************************"
echo "needs:" "$NEEDS_CONTEXT"
echo "******************************"
echo "inputs:" "$INPUTS_CONTEXT"
echo "******************************"
- uses: actions/checkout@v3

- run: mkdir -p protocol/cargo-cache
- run: mkdir -p protocol/target
- run: mkdir -p node_modules
- run: mkdir -p ~/.cache/Cypress

- name: Restore cache
uses: actions/cache/restore@v3
with:
path: |
protocol/cargo-cache
protocol/target
node_modules
~/.cache/Cypress
# note that restoring a cache in github is a pain. The trailing '-' matches any string after the '-', therefore 'abc-' would match a cache named 'abc-1234' or 'abc-5678', etc.
# the problem is 'abc-' will not match a cache named 'abc'! So if you're using wildcard cache name selectors like this, you need a field that changes as the suffix to become the wildcard
# here we're setting the key to an unused cache key so it falls back to the wildcard selector in `restore-keys`
key: some-unused-cache-key
restore-keys: |
project-cache-${{ runner.os }}-${{ runner.arch }}-
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- run: npm i -g npm@$(cat package.json | jq -r .engines.npm)

- run: npm ci

# build all packages in workspace
- run: npm run build:all

- name: Setup env
run: |
cp demos/client-example-server/env.development demos/client-example-server/.env.test
cp demos/client-example/env.development demos/client-example/.env.test
cp dev/scripts/env.test .env.test
cp dev/scripts/env.test dev/scripts/.env.test
cp dev/scripts/env.test packages/cli/.env.test
cp dev/scripts/env.test packages/procaptcha-bundle/.env.test
echo NODE_ENV: $NODE_ENV
- name: Start the docker images
run: |
docker compose --file ./docker/docker-compose.test.yml up -d
docker container ls
sleep 10s
# deploy dapp + protocol and run setup to register, stake and load a dataset for a provider
- run: NODE_ENV=test npm run deploy_protocol
- run: NODE_ENV=test npm run setup

# Build a test version of the procaptcha bundle and run the cypress tests on it and on the React client-example
# Running bundle:dev instead of bundle:prod means the bundle will be built with selectors that can be used
# by the cypress tests to find the elements they need to interact with
- run: NODE_ENV=test npm -w @prosopo/procaptcha-bundle run bundle:dev

# Needs concurrently to avoid vite hanging forever https://github.com/vitejs/vite/discussions/8745
- name: Install concurrently and cypress
run: npm i concurrently cypress

- name: Run the cypress tests on client-example
run: |
npx concurrently "npm run start:server" "npm run start:provider" "npm run start:demo" "sleep 10s && npm -w @prosopo/cypress-shared run cypress:run:client-example" --success "first" --kill-others
- name: Run the cypress tests on client-bundle-example
run: |
npx concurrently "npm run start:server" "npm run start:provider" "npm run start:bundle" "sleep 10s && npm -w @prosopo/cypress-shared run cypress:run:client-bundle-example" --success "first" --kill-others
- name: Run the cypress tests on client-bundle-example explicit rendering
run: |
npx concurrently "npm run start:server" "npm run start:provider" "npm run start:bundle" "sleep 10s && npm -w @prosopo/cypress-shared run cypress:run:client-bundle-example:explicit" --success "first" --kill-others
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ jobs:
docker run -d -p 3080:80 prosopo/js_server:${{ steps.next_version.outputs.version }}
# Start the bundle demo & run the cypress tests against the new bundle
npx concurrently "npm run start:bundle" "npm run -w @prosopo/cypress-shared cypress:run:client-bundle-example:js_server" --success "first" --kill-others
# npx concurrently "npm run start:bundle" "npm run -w @prosopo/cypress-shared cypress:run:client-bundle-example:js_server" --success "first" --kill-others
- name: Github release
continue-on-error: true
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,36 +115,3 @@ jobs:
# deploy protocol and run the unit tests
- run: npm run deploy_protocol
- run: npm run test

# restart the docker images to drop any changes made by the unit tests to the contract(s) before running cypress tests
- name: Reset the docker containers
run: |
docker compose --file ./docker/docker-compose.test.yml down
docker compose --file ./docker/docker-compose.test.yml up -d
docker container ls
sleep 10s
# deploy dapp + protocol and run setup to register, stake and load a dataset for a provider
- run: NODE_ENV=test npm run deploy_protocol
- run: NODE_ENV=test npm run setup

# Build a test version of the procaptcha bundle and run the cypress tests on it and on the React client-example
# Running bundle:dev instead of bundle:prod means the bundle will be built with selectors that can be used
# by the cypress tests to find the elements they need to interact with
- run: NODE_ENV=test npm -w @prosopo/procaptcha-bundle run bundle:dev

# Needs concurrently to avoid vite hanging forever https://github.com/vitejs/vite/discussions/8745
- name: Install concurrently and cypress
run: npm i concurrently cypress

- name: Run the cypress tests on client-example
run: |
npx concurrently "npm run start:server" "npm run start:provider" "npm run start:demo" "sleep 10s && npm -w @prosopo/cypress-shared run cypress:run:client-example" --success "first" --kill-others
- name: Run the cypress tests on client-bundle-example
run: |
npx concurrently "npm run start:server" "npm run start:provider" "npm run start:bundle" "sleep 10s && npm -w @prosopo/cypress-shared run cypress:run:client-bundle-example" --success "first" --kill-others
- name: Run the cypress tests on client-bundle-example explicit rendering
run: |
npx concurrently "npm run start:server" "npm run start:provider" "npm run start:bundle" "sleep 10s && npm -w @prosopo/cypress-shared run cypress:run:client-bundle-example:explicit" --success "first" --kill-others
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,6 @@ js_bundles_host_temp
**/client-bundle-example/src/assets/**

.csv

# ignore captcha
captcha.json
2 changes: 1 addition & 1 deletion contracts/captcha/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prosopo/captcha-contract",
"version": "0.3.42",
"version": "1.0.1",
"description": "The captcha contract",
"main": "dist/index.js",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions contracts/captcha/src/captcha.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"source": {
"hash": "0x67e7a9faf4442f403d5eabea884fa75e0be1b0152ba892ddd5e3cd8f5bd14f61",
"hash": "0xcc59363fa4cd47a1a3116bd7c29b77bf0198f53c008c4359cd7568c5f015e6cd",
"language": "ink! 4.3.0",
"compiler": "rustc 1.69.0",
"build_info": {
Expand All @@ -15,7 +15,7 @@
},
"contract": {
"name": "captcha",
"version": "0.3.42",
"version": "1.0.1",
"authors": [
"Chris Taylor <chris@prosopo.io>",
"George Oastler <george@prosopo.io>",
Expand Down
4 changes: 2 additions & 2 deletions contracts/captcha/src/contract-info/captcha.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prosopo/common-contract",
"version": "0.3.42",
"version": "1.0.1",
"description": "The common contract",
"main": "dist/index.js",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions contracts/common/src/common.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"source": {
"hash": "0xf8ec20e744b845fc7a7436f4746d7a489000f3da2ac1ce4751857f6fd709a4e6",
"hash": "0x6f5c1914b86e7ad67eb116f384483c16255fa3341991a41cbc7f27ee2d4cb5b0",
"language": "ink! 4.3.0",
"compiler": "rustc 1.69.0",
"build_info": {
Expand All @@ -15,7 +15,7 @@
},
"contract": {
"name": "common",
"version": "0.3.42",
"version": "1.0.1",
"authors": [
"Chris Taylor <chris@prosopo.io>",
"George Oastler <george@prosopo.io>",
Expand Down
4 changes: 2 additions & 2 deletions contracts/common/src/contract-info/common.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/proxy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prosopo/proxy-contract",
"version": "0.3.42",
"version": "1.0.1",
"description": "The proxy contract",
"main": "dist/index.js",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions contracts/proxy/src/contract-info/proxy.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions contracts/proxy/src/proxy.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"source": {
"hash": "0x176e47429a04839221e85ec343033bf108e94889d95a0f4c711ec1bb1dcdb6ab",
"hash": "0x507ca88c583dd09644cf489a1abf314e6506234a5d53d18776994e4eb7129025",
"language": "ink! 4.3.0",
"compiler": "rustc 1.69.0",
"build_info": {
Expand All @@ -15,7 +15,7 @@
},
"contract": {
"name": "proxy",
"version": "0.3.42",
"version": "1.0.1",
"authors": ["Chris Taylor <chris@prosopo.io>", "George Oastler <george@prosopo.io>"]
},
"spec": {
Expand Down
2 changes: 1 addition & 1 deletion demos/client-bundle-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"dotenv": "^16.0.1",
"vite": "^5.1.7"
},
"version": "0.3.42",
"version": "1.0.1",
"devDependencies": {
"tslib": "2.6.2",
"typescript": "5.1.6"
Expand Down
4 changes: 2 additions & 2 deletions demos/client-example-server/env.development
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ PROSOPO_SUBSTRATE_ENDPOINT=ws://localhost:9944
PROSOPO_CONTRACT_ADDRESS=
PROSOPO_WEB2=true
PROSOPO_SERVER_URL=https://localhost
PROSOPO_SITE_PRIVATE_KEY=//Bob
PROSOPO_SITE_PRIVATE_KEY=//Eve
PROSOPO_SERVER_PORT=9228
PROSOPO_DEFAULT_ENVIRONMENT=development
PROSOPO_DEFAULT_NETWORK=development
PROSOPO_MONGO_EVENTS_URI=mongodb+srv://<MONGO_URI_HERE>/frictionless_events
_DEV_ONLY_WATCH_EVENTS=false
_DEV_ONLY_WATCH_EVENTS=false
14 changes: 7 additions & 7 deletions demos/client-example-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prosopo/client-example-server",
"version": "0.3.42",
"version": "1.0.1",
"description": "Backend for client-example",
"main": "dist/app.js",
"type": "module",
Expand Down Expand Up @@ -38,11 +38,11 @@
"@noble/hashes": "^1.3.1",
"@polkadot/util": "12.6.2",
"@polkadot/util-crypto": "12.6.2",
"@prosopo/api": "0.3.42",
"@prosopo/contract": "0.3.42",
"@prosopo/procaptcha": "0.3.42",
"@prosopo/server": "0.3.42",
"@prosopo/types": "0.3.42",
"@prosopo/api": "1.0.1",
"@prosopo/contract": "1.0.1",
"@prosopo/procaptcha": "1.0.1",
"@prosopo/server": "1.0.1",
"@prosopo/types": "1.0.1",
"@typegoose/auto-increment": "3.3.0",
"cors": "^2.8.5",
"jsonwebtoken": "^9.0.0",
Expand All @@ -55,6 +55,6 @@
"tslib": "2.6.2",
"typescript": "5.1.6",
"vite": "^5.1.7",
"@prosopo/config": "0.3.42"
"@prosopo/config": "1.0.1"
}
}
7 changes: 2 additions & 5 deletions demos/client-example-server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { ProsopoEnvError, getLoggerDefault } from '@prosopo/common'
import { ProsopoServer, getServerConfig } from '@prosopo/server'
import { getPairAsync } from '@prosopo/contract'
import { getServerConfig } from '@prosopo/server'
import connectionFactory from './utils/connection.js'
import cors from 'cors'
import dotenv from 'dotenv'
Expand Down Expand Up @@ -82,10 +81,8 @@ async function main() {
const config = getServerConfig()

console.log('config', config)
const pair = await getPairAsync(config.networks[config.defaultNetwork], process.env.PROSOPO_SITE_PRIVATE_KEY)
const prosopoServer = new ProsopoServer(config, pair)

app.use(routesFactory(mongoose, prosopoServer, verifyEndpoint, verifyType))
app.use(routesFactory(mongoose, config, verifyEndpoint, verifyType))

app.listen(process.env.PROSOPO_SERVER_PORT)
}
Expand Down
Loading

0 comments on commit d0522a0

Please sign in to comment.