From a50081c656298eff19eb3699746039314624bfcf Mon Sep 17 00:00:00 2001 From: Nikos Koukis Date: Sat, 10 Aug 2024 19:52:40 +0300 Subject: [PATCH] Refactor CI --- .github/workflows/ci.yml | 61 -------------------------- .github/workflows/coverage.yml | 39 ++++++++++++++++ .github/workflows/install-software.yml | 3 +- .github/workflows/linters.yml | 25 +++++++++++ .github/workflows/release.yml | 16 +++++++ .github/workflows/tests.yml | 12 ++--- 6 files changed, 88 insertions(+), 68 deletions(-) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/coverage.yml create mode 100644 .github/workflows/linters.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index ee0f424..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: CI -on: - push: - pull_request: -jobs: - style_and_linters: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: "3.8" - - name: Python Poetry Action - uses: abatilo/actions-poetry@v2.1.3 - with: - poetry-version: "1.6.1" - - name: Install prerequisites - run: | - poetry install -E google -E notion -E gkeep - poetry self add "poetry-dynamic-versioning[plugin]" - - name: Run style checkers and linters - run: poetry run pre-commit run --all-files - coverage: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: "3.8" - - name: Python Poetry Action - uses: abatilo/actions-poetry@v2.1.3 - with: - poetry-version: "1.6.1" - - name: Install prerequisites - run: | - sudo ./scripts/install-taskwarrior.sh - poetry install --all-extras - poetry self add "poetry-dynamic-versioning[plugin]" - task --version - - name: Coverage - run: | - poetry run coverage run -m pytest --doctest-modules - poetry run coverage report - # Using --service=github + secrets.GITHUB_TOKEN for builds originating from PRs to work - # Not sure if both are required - # https://github.com/TheKevJames/coveralls-python/issues/252 - - name: Coveralls - run: poetry run coveralls --service=github || poetry run coveralls - env: - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - publish_package: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Publish package to pypi - uses: JRubics/poetry-publish@v1.16 - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - with: - pypi_token: ${{ secrets.PYPI_API_TOKEN }} - plugins: "poetry-dynamic-versioning[plugin]" diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..98c989d --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,39 @@ +name: Check Coverage +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Python Poetry Action + uses: abatilo/actions-poetry@v2.1.3 + with: + poetry-version: "1.6.1" + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + cache: "poetry" + - name: Install prerequisites + run: | + sudo ./scripts/install-taskwarrior.sh + poetry install --all-extras + poetry self add "poetry-dynamic-versioning[plugin]" + task --version + - name: Coverage + run: | + poetry run coverage run -m pytest --doctest-modules + poetry run coverage report + # Using --service=github + secrets.GITHUB_TOKEN for builds originating from PRs to work + # Not sure if both are required + # https://github.com/TheKevJames/coveralls-python/issues/252 + - name: Coveralls + run: poetry run coveralls --service=github || poetry run coveralls + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/install-software.yml b/.github/workflows/install-software.yml index 489c4f1..7b70465 100644 --- a/.github/workflows/install-software.yml +++ b/.github/workflows/install-software.yml @@ -1,4 +1,4 @@ -name: CI +name: Install software on: push: pull_request: @@ -14,6 +14,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + cache: "pip" - name: Install with pip3 - no extras run: | pip3 install . diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml new file mode 100644 index 0000000..4c403dc --- /dev/null +++ b/.github/workflows/linters.yml @@ -0,0 +1,25 @@ +name: Style and Linters +on: + push: + pull_request: +jobs: + style_and_linters: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Python Poetry Action + uses: abatilo/actions-poetry@v3 + with: + poetry-version: "1.6.1" + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + cache: "poetry" + - name: Install prerequisites + run: | + poetry install --all-extras + poetry self add "poetry-dynamic-versioning[plugin]" + - name: "Run pre-commit hooks" + uses: slamcore/pre-commit-action@v0.2.0 + with: + command_prefix: "poetry run" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9ef4bd0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,16 @@ +name: Publish package +on: + push: + pull_request: + +jobs: + publish_package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Publish package to pypi + uses: JRubics/poetry-publish@v1.16 + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + with: + pypi_token: ${{ secrets.PYPI_API_TOKEN }} + plugins: "poetry-dynamic-versioning[plugin]" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d61fdab..45b873e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,19 +11,19 @@ jobs: os: [ubuntu-latest] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} + - uses: actions/checkout@v4 - name: Python Poetry Action uses: abatilo/actions-poetry@v2.1.3 with: poetry-version: "1.6.1" + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: "poetry" - name: Install prerequisites run: | - sudo ./scripts/install-taskwarrior.sh poetry install --all-extras - poetry self add "poetry-dynamic-versioning[plugin]" + sudo ./scripts/install-taskwarrior.sh task --version - name: Run tests run: poetry run pytest