Prepare for next version of node/ocean.js #618
This file contains hidden or 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
| name: Test Flow | |
| on: | |
| pull_request: | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v2 | |
| with: | |
| node-version: "22.23.1" | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Run build | |
| run: npm run build | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v2 | |
| with: | |
| node-version: "22.23.1" | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Run lint | |
| run: npm run lint | |
| pack_smoke: | |
| # Guards the global-install contract without needing a full Ocean stack: | |
| # a broken bin, cwd-dependent module loading, or env-gated --help/--version | |
| # would all fail here. Also asserts the publish tarball excludes sources. | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22.23.1" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Pack tarball | |
| run: | | |
| TARBALL=$(npm pack | tail -1) | |
| echo "TARBALL=$TARBALL" >> $GITHUB_ENV | |
| echo "Packed $TARBALL" | |
| - name: Assert tarball contents (dist/metadata/README in; src/test out) | |
| run: | | |
| FILES=$(tar -tzf "$TARBALL") | |
| echo "$FILES" | |
| echo "$FILES" | grep -q '^package/dist/index.js$' || { echo "MISSING dist/index.js"; exit 1; } | |
| echo "$FILES" | grep -q '^package/README.md$' || { echo "MISSING README.md"; exit 1; } | |
| echo "$FILES" | grep -q '^package/metadata/' || { echo "MISSING metadata/"; exit 1; } | |
| if echo "$FILES" | grep -qE '^package/(src|test)/'; then | |
| echo "Tarball must not ship src/ or test/"; exit 1 | |
| fi | |
| - name: Install globally from tarball | |
| run: npm i -g "./$TARBALL" | |
| - name: Run bin from a foreign cwd with NO env vars | |
| working-directory: ${{ runner.temp }} | |
| run: | | |
| ocean-cli --version | |
| ocean-cli --help > /dev/null | |
| ocean-cli -h > /dev/null | |
| ocean-cli -V > /dev/null | |
| test_system: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| transport: [http, p2p] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v2 | |
| with: | |
| node-version: "22.23.1" | |
| - name: Cache node_modules | |
| uses: actions/cache@v3 | |
| env: | |
| cache-name: cache-node-modules | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-test-${{ matrix.transport }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: ${{ runner.os }}-test-${{ matrix.transport }}-${{ env.cache-name }}- | |
| - name: Set ADDRESS_FILE | |
| run: echo "ADDRESS_FILE=${HOME}/.ocean/ocean-contracts/artifacts/address.json" >> $GITHUB_ENV | |
| - name: Checkout Barge | |
| uses: actions/checkout@v3 | |
| with: | |
| repository: 'oceanprotocol/barge' | |
| path: 'barge' | |
| ref: "feature/node-v4" | |
| - name: Login to Docker Hub | |
| if: ${{ env.DOCKERHUB_PASSWORD && env.DOCKERHUB_USERNAME }} | |
| run: | | |
| echo "Login to Docker Hub" | |
| echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin | |
| env: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| - name: Run Barge | |
| working-directory: ${{ github.workspace }}/barge | |
| run: | | |
| bash -x start_ocean.sh --with-typesense 2>&1 > start_ocean.log & | |
| env: | |
| CONTRACTS_VERSION: '2.9.0' | |
| NODE_VERSION: "pr-1408" | |
| - run: npm ci | |
| - run: npm run build | |
| - run: docker image ls | |
| - name: Wait for node to be ready | |
| run: | | |
| max_attempts=60 | |
| attempt=1 | |
| echo "Waiting for node container to be ready (timeout: 300s)..." | |
| while [ $attempt -le $max_attempts ]; do | |
| if [ "$(docker inspect -f '{{.State.Running}}' ocean-node-1 2>/dev/null)" = "true" ]; then | |
| echo "Node container is running!" | |
| break | |
| fi | |
| echo "Attempt $attempt/$max_attempts: Node container not ready yet, waiting..." | |
| if [ $attempt -eq $max_attempts ]; then | |
| echo "Error: Node container failed to start within 300 seconds" | |
| docker ps -a | |
| docker inspect ocean-node-1 | |
| exit 1 | |
| fi | |
| sleep 10 | |
| attempt=$((attempt + 1)) | |
| done | |
| - name: Set NODE_URL for HTTP | |
| if: matrix.transport == 'http' | |
| run: echo "NODE_URL=http://127.0.0.1:8001" >> $GITHUB_ENV | |
| - name: Set NODE_URL for P2P | |
| if: matrix.transport == 'p2p' | |
| run: | | |
| max_attempts=30 | |
| attempt=1 | |
| echo "Waiting for node HTTP API to be ready..." | |
| while [ $attempt -le $max_attempts ]; do | |
| PEER_ID=$(curl -s http://127.0.0.1:8001 | jq -r '.nodeId // empty' 2>/dev/null) | |
| if [ -n "$PEER_ID" ]; then | |
| echo "Got peer ID: $PEER_ID" | |
| echo "NODE_URL=${PEER_ID}" >> $GITHUB_ENV | |
| break | |
| fi | |
| echo "Attempt $attempt/$max_attempts: Node API not ready yet..." | |
| if [ $attempt -eq $max_attempts ]; then | |
| echo "Error: Could not get node peer ID" | |
| exit 1 | |
| fi | |
| sleep 5 | |
| attempt=$((attempt + 1)) | |
| done | |
| - name: docker logs | |
| run: docker logs ocean_ocean-contracts_1 && docker logs ocean_typesense_1 | |
| if: ${{ failure() }} | |
| - name: Run system tests (${{ matrix.transport }}) | |
| run: npm run test:system | |
| env: | |
| INDEXING_RETRY_INTERVAL: 4000 | |
| INDEXING_MAX_RETRIES: 120 | |
| AVOID_LOOP_RUN: true | |
| - name: Print Ocean Node Logs if tests fail | |
| if: ${{ failure() }} | |
| run: | | |
| echo "========== Ocean Node Logs ==========" | |
| docker logs --tail 1000 ocean-node-1 2>&1 | tac || echo "Ocean Node container logs not available" |