Skip to content

Commit

Permalink
refactor actions
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalEgn committed Jul 18, 2024
1 parent 5eaad9c commit b6ca8d0
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 63 deletions.
Original file line number Diff line number Diff line change
@@ -1,101 +1,64 @@
name: bump, build and release
name: Bump package version and publish to pypi

on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_call:

jobs:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
include:
- python: python3
pip: pip3
- python: python2
pip: pip
bump:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.INSPIRE_BOT_TOKEN }}
fetch-depth: 0

- name: Install npm dependencies
run: |
npm install buffer-shims
npm install --global rollup
- 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,docs]
- 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
uses: actions/setup-python@v5
with:
python-version: 3.x
python-version: "3.11"

- name: Install bump2version
- name: Configure git
shell: bash
run: |
python -m pip install --upgrade pip
pip install bump2version
git config user.name github-actions
git config user.email "38065702145+github-actions[bot]@users.noreply.github.com"
- name: Configure git
- name: Install bump2version
shell: bash
run: |
git config user.name github-actions
git config user.email github-actions@github.com
python -m pip install --upgrade pip
pip install bump2version
- name: Bump version
shell: bash
run: |
bump2version patch --tag --verbose
- name: Push changes
uses: ad-m/github-push-action@master
uses: ad-m/github-push-action@v0.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
github_token: ${{ secrets.INSPIRE_BOT_TOKEN }}
tags: true

publish:
needs: bump
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: "3.11"

- name: Setup nodejs
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 10.14.0
registry-url: "https://registry.npmjs.org"
Expand All @@ -108,20 +71,20 @@ jobs:
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip --no-cache-dir install setuptools wheel "urllib3==1.25.11"
pip --no-cache-dir install -e .[tests,docs]
pip install setuptools wheel
pip install -e .[tests,docs]
- name: Show python dependencies
run: |
python3 --version
pip freeze
- name: Build package
run: |
mkdir clean-build
python setup.py sdist bdist_wheel --universal --dist-dir ./clean-build
- name: Publish package
uses: pypa/gh-action-pypi-publish@v1.3.1
uses: pypa/gh-action-pypi-publish@v1.9.0
with:
verify_metadata: false
user: __token__
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/pull-request-master.yml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions .github/workflows/push-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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-and-publish.yml
secrets: inherit

36 changes: 36 additions & 0 deletions .github/workflows/test-python-2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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: |
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
${{ matrix.python }} get-pip.py
${{ matrix.python }} -m ${{ matrix.pip }} install --user --upgrade pip
${{ matrix.python }} -m ${{ matrix.pip }} --no-cache-dir install --user setuptools wheel "urllib3==1.25.11"
${{ matrix.python }} -m ${{ 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
42 changes: 42 additions & 0 deletions .github/workflows/test-python-3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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.x"
check-latest: true
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
2 changes: 1 addition & 1 deletion tests/integration/test_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
def load_file(file_name):
path = os.path.join(FIXTURES_PATH, file_name)
with open(path) as input_data:
data = yaml.load(input_data.read())
data = yaml.full_load(input_data.read())

return data

Expand Down

0 comments on commit b6ca8d0

Please sign in to comment.