From c9455ecc68aaccc053bbe4c973634bdfb47f2935 Mon Sep 17 00:00:00 2001 From: ilai Date: Sun, 29 Oct 2023 12:28:31 +0200 Subject: [PATCH 1/2] [CI] Try merge queue This will allow us to merge multiple PRs simulatneusly --- .github/workflows/PR.yml | 103 ++++++++++++++++++ .../workflows/{CI.yml => merege_queue.yml} | 48 +------- 2 files changed, 105 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/PR.yml rename .github/workflows/{CI.yml => merege_queue.yml} (69%) diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml new file mode 100644 index 00000000..181d2b66 --- /dev/null +++ b/.github/workflows/PR.yml @@ -0,0 +1,103 @@ +name: Run unit tests and linters + +on: pull_request + +# Cancel previous runs on the same branch \ PR number if they are still running +# From: https://stackoverflow.com/a/72408109 +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + + +jobs: + run-linters: + name: Run linters + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.9, '3.10', 3.11] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.9 + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: 1.3.2 + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + #---------------------------------------------- + # load cached venv if cache exists + #---------------------------------------------- + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v3 + with: + path: .venv + key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }} + #---------------------------------------------- + # install dependencies if cache does not exist + #---------------------------------------------- + - name: Install dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root --with dev + - name: Install project + run: poetry install --no-interaction + - name: Run flake8 Check + run: poetry run flake8 . + - name: Run mypy check + run: poetry run mypy src + + run-tests: + name: Run tests + runs-on: ubuntu-latest + needs: run-linters + strategy: + matrix: + python-version: [3.9, '3.10', 3.11] + pinecone-plan: ["paid", "starter"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: 1.3.2 + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + #---------------------------------------------- + # load cached venv if cache exists + #---------------------------------------------- + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v3 + with: + path: .venv + key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }} + #---------------------------------------------- + # install dependencies if cache does not exist + #---------------------------------------------- + - name: Install dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root --with dev + - name: Install project + run: poetry install --no-interaction + - name: Run unit tests + run: poetry run pytest --html=report.html --self-contained-html tests/unit + - name: upload pytest report.html + uses: actions/upload-artifact@v3 + if: always() + with: + name: pytest-report-py${{ matrix.python-version }}-${{ matrix.pinecone-plan }} + path: report*.html \ No newline at end of file diff --git a/.github/workflows/CI.yml b/.github/workflows/merege_queue.yml similarity index 69% rename from .github/workflows/CI.yml rename to .github/workflows/merege_queue.yml index c0b2913f..71574ceb 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/merege_queue.yml @@ -1,6 +1,6 @@ -name: CI +name: Run system and e2e tests -on: pull_request +on: merge_queue # Cancel previous runs on the same branch \ PR number if they are still running # From: https://stackoverflow.com/a/72408109 @@ -10,48 +10,6 @@ concurrency: jobs: - run-linters: - name: Run linters - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.9, '3.10', 3.11] - - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.9 - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - version: 1.3.2 - virtualenvs-create: true - virtualenvs-in-project: true - installer-parallel: true - #---------------------------------------------- - # load cached venv if cache exists - #---------------------------------------------- - - name: Load cached venv - id: cached-poetry-dependencies - uses: actions/cache@v3 - with: - path: .venv - key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }} - #---------------------------------------------- - # install dependencies if cache does not exist - #---------------------------------------------- - - name: Install dependencies - if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - run: poetry install --no-interaction --no-root --with dev - - name: Install project - run: poetry install --no-interaction - - name: Run flake8 Check - run: poetry run flake8 . - - name: Run mypy check - run: poetry run mypy src run-tests: name: Run tests @@ -93,8 +51,6 @@ jobs: run: poetry install --no-interaction --no-root --with dev - name: Install project run: poetry install --no-interaction - - name: Run unit tests - run: poetry run pytest --html=report.html --self-contained-html tests/unit - name: Set Index Name for System / E2E id: gen_suffix run: | From d66ca8af0ca0eabab699b53ff96b1f063bad74d6 Mon Sep 17 00:00:00 2001 From: ilai Date: Sun, 29 Oct 2023 12:55:59 +0200 Subject: [PATCH 2/2] [CI] Fix merge queue workflow --- .github/workflows/merege_queue.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/merege_queue.yml b/.github/workflows/merege_queue.yml index 71574ceb..a7cc169a 100644 --- a/.github/workflows/merege_queue.yml +++ b/.github/workflows/merege_queue.yml @@ -1,6 +1,6 @@ name: Run system and e2e tests -on: merge_queue +on: merge_group # Cancel previous runs on the same branch \ PR number if they are still running # From: https://stackoverflow.com/a/72408109