From 3c87900b4814515931efabfb98d4dfab06245c98 Mon Sep 17 00:00:00 2001 From: David Kazlauskas Date: Wed, 2 Oct 2024 08:30:50 +0300 Subject: [PATCH] feat: add PR test for coprocessor --- .github/workflows/coprocessor-test.yml | 37 +++++++++++++++++++ fhevm-engine/coprocessor/Makefile | 4 +- .../coprocessor/docker-compose.test.yml | 15 ++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/coprocessor-test.yml create mode 100644 fhevm-engine/coprocessor/docker-compose.test.yml diff --git a/.github/workflows/coprocessor-test.yml b/.github/workflows/coprocessor-test.yml new file mode 100644 index 00000000..a5bb53f9 --- /dev/null +++ b/.github/workflows/coprocessor-test.yml @@ -0,0 +1,37 @@ +name: Run PR test + +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + coprocessor_test: + permissions: + contents: read + runs-on: "large_ubuntu_32" + if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} + steps: + - name: Check out repo + uses: actions/checkout@v4 + + - name: Install xmllint + run: sudo apt-get install -y protobuf-compiler + + - name: Install sqlx-cli from crates.io + uses: baptiste0928/cargo-install@v3 + with: + crate: sqlx-cli + version: '^0.8' + + - name: Setup database + working-directory: ./fhevm-engine/coprocessor + run: | + make init_db + # build with --release flag for faster tests + cargo build --release + cargo build --tests --release + COPROCESSOR_TEST_LOCAL_DB=true cargo test --release -- --nocapture + diff --git a/fhevm-engine/coprocessor/Makefile b/fhevm-engine/coprocessor/Makefile index 7b1d62fb..abb8790e 100644 --- a/fhevm-engine/coprocessor/Makefile +++ b/fhevm-engine/coprocessor/Makefile @@ -7,11 +7,11 @@ build: .PHONY: cleanup cleanup: - docker compose down -v + docker compose -f docker-compose.test.yml down -v .PHONY: init_db init_db: - docker compose up -d + docker compose -f docker-compose.test.yml up -d sleep 3 $(DB_URL) sqlx db create $(DB_URL) sqlx migrate run diff --git a/fhevm-engine/coprocessor/docker-compose.test.yml b/fhevm-engine/coprocessor/docker-compose.test.yml new file mode 100644 index 00000000..9f51f5dc --- /dev/null +++ b/fhevm-engine/coprocessor/docker-compose.test.yml @@ -0,0 +1,15 @@ +version: '3.8' +services: + db: + image: postgres:15.7 + restart: always + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + ports: + - '5432:5432' + volumes: + - db:/var/lib/postgresql/data +volumes: + db: + driver: local