diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml new file mode 100644 index 0000000..e4c7e44 --- /dev/null +++ b/.github/workflows/build-and-publish.yml @@ -0,0 +1,38 @@ +name: Build and publish package + +on: + workflow_call: + +publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Install python dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel + pip install -e .[tests,elasticsearch5] + + - name: Show python dependencies + run: | + python3 --version + pip freeze + + - name: Build package + run: | + python setup.py sdist bdist_wheel + + - name: Publish package + uses: pypa/gh-action-pypi-publish@v1.3.1 + with: + user: __token__ + password: ${{ secrets.pypi_password }} diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml deleted file mode 100644 index 2cac14b..0000000 --- a/.github/workflows/build-and-release.yml +++ /dev/null @@ -1,111 +0,0 @@ -name: Build and release - -on: - push: - branches: [master] - pull_request: - branches: [master] - -jobs: - test: - runs-on: ubuntu-20.04 - strategy: - matrix: - include: - - python: python3 - pip: pip3 - - python: python2 - pip: pip - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - python-version: ${{ matrix.python-version }} - fetch-depth: 0 - - - name: Install python dependencies - run: | - ${{ matrix.pip }} install --user --upgrade pip - ${{ matrix.pip }} --no-cache-dir install --user setuptools wheel "urllib3==1.25.11" - ${{ matrix.pip }} --no-cache-dir install --user -e .[tests,elasticsearch5] - - - name: Show python dependencies - run: | - ${{ matrix.python }} --version - ${{ matrix.pip }} freeze - - - name: Run tests - run: | - ./run-tests.sh - - bump: - needs: test - if: ${{ github.event_name == 'push' }} - runs-on: ubuntu-20.04 - steps: - - name: Check out the repository - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.x - - - name: Install bump2version - shell: bash - run: | - python -m pip install --upgrade pip - pip install bump2version - - - name: Configure git - shell: bash - run: | - git config user.name github-actions - git config user.email github-actions@github.com - - - name: Bump version - shell: bash - run: | - bump2version patch --tag --verbose - - - name: Push changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.ref }} - tags: true - - publish: - needs: bump - if: ${{ github.event_name == 'push' }} - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.x - - - name: Install python dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel - pip install -e .[tests,elasticsearch5] - - - name: Show python dependencies - run: | - pip freeze - - - name: Build package - run: | - python setup.py sdist bdist_wheel - - - name: Publish package - uses: pypa/gh-action-pypi-publish@v1.3.1 - with: - user: __token__ - password: ${{ secrets.pypi_password }} diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml new file mode 100644 index 0000000..90323da --- /dev/null +++ b/.github/workflows/bump.yml @@ -0,0 +1,41 @@ +name: Bump package version + +on: + workflow_call: + +jobs: + bump: + needs: test + runs-on: ubuntu-20.04 + steps: + - name: Check out the repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Install bump2version + shell: bash + run: | + python -m pip install --upgrade pip + pip install bump2version + + - name: Configure git + shell: bash + run: | + git config user.name github-actions + git config user.email github-actions@github.com + + - name: Bump version + shell: bash + run: | + bump2version patch --tag --verbose + + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} + tags: true \ No newline at end of file diff --git a/.github/workflows/pull-request-master.yml b/.github/workflows/pull-request-master.yml new file mode 100644 index 0000000..0992b97 --- /dev/null +++ b/.github/workflows/pull-request-master.yml @@ -0,0 +1,13 @@ +name: Pull request master + +on: + pull_request: + branches: + - master + +jobs: + python2_tests: + uses: ./.github/workflows/test-python-2.yml + + python3_tests: + uses: ./.github/workflows/test-python-3.yml \ No newline at end of file diff --git a/.github/workflows/push-master.yml b/.github/workflows/push-master.yml new file mode 100644 index 0000000..ccec57b --- /dev/null +++ b/.github/workflows/push-master.yml @@ -0,0 +1,21 @@ +name: Pull request master + +on: + push: + branches: + - master + +jobs: + python2_tests: + uses: ./.github/workflows/test-python-2.yml + + python3_tests: + uses: ./.github/workflows/test-python-3.yml + + bump_version: + needs: [python2_tests, python3_tests] + uses: ./.github/workflows/bump.yml + + publish_package: + needs: bump_version + uses: ./.github/workflows/build-and-publish.yml diff --git a/.github/workflows/test-python-2.yml b/.github/workflows/test-python-2.yml new file mode 100644 index 0000000..77a5f1f --- /dev/null +++ b/.github/workflows/test-python-2.yml @@ -0,0 +1,34 @@ +name: Test Python 2 + +on: + workflow_call: + +jobs: + test: + runs-on: ubuntu-20.04 + strategy: + matrix: + include: + - python: python2 + pip: pip + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + python-version: ${{ matrix.python-version }} + fetch-depth: 0 + + - name: Install python dependencies + run: | + ${{ matrix.pip }} install --user --upgrade pip + ${{ matrix.pip }} --no-cache-dir install --user setuptools wheel "urllib3==1.25.11" + ${{ matrix.pip }} --no-cache-dir install --user -e .[tests,elasticsearch5] + + - name: Show python dependencies + run: | + ${{ matrix.python }} --version + ${{ matrix.pip }} freeze + + - name: Run tests + run: | + ./run-tests.sh diff --git a/.github/workflows/test-python-3.yml b/.github/workflows/test-python-3.yml new file mode 100644 index 0000000..5b1f3a4 --- /dev/null +++ b/.github/workflows/test-python-3.yml @@ -0,0 +1,41 @@ +name: Test Python 3 + +on: + workflow_call: + +jobs: + test: + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.experimental }} + strategy: + fail-fast: true + matrix: + python-version: ["3.9", "3.10", "3.11"] + experimental: [false] + include: + - python-version: "3.12" + experimental: true + + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e .[tests] + + - name: Show python dependencies + run: | + python3 --version + pip freeze + + - name: Run tests + run: | + ./run-tests.sh