From d0eae3c22eea6bc84dba2f18d1b1b68d309e0da5 Mon Sep 17 00:00:00 2001 From: trizin <25263018+trizin@users.noreply.github.com> Date: Fri, 4 Aug 2023 11:30:10 +0300 Subject: [PATCH 01/10] Add pytest workflow --- .github/workflows/pytest.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/pytest.yml diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 000000000..dac9ba39a --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,35 @@ +## +## Copyright 2023 Ocean Protocol Foundation +## SPDX-License-Identifier: Apache-2.0 +## +name: pdr-backend tests + +on: + - pull_request + push: + branches: [main] + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Setup repository + uses: actions/checkout@v3 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: '3.8' + - name: Install dependencies + working-directory: ${{ github.workspace }} + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest + - name: Test with pytest + id: pytest + run: | + coverage run --omit="*test*" -m pytest + coverage report \ No newline at end of file From 84bc28f8279b3433078bee7811b3f1b19e803b03 Mon Sep 17 00:00:00 2001 From: trizin <25263018+trizin@users.noreply.github.com> Date: Fri, 4 Aug 2023 11:31:53 +0300 Subject: [PATCH 02/10] Fix --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index dac9ba39a..766228d83 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -5,7 +5,7 @@ name: pdr-backend tests on: - - pull_request + pull_request: push: branches: [main] From 084af7f668c2d3f1485ec50476adc0b3732293d8 Mon Sep 17 00:00:00 2001 From: trizin <25263018+trizin@users.noreply.github.com> Date: Fri, 4 Aug 2023 11:32:15 +0300 Subject: [PATCH 03/10] Fix --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 766228d83..cbef3d26d 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -13,7 +13,7 @@ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: - build: + test: runs-on: ubuntu-latest steps: - name: Setup repository From 74a5fd6e6d5a891a169ca4ac2c836df142cfb09b Mon Sep 17 00:00:00 2001 From: trizin <25263018+trizin@users.noreply.github.com> Date: Fri, 4 Aug 2023 08:43:50 +0000 Subject: [PATCH 04/10] Fix imports --- pdr_backend/dfbuyer/main.py | 2 +- pdr_backend/predictoor/main.py | 2 +- pdr_backend/trueval/main.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pdr_backend/dfbuyer/main.py b/pdr_backend/dfbuyer/main.py index 60045f90d..bf8bdfb39 100644 --- a/pdr_backend/dfbuyer/main.py +++ b/pdr_backend/dfbuyer/main.py @@ -5,7 +5,7 @@ from pdr_backend.dfbuyer.utils.subgraph import get_consume_so_far from pdr_backend.utils.subgraph import get_all_interesting_prediction_contracts -from pdr_backend.utils.contract import PredictorContract, Web3Config +from pdr_backend.utils.contract import PredictoorContract, Web3Config from pdr_backend.utils import env rpc_url = env.get_rpc_url_or_exit() subgraph_url = env.get_subgraph_or_exit() diff --git a/pdr_backend/predictoor/main.py b/pdr_backend/predictoor/main.py index 6dcab2cf0..8c653bf14 100644 --- a/pdr_backend/predictoor/main.py +++ b/pdr_backend/predictoor/main.py @@ -8,7 +8,7 @@ from pdr_backend.predictoor.predict import predict_function from pdr_backend.utils.subgraph import get_all_interesting_prediction_contracts -from pdr_backend.utils.contract import PredictorContract, Web3Config +from pdr_backend.utils.contract import PredictoorContract, Web3Config from pdr_backend.utils import env diff --git a/pdr_backend/trueval/main.py b/pdr_backend/trueval/main.py index ab9d283fa..cc5ebdd39 100644 --- a/pdr_backend/trueval/main.py +++ b/pdr_backend/trueval/main.py @@ -4,7 +4,7 @@ from pdr_backend.trueval.trueval import get_true_val from pdr_backend.utils.subgraph import get_all_interesting_prediction_contracts -from pdr_backend.utils.contract import PredictorContract, Web3Config +from pdr_backend.utils.contract import PredictoorContract, Web3Config from pdr_backend.utils import env From afb5b1a75118fd280d879e4b157da23ef6b42e8e Mon Sep 17 00:00:00 2001 From: trizin <25263018+trizin@users.noreply.github.com> Date: Fri, 4 Aug 2023 08:47:04 +0000 Subject: [PATCH 05/10] Add env vars --- .github/workflows/pytest.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index cbef3d26d..960e2a736 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -30,6 +30,11 @@ jobs: pip install pytest - name: Test with pytest id: pytest + env: + ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json" + RPC_URL=http://127.0.0.1:8545 + SUBGRAPH_URL="http://172.15.0.15:8000/subgraphs/name/oceanprotocol/ocean-subgraph" + PRIVATE_KEY="0xef4b441145c1d0f3b4bc6d61d29f5c6e502359481152f869247c7a4244d45209" run: | coverage run --omit="*test*" -m pytest coverage report \ No newline at end of file From b8467d29ba9b8eb17930388d0a8ae0e44ab9e196 Mon Sep 17 00:00:00 2001 From: trizin <25263018+trizin@users.noreply.github.com> Date: Fri, 4 Aug 2023 11:51:17 +0300 Subject: [PATCH 06/10] Fix --- .github/workflows/pytest.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 960e2a736..9db8ba4e5 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -31,10 +31,10 @@ jobs: - name: Test with pytest id: pytest env: - ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json" - RPC_URL=http://127.0.0.1:8545 - SUBGRAPH_URL="http://172.15.0.15:8000/subgraphs/name/oceanprotocol/ocean-subgraph" - PRIVATE_KEY="0xef4b441145c1d0f3b4bc6d61d29f5c6e502359481152f869247c7a4244d45209" + ADDRESS_FILE: ${{env.HOME}}/.ocean/ocean-contracts/artifacts/address.json + RPC_URL: http://127.0.0.1:8545 + SUBGRAPH_URL: http://172.15.0.15:8000/subgraphs/name/oceanprotocol/ocean-subgraph + PRIVATE_KEY: 0xef4b441145c1d0f3b4bc6d61d29f5c6e502359481152f869247c7a4244d45209 run: | coverage run --omit="*test*" -m pytest coverage report \ No newline at end of file From 2f7165d6ca7e1f8a600b5ebca5347e1c6aa85294 Mon Sep 17 00:00:00 2001 From: trizin <25263018+trizin@users.noreply.github.com> Date: Fri, 4 Aug 2023 11:54:29 +0300 Subject: [PATCH 07/10] Test --- .github/workflows/pytest.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 9db8ba4e5..5b2f75618 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -31,7 +31,6 @@ jobs: - name: Test with pytest id: pytest env: - ADDRESS_FILE: ${{env.HOME}}/.ocean/ocean-contracts/artifacts/address.json RPC_URL: http://127.0.0.1:8545 SUBGRAPH_URL: http://172.15.0.15:8000/subgraphs/name/oceanprotocol/ocean-subgraph PRIVATE_KEY: 0xef4b441145c1d0f3b4bc6d61d29f5c6e502359481152f869247c7a4244d45209 From a446ff999beb10be8947a7954f189230a63aef39 Mon Sep 17 00:00:00 2001 From: trizin <25263018+trizin@users.noreply.github.com> Date: Fri, 4 Aug 2023 11:55:36 +0300 Subject: [PATCH 08/10] Test --- .github/workflows/pytest.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 5b2f75618..cbef3d26d 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -30,10 +30,6 @@ jobs: pip install pytest - name: Test with pytest id: pytest - env: - RPC_URL: http://127.0.0.1:8545 - SUBGRAPH_URL: http://172.15.0.15:8000/subgraphs/name/oceanprotocol/ocean-subgraph - PRIVATE_KEY: 0xef4b441145c1d0f3b4bc6d61d29f5c6e502359481152f869247c7a4244d45209 run: | coverage run --omit="*test*" -m pytest coverage report \ No newline at end of file From 3e83378ada1805fcfd739f84d4debeaf560f74b2 Mon Sep 17 00:00:00 2001 From: trizin <25263018+trizin@users.noreply.github.com> Date: Fri, 4 Aug 2023 11:58:57 +0300 Subject: [PATCH 09/10] Add env vars back --- .github/workflows/pytest.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index cbef3d26d..9db8ba4e5 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -30,6 +30,11 @@ jobs: pip install pytest - name: Test with pytest id: pytest + env: + ADDRESS_FILE: ${{env.HOME}}/.ocean/ocean-contracts/artifacts/address.json + RPC_URL: http://127.0.0.1:8545 + SUBGRAPH_URL: http://172.15.0.15:8000/subgraphs/name/oceanprotocol/ocean-subgraph + PRIVATE_KEY: 0xef4b441145c1d0f3b4bc6d61d29f5c6e502359481152f869247c7a4244d45209 run: | coverage run --omit="*test*" -m pytest coverage report \ No newline at end of file From 9f4ff3bf1ea718c1d44aaa81f430c97521cefa34 Mon Sep 17 00:00:00 2001 From: trizin <25263018+trizin@users.noreply.github.com> Date: Fri, 4 Aug 2023 12:01:06 +0300 Subject: [PATCH 10/10] Fix --- .github/workflows/pytest.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 9db8ba4e5..5b9cab7fb 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -27,14 +27,14 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - pip install pytest + pip install pytest - name: Test with pytest id: pytest env: - ADDRESS_FILE: ${{env.HOME}}/.ocean/ocean-contracts/artifacts/address.json - RPC_URL: http://127.0.0.1:8545 - SUBGRAPH_URL: http://172.15.0.15:8000/subgraphs/name/oceanprotocol/ocean-subgraph - PRIVATE_KEY: 0xef4b441145c1d0f3b4bc6d61d29f5c6e502359481152f869247c7a4244d45209 + ADDRESS_FILE: "${{env.HOME}}/.ocean/ocean-contracts/artifacts/address.json" + RPC_URL: "http://127.0.0.1:8545" + SUBGRAPH_URL: "http://172.15.0.15:8000/subgraphs/name/oceanprotocol/ocean-subgraph" + PRIVATE_KEY: "0xef4b441145c1d0f3b4bc6d61d29f5c6e502359481152f869247c7a4244d45209" run: | coverage run --omit="*test*" -m pytest coverage report \ No newline at end of file