From 9a0f1f3dadd5b4b236a771b8e06afdeee209cb8b Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Sat, 25 Jun 2022 22:34:05 +0100 Subject: [PATCH 1/4] Split CI by function --- .github/workflows/ci-branch-main.yml | 44 +++++++++++++ .../workflows/{ci.yml => ci-development.yml} | 19 +----- .github/workflows/ci-pull-request.yml | 65 +++++++++++++++++++ 3 files changed, 112 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/ci-branch-main.yml rename .github/workflows/{ci.yml => ci-development.yml} (84%) create mode 100644 .github/workflows/ci-pull-request.yml diff --git a/.github/workflows/ci-branch-main.yml b/.github/workflows/ci-branch-main.yml new file mode 100644 index 0000000..489583f --- /dev/null +++ b/.github/workflows/ci-branch-main.yml @@ -0,0 +1,44 @@ +name: CI +on: + workflow_dispatch: + push: + branches: + - "main" + paths-ignore: + - 'README.md' + - 'LICENSE.md' + - '.gitignore' + - 'renovate.json' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Setup Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + # - name: Install dependencies + # run: pip install -r requirements.txt && pip install -r requirements-dev.txt + - name: Install build dependencies + run: pip install setuptools wheel + - name: Build wheel file + run: python setup.py bdist_wheel + - id: skip_check + uses: actions/upload-artifact@v3 + with: + name: whl + path: dist/ + + publish: + needs: build + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + runs-on: ubuntu-latest + steps: + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci-development.yml similarity index 84% rename from .github/workflows/ci.yml rename to .github/workflows/ci-development.yml index bfad360..09905ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci-development.yml @@ -2,12 +2,13 @@ name: CI on: workflow_dispatch: push: + branches: + - '!main' paths-ignore: - 'README.md' - 'LICENSE.md' - '.gitignore' - 'renovate.json' - pull_request: jobs: skip_duplicate: @@ -92,12 +93,10 @@ jobs: steps: - name: Check out repository code uses: actions/checkout@v3 - - name: Setup Python ${{ matrix.python-version }} + - name: Setup Python 3.10 uses: actions/setup-python@v4 with: python-version: "3.10" - # - name: Install dependencies - # run: pip install -r requirements.txt && pip install -r requirements-dev.txt - name: Install build dependencies run: pip install setuptools wheel - name: Build wheel file @@ -107,15 +106,3 @@ jobs: with: name: whl path: dist/ - - publish: - name: Publish - needs: build - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - runs-on: ubuntu-latest - steps: - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/ci-pull-request.yml b/.github/workflows/ci-pull-request.yml new file mode 100644 index 0000000..3048445 --- /dev/null +++ b/.github/workflows/ci-pull-request.yml @@ -0,0 +1,65 @@ +name: CI +on: + pull_request: + paths-ignore: + - 'README.md' + - 'LICENSE.md' + - '.gitignore' + - 'renovate.json' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + strategy: + fail-fast: false + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: python + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install dependencies + run: pip install -r requirements.txt && pip install -r requirements-dev.txt + - name: Lint + run: pylint --recursive=yes . + + test: + name: Run unit tests + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ '3.10' ] + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: pip install -r requirements.txt && pip install -r requirements-dev.txt + - name: Run test suite + run: coverage run -m py.test -v + - name: Upload Coverage to Codecov + uses: codecov/codecov-action@v3 -- 2.47.2 From e0248f83ffafaf57d4e3708efd56a1c4a1cb6f26 Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Sat, 25 Jun 2022 22:36:52 +0100 Subject: [PATCH 2/4] Add lint/test to CI for main (codecov) --- .github/workflows/ci-branch-main.yml | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/ci-branch-main.yml b/.github/workflows/ci-branch-main.yml index 489583f..31c9ccc 100644 --- a/.github/workflows/ci-branch-main.yml +++ b/.github/workflows/ci-branch-main.yml @@ -11,6 +11,41 @@ on: - 'renovate.json' jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install dependencies + run: pip install -r requirements.txt && pip install -r requirements-dev.txt + - name: Lint + run: pylint --recursive=yes . + + test: + name: Run unit tests + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ '3.10' ] + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: pip install -r requirements.txt && pip install -r requirements-dev.txt + - name: Run test suite + run: coverage run -m py.test -v + - name: Upload Coverage to Codecov + uses: codecov/codecov-action@v3 + build: runs-on: ubuntu-latest steps: -- 2.47.2 From 8b25be3889c67311391e3696fed3202f707820dc Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Sat, 25 Jun 2022 22:38:31 +0100 Subject: [PATCH 3/4] Add lint/test to CI for main (codecov) (2) --- .github/workflows/ci-branch-main.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci-branch-main.yml b/.github/workflows/ci-branch-main.yml index 31c9ccc..369d980 100644 --- a/.github/workflows/ci-branch-main.yml +++ b/.github/workflows/ci-branch-main.yml @@ -12,7 +12,6 @@ on: jobs: lint: - name: Lint runs-on: ubuntu-latest steps: - name: Check out repository code @@ -27,7 +26,6 @@ jobs: run: pylint --recursive=yes . test: - name: Run unit tests runs-on: ubuntu-latest strategy: matrix: -- 2.47.2 From 935a927357df3396866ea0055f1c9453c3957e62 Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Sat, 25 Jun 2022 22:39:39 +0100 Subject: [PATCH 4/4] Give each CI file a unique name --- .github/workflows/ci-branch-main.yml | 2 +- .github/workflows/ci-development.yml | 2 +- .github/workflows/ci-pull-request.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-branch-main.yml b/.github/workflows/ci-branch-main.yml index 369d980..ce2f6a3 100644 --- a/.github/workflows/ci-branch-main.yml +++ b/.github/workflows/ci-branch-main.yml @@ -1,4 +1,4 @@ -name: CI +name: CI - Merge to main on: workflow_dispatch: push: diff --git a/.github/workflows/ci-development.yml b/.github/workflows/ci-development.yml index 09905ff..f31d988 100644 --- a/.github/workflows/ci-development.yml +++ b/.github/workflows/ci-development.yml @@ -1,4 +1,4 @@ -name: CI +name: CI - Development on: workflow_dispatch: push: diff --git a/.github/workflows/ci-pull-request.yml b/.github/workflows/ci-pull-request.yml index 3048445..7de9d84 100644 --- a/.github/workflows/ci-pull-request.yml +++ b/.github/workflows/ci-pull-request.yml @@ -1,4 +1,4 @@ -name: CI +name: CI - Pull request on: pull_request: paths-ignore: -- 2.47.2