codex-storage / codex-marketplace-ui

Codex marketplace UI allowing buy and sell operations in the Codex decentralized storage network
https://app.codex.storage
Apache License 2.0
0 stars 0 forks source link

Create automated testing for the main features #34

Closed 2-towns closed 1 month ago

2-towns commented 1 month ago

I am gonna to use Playwright.

cc @veaceslavdoina

veaceslavdoina commented 1 month ago

Setting up GitHub Actions

2-towns commented 1 month ago

Setting up GitHub Actions

I would need to run a local client node and then return the playwright tests. Can you indicate me how to do it ? Maybe there is a docker image to see ? @veaceslavdoina

veaceslavdoina commented 1 month ago

We can probably can do it locally first and then automate using GitHub Actions.

Looking at the workflow on the Setting up GitHub Actions, we have these steps

    - name: Install dependencies
      run: npm ci

    - name: Install Playwright Browsers
      run: npx playwright install --with-deps

    - name: Run Playwright tests
      run: npx playwright test

And locally it would be like following (and we can also define a command in package.json ?)

npm ci
npx playwright install --with-deps
npx playwright test

Now, we should probably prepare the tests?

  1. Create a test folder
  2. Prepare the tests
  3. Any additional configuration files for that (playwright.config.ts) ?

We can probably check https://github.com/microsoft/playwright-examples repository for some examples.

After tests are ready, we can prepare a workflow and run it on PR, Push and other events.

veaceslavdoina commented 1 month ago

Aha, and your main question was slightly different :)

We have a guide how to run Codex using Docker and as you are planing to interact with marketplace we would need

@benbierens is already doing that part inside the docker and we can check options he is using.

As for GitHub Actions, will check how to run a step using container - jobs..container.

2-towns commented 1 month ago

After tests are ready, we can prepare a workflow and run it on PR, Push and other events.

Okay so I pushed the tests on the branch feat/tests/test-init

I even have the Github Workflow

name: Playwright Tests
on:
  push:
    branches: [ main, master ]
  pull_request:
    branches: [ main, master ]
jobs:
  test:
    timeout-minutes: 60
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-node@v4
      with:
        node-version: lts/*
    - name: Install dependencies
      run: npm ci
    - name: Install Playwright Browsers
      run: npx playwright install --with-deps
    - name: Run Playwright tests
      run: npx playwright test
    - uses: actions/upload-artifact@v4
      if: ${{ !cancelled() }}
      with:
        name: playwright-report
        path: playwright-report/
        retention-days: 30

But now I need to start a client node to run those tests

2-towns commented 1 month ago

As for GitHub Actions, will check how to run a step using container - jobs..container.

Okay great I will check that tomorrow morning because I think it's gonna to take me some times to setup

veaceslavdoina commented 1 month ago

Just did a check of the simple workflow were we install and run Codex from GitHub releases. But next step it would be required to look how to run Codex with marketplace support.

By the way, are you planing to use a real network like Testnet or just a local node?

playwright-tests.yaml ```yaml name: Playwright Tests on: push: branches: [ main, master ] pull_request: branches: [ main, master ] workflow_dispatch: env: codex_version: v0.1.6 jobs: tests: timeout-minutes: 60 runs-on: ubuntu-latest steps: - name: Run Codex node run: | # Download version=${{ env.codex_version }} platform=$(echo `uname -s` | awk '{print tolower($0)}') architecture=$([[ `uname -m` == 'x86_64' ]] && echo amd64 || echo arm64) curl -LO https://github.com/codex-storage/nim-codex/releases/download/${version}/codex-${version}-${platform}-${architecture}.tar.gz curl -LO https://github.com/codex-storage/nim-codex/releases/download/${version}/codex-${version}-${platform}-${architecture}.tar.gz.sha256 sha256sum -c codex-${version}-${platform}-${architecture}.tar.gz.sha256 [[ $? -eq 0 ]] && { echo "Checksum is OK"; } || { echo "Checksum failed"; exit 1; } tar -zxvf codex-${version}-${platform}-${architecture}.tar.gz sudo apt update && sudo apt install libgomp1 # Run ./codex-${version}-${platform}-${architecture} & - name: Check Codex API run: | curl --max-time 5 --fail localhost:8080/api/codex/v1/debug/info -w "\n" [[ $? -eq 0 ]] && { echo "Codex node is up"; } || { echo "Please check Codex node"; exit 1; } - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: lts/* - name: Install dependencies if: false run: npm ci - name: Install Playwright Browsers if: false run: npx playwright install --with-deps - name: Run Playwright tests if: false run: npx playwright test - uses: actions/upload-artifact@v4 if: false # if: ${{ !cancelled() }} with: name: playwright-report path: playwright-report/ retention-days: 30 ```

Image

2-towns commented 1 month ago

Just did a check of the simple workflow were we install and run Codex from GitHub releases. But next step it would be required to look how to run Codex with marketplace support.

Ok thank you @veaceslavdoina I will work on that

By the way, are you planing to use a real network like Testnet or just a local node?

I planned to use a local node

2-towns commented 1 month ago

@veaceslavdoina We have now a beautiful Github Actions setup running the e2e tests on Testnet.

Thanks for your help !

veaceslavdoina commented 1 month ago

Hey Arnaud, looks good - thank you!