diff --git a/.github/workflows/integration-tests-V2.yml b/.github/workflows/integration-tests-V2.yml index 29c03112..0c092b8e 100644 --- a/.github/workflows/integration-tests-V2.yml +++ b/.github/workflows/integration-tests-V2.yml @@ -23,22 +23,43 @@ jobs: with: repository: Railgun-Privacy/contract path: contract + - name: Enable Corepack + run: corepack enable - name: Yarn in engine - uses: borales/actions-yarn@v4 - with: - cmd: install - dir: 'engine' + working-directory: ./engine + run: yarn install --frozen-lockfile - name: Yarn in contract - uses: borales/actions-yarn@v4 - with: - cmd: install - dir: 'contract' + working-directory: ./contract + run: yarn install --frozen-lockfile - name: Build contract - run: cd contract && npm run compile - - name: Run contract hardhat and engine tests - uses: BerniWittmann/background-server-action@v1 - with: - command: cd contract && npm run deploy && cd ../engine && yarn test-hardhat-V2 - start: cd contract && npm run node >/dev/null - wait-on: 'http://localhost:8545' - wait-on-timeout: 120 \ No newline at end of file + working-directory: ./contract + run: npm run compile + - name: Start Hardhat node (background) + working-directory: ./contract + run: | + npm run node > "$GITHUB_WORKSPACE/hardhat.log" 2>&1 & + echo $! > "$GITHUB_WORKSPACE/hardhat.pid" + for i in {1..120}; do + if curl -s -o /dev/null -X POST -H "Content-Type: application/json" \ + --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' \ + http://localhost:8545; then + echo "Hardhat node ready" + exit 0 + fi + sleep 1 + done + echo "Hardhat node did not become ready in 120s" + cat "$GITHUB_WORKSPACE/hardhat.log" + exit 1 + - name: Deploy contracts + working-directory: ./contract + run: npm run deploy + - name: Run engine tests + working-directory: ./engine + run: yarn test-hardhat-V2 + - name: Stop Hardhat node + if: always() + run: | + if [ -f "$GITHUB_WORKSPACE/hardhat.pid" ]; then + kill "$(cat "$GITHUB_WORKSPACE/hardhat.pid")" 2>/dev/null || true + fi diff --git a/.github/workflows/integration-tests-V3.yml b/.github/workflows/integration-tests-V3.yml index aff8c905..08c15691 100644 --- a/.github/workflows/integration-tests-V3.yml +++ b/.github/workflows/integration-tests-V3.yml @@ -24,22 +24,43 @@ jobs: with: repository: Railgun-Privacy/contract path: contract + - name: Enable Corepack + run: corepack enable - name: Yarn in engine - uses: borales/actions-yarn@v4 - with: - cmd: install - dir: 'engine' + working-directory: ./engine + run: yarn install --frozen-lockfile - name: Yarn in contract - uses: borales/actions-yarn@v4 - with: - cmd: install - dir: 'contract' + working-directory: ./contract + run: yarn install --frozen-lockfile - name: Build contract - run: cd contract && ./node_modules/.bin/hardhat compile - - name: Run contract hardhat and engine tests - uses: BerniWittmann/background-server-action@v1 - with: - command: cd engine && yarn test-hardhat - start: cd contract && npx hardhat node >/dev/null, cd contract && sleep 5 && npx hardhat deploy:test --network localhost >/dev/null - wait-on: 'http://localhost:8545' - wait-on-timeout: 120 + working-directory: ./contract + run: ./node_modules/.bin/hardhat compile + - name: Start Hardhat node (background) + working-directory: ./contract + run: | + npx hardhat node > "$GITHUB_WORKSPACE/hardhat.log" 2>&1 & + echo $! > "$GITHUB_WORKSPACE/hardhat.pid" + for i in {1..120}; do + if curl -s -o /dev/null -X POST -H "Content-Type: application/json" \ + --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' \ + http://localhost:8545; then + echo "Hardhat node ready" + exit 0 + fi + sleep 1 + done + echo "Hardhat node did not become ready in 120s" + cat "$GITHUB_WORKSPACE/hardhat.log" + exit 1 + - name: Deploy test contracts + working-directory: ./contract + run: npx hardhat deploy:test --network localhost + - name: Run engine tests + working-directory: ./engine + run: yarn test-hardhat + - name: Stop Hardhat node + if: always() + run: | + if [ -f "$GITHUB_WORKSPACE/hardhat.pid" ]; then + kill "$(cat "$GITHUB_WORKSPACE/hardhat.pid")" 2>/dev/null || true + fi diff --git a/.github/workflows/publish-npmjs.yml b/.github/workflows/publish-npmjs.yml index 038679c6..25712b8a 100644 --- a/.github/workflows/publish-npmjs.yml +++ b/.github/workflows/publish-npmjs.yml @@ -20,8 +20,7 @@ jobs: with: node-version: '24' registry-url: 'https://registry.npmjs.org' - - name: Install yarn - uses: borales/actions-yarn@v4 - with: - cmd: install + cache: 'yarn' + - run: corepack enable + - run: yarn install --frozen-lockfile - run: npm publish diff --git a/.github/workflows/unit-tests-V2.yml b/.github/workflows/unit-tests-V2.yml index 6c45bd86..c9932bf3 100644 --- a/.github/workflows/unit-tests-V2.yml +++ b/.github/workflows/unit-tests-V2.yml @@ -16,10 +16,8 @@ jobs: with: node-version: '18' cache: 'yarn' - - name: Install yarn - uses: borales/actions-yarn@v4 - with: - cmd: install + - run: corepack enable + - run: yarn install --frozen-lockfile - name: Yarn test shell: bash run: yarn test-V2 diff --git a/.github/workflows/unit-tests-V3.yml b/.github/workflows/unit-tests-V3.yml index f44b69ca..b7dbbd8b 100644 --- a/.github/workflows/unit-tests-V3.yml +++ b/.github/workflows/unit-tests-V3.yml @@ -16,10 +16,8 @@ jobs: with: node-version: '18' cache: 'yarn' - - name: Install yarn - uses: borales/actions-yarn@v4 - with: - cmd: install + - run: corepack enable + - run: yarn install --frozen-lockfile - name: Yarn test shell: bash run: yarn test