From 3068b265799fc7bb40eaaa2e42b09747a42feffd Mon Sep 17 00:00:00 2001 From: jxdv Date: Wed, 31 Jan 2024 20:11:12 +0000 Subject: [PATCH] ci: Optimize actions (#187) * update linter ci * optimize build ci * cosmetics --- .github/workflows/ci.yml | 54 +++++++++++++++++------------------ .github/workflows/docker.yml | 8 ++---- .github/workflows/lint.yml | 13 +++++++-- .github/workflows/publish.yml | 5 ++-- 4 files changed, 43 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a41a85..c097b83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,75 +3,75 @@ name: Continuous Integration on: workflow_dispatch: pull_request: - branches: - - master + branches: [ master ] paths: - "docker/**" - "graphenex/**" push: - branches: - - master + branches: [ master ] paths: - "docker/**" - "graphenex/**" jobs: setup_linux: - name: "Linux setup" + name: Linux setup runs-on: ubuntu-latest steps: - - name: checkout + - name: Checkout uses: actions/checkout@v4 - - name: "Install dependencies" - run: | - sudo apt-get update - sudo apt-get install -y \ - --no-install-recommends \ - --allow-unauthenticated python3-pip + - name: Python setup + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Install poetry + uses: snok/install-poetry@v1 - - name: "Install grapheneX" + - name: Install grapheneX run: | - python3 -m pip install poetry poetry install - - name: "Python import issue workaround" + - name: Python import issue workaround run: | sed -i '/Mapping/s/collections/collections.abc/' \ /home/runner/.cache/pypoetry/virtualenvs/graphenex--sEiZHBC-py3.10/lib/python3.10/site-packages/prompt_toolkit/styles/from_dict.py - - name: "Run grapheneX" + - name: Run grapheneX run: poetry run grapheneX setup_windows: - name: "Windows setup" + name: Windows setup runs-on: windows-latest + defaults: + run: + shell: bash + steps: - name: checkout uses: actions/checkout@v4 - - name: "Install python" + - name: Python setup uses: actions/setup-python@v5 with: python-version: "3.10" - cache: "pip" - - name: "Update pip" - run: python -m pip install --upgrade pip + - name: Install poetry + uses: snok/install-poetry@v1 - - name: "Install grapheneX" + - name: Install grapheneX run: | - python3 -m pip install poetry poetry install - - name: "Python import issue workaround" + - name: Python import issue workaround shell: pwsh run: (Get-Content C:\Users\runneradmin\AppData\Local\pypoetry\Cache\virtualenvs\graphenex-6fD1lE0z-py3.10\lib\site-packages\prompt_toolkit\styles\from_dict.py) -Replace 'from collections import Mapping', 'from collections.abc import Mapping' | Set-Content C:\Users\runneradmin\AppData\Local\pypoetry\Cache\virtualenvs\graphenex-6fD1lE0z-py3.10\lib\site-packages\prompt_toolkit\styles\from_dict.py - - name: "Update Flask-SocketIO" - run: python3 -m pip install --upgrade flask_socketio + - name: Update Flask-SocketIO + run: python -m pip install --upgrade flask_socketio - - name: "run grapheneX" + - name: Run grapheneX run: poetry run grapheneX \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 761de9f..10bf502 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,18 +2,16 @@ name: Docker Automated Build on: push: - branches: - - master + branches: [ master ] tags: - ".*" pull_request: - branches: - - master + branches: [ master ] jobs: docker: name: Docker Build and Push - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3190ce3..2bf266e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,9 +1,18 @@ name: Ruff -on: [ push, pull_request ] +on: + push: + branches: [ master ] + paths: + - 'grapheneX/**/*.py' + pull_request: + branches: [ master ] + paths: + - 'grapheneX/**/.py' + jobs: ruff: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e7aa6d9..98c88e1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,8 +2,7 @@ name: PyPI Automated publish on: pull_request: - branches: - - master + branches: [ master ] push: tags: - "*" @@ -11,7 +10,7 @@ on: jobs: deploy: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - name: Checkout