Skip to content

Commit

Permalink
Merge branch 'main' into fix-prosoponator-disapprove
Browse files Browse the repository at this point in the history
  • Loading branch information
goastler authored Jun 11, 2024
2 parents 61347ac + ee067b9 commit 4772d83
Show file tree
Hide file tree
Showing 184 changed files with 7,582 additions and 9,984 deletions.
6 changes: 6 additions & 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 Expand Up @@ -42,3 +43,8 @@ diagram.svg
.env.*
**/assets/*.js
*.min.js
**/Readme.md
**/README.md
code-of-conduct.md
diagram.svg
**/.eslintignore
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
11 changes: 9 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ jobs:

- run: npm ci

- run: npm run build -w @prosopo/scripts
- run: npm run -w @prosopo/scripts build

- run: npm run lint
- name: lint
run: |
# get the files which have changed in the PR
files=$(curl -L -s -H "Authorization: Bearer ${{ github.token }}" -H "Accept: application/vnd.github.v3+json" "${{ github.event.pull_request.url }}/files" | jq -r '.[] | .filename')
echo "files: $files"
npm run lint:cmd -- $files
28 changes: 13 additions & 15 deletions .github/workflows/post_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,19 @@ jobs:
- run: ls -la protocol/target/ink || true
- run: ls -la node_modules || true

# remove all but the latest cache (this ensures there's at least one cache available for the next run, just in case this takes place while we're clearing up caches)
# this means there will be the previous cache (the latest) and the current cache (the one we're building now) after this workflow finishes
# github actions will prefer the latest cache, so the one output from this workflow will take precedence in future jobs
# save cache to main branch. Any branch can use this cache afterwards to speed up their build
- name: Save cache
uses: actions/cache/save@v3
if: always()
with:
path: |
protocol/cargo-cache
protocol/target
node_modules
~/.cache/Cypress
key: project-cache-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }}

# remove all but the latest cache, leaving only the cache we just saved
- name: Cleanup caches
if: always()
run: |
Expand All @@ -124,15 +134,3 @@ jobs:
do
gh actions-cache delete $cacheKey -R $REPO --confirm
done
# save cache to main branch. Any branch can use this cache afterwards to speed up their build
- name: Save cache
uses: actions/cache/save@v3
if: always()
with:
path: |
protocol/cargo-cache
protocol/target
node_modules
~/.cache/Cypress
key: project-cache-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }}
7 changes: 6 additions & 1 deletion .github/workflows/prosoponator_bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ jobs:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- run: npm i -g npm@$(cat package.json | jq -r .engines.npm)

- name: Run
env:
GITHUB_TOKEN: ${{ secrets.PROSOPONATOR_PAT }}
run: |
cd dev/prosoponator-bot
npm ci
cd dev/prosoponator-bot
npx tsx src/bot.ts
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 .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v20
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.40",
"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": "0xc2c334c53598f33bf8a597813825eafced8cc8d86429f98937679fa275e5a777",
"hash": "0x6a967c0e4f4c6bc1f26b8ba909eb1e2ea91e66ca78a60f5e74a4a39b7c40f849",
"language": "ink! 4.3.0",
"compiler": "rustc 1.69.0",
"build_info": {
Expand All @@ -15,7 +15,7 @@
},
"contract": {
"name": "captcha",
"version": "0.3.40",
"version": "1.0.1",
"authors": [
"Chris Taylor <[email protected]>",
"George Oastler <[email protected]>",
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.40",
"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": "0x7f6db3a9551bcf3248429bba0d2497cd373f46653e21fb8d632133277589d352",
"hash": "0xe789318be8bb8d251d79be1403aa4c0aa64d4f4f268561c76bf19b1849dcd919",
"language": "ink! 4.3.0",
"compiler": "rustc 1.69.0",
"build_info": {
Expand All @@ -15,7 +15,7 @@
},
"contract": {
"name": "common",
"version": "0.3.40",
"version": "1.0.1",
"authors": [
"Chris Taylor <[email protected]>",
"George Oastler <[email protected]>",
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.40",
"version": "1.0.1",
"description": "The proxy contract",
"main": "dist/index.js",
"type": "module",
Expand Down
Loading

0 comments on commit 4772d83

Please sign in to comment.