diff --git a/.codecov.yaml b/.codecov.yaml new file mode 100644 index 0000000..6a4917b --- /dev/null +++ b/.codecov.yaml @@ -0,0 +1,3 @@ +codecov: + notify: + after_n_builds: 5 diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..491deae --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: +- package-ecosystem: pip + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..77681a6 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,40 @@ +name: CI + +on: + workflow_dispatch: + inputs: + upload-wheel: + type: boolean + required: false + default: false + description: Upload wheel as an artifact + pull_request: + branches: [ main ] + push: + branches: [ main ] + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + tests: + uses: ./.github/workflows/step_test.yaml + + build-wheel: + uses: ./.github/workflows/step_build-wheel.yaml + needs: [ tests ] + with: + upload: ${{ inputs.upload-wheel || false }} + pass: + needs: [tests, build-wheel] + runs-on: ubuntu-latest + steps: + - name: Check all CI action + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} + if: always() diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..343df84 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,52 @@ +name: Prepare release + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + - "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" + workflow_dispatch: + inputs: + ref: + description: Tag to release + required: true + type: string + +permissions: + contents: read + +jobs: + tests: + uses: ./.github/workflows/step_test.yaml + build-wheel: + needs: [ tests ] + uses: ./.github/workflows/step_build-wheel.yaml + with: + ref: ${{ inputs.ref }} + upload_pypi: + name: Upload to PyPI repository + needs: [ tests, build-wheel ] + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/click-option-group/ + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + release: + needs: [ upload_pypi ] + name: Create release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: softprops/action-gh-release@v1 + with: + name: click-option-group ${{ github.ref_name }} + prerelease: ${{ contains(github.ref, 'rc') }} + generate_release_notes: true diff --git a/.github/workflows/step_build-wheel.yaml b/.github/workflows/step_build-wheel.yaml new file mode 100644 index 0000000..b1cb720 --- /dev/null +++ b/.github/workflows/step_build-wheel.yaml @@ -0,0 +1,29 @@ +on: + workflow_call: + inputs: + upload: + description: Upload wheel as artifact + required: false + type: boolean + default: true + ref: + description: Tag to release + required: false + type: string + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + - name: Build package + run: pipx run build + - uses: actions/upload-artifact@v3 + with: + path: dist/* + if: ${{ inputs.upload }} diff --git a/.github/workflows/step_test.yaml b/.github/workflows/step_test.yaml new file mode 100644 index 0000000..a9cd07d --- /dev/null +++ b/.github/workflows/step_test.yaml @@ -0,0 +1,45 @@ +on: + workflow_call: + +permissions: + contents: read + +jobs: + tests: + name: Check with Python ${{ matrix.python-version }} ${{ matrix.experimental && '(Experimental)' }} + needs: [ pre-commit ] + continue-on-error: ${{ matrix.experimental || false }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ] + include: + - python-version: "3.12" + experimental: true + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + allow-prereleases: true + + - name: Install package + run: pip install -e .[test-cov] + - name: Test package + run: pytest --cov --cov-report=xml + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + name: python ${{ matrix.python-version }} + flags: python-${{ matrix.python-version }} + + pass: + needs: [ tests ] + runs-on: ubuntu-latest + steps: + - name: Check test jobs + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} + if: always() diff --git a/pyproject.toml b/pyproject.toml index b1a42fa..fc1a755 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,10 @@ fypp = "fypp:run_fypp" test = [ "pytest", ] +test-cov = [ + "fypp[test]", + "pytest-cov", +] docs = [ "sphinx", "sphinx-rtd-theme",