-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make procaptcha return a token * Package lock * Update packages and demos to accept new token format * Use encode function. Remove unused dep * lint:fix * Remove trailing comma * Return false if token is not hex * Add util to decode procaptcha token * package-lock.json * Add nonce to output type * Split the cypress tests into their own workflow * don't grab the cypress cache for the provider tests * lint:fix * Redo changes * Redo wiped changes * package-lock.json * make secret optional in config * Undo cache changes2 * Fix passing of parameters to verify endpoint * package-lock.json * Fixes for API endpoints * remove logs * bundle NODE_ENV
- Loading branch information
Showing
33 changed files
with
1,272 additions
and
1,058 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.