diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 2c55069..c09da04 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -5,28 +5,72 @@ on: types: [released] jobs: - deploy: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["ubuntu-latest"] + python_version: ['3.9'] + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python_version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install hatch pre-commit + hatch env create + - name: Lint and typecheck + run: | + hatch run lint:lint-check + # - name: Run Tests + # run: | + # hatch run test:pytest + - uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true + verbose: true + + release: runs-on: ubuntu-latest + environment: release + needs: test + if: startsWith(github.ref, 'refs/tags/') + permissions: + contents: write + id-token: write steps: - uses: actions/checkout@v4 - - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.10" - + python-version: '3.9' - name: Install dependencies + shell: bash run: | python -m pip install --upgrade pip - pip install -e .[release] - + pip install hatch pre-commit - name: Build - run: python setup.py sdist bdist_wheel - - - name: Publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: twine upload dist/* --verbose + run: | + hatch build + - name: Publish 📦 to Test PyPI + if: startsWith(github.ref, 'refs/heads/main') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + skip_existing: true + user: __token__ + password: ${{ secrets.TEST_PYPI_SECRECT }} + packages-dir: dist/ + repository-url: https://test.pypi.org/legacy/ + - name: Publish 📦 to PyPI + if: startsWith(github.ref, 'refs/heads/main') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_SECRECT }} + packages-dir: dist/ diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 19be36d..38dce05 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,73 +10,27 @@ concurrency: cancel-in-progress: true jobs: - linting: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - pip install .[lint] - - - name: Run Black - run: black --check . - - - name: Run isort - run: isort --check-only . - - - name: Run flake8 - run: flake8 . - - - name: Run mdformat - run: mdformat . --check - - type-check: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - pip install .[lint,test] - - - name: Run MyPy - run: mypy . - - functional: - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: [ubuntu-latest, macos-latest] # eventually add `windows-latest` - python-version: [3.9, "3.10", "3.11", "3.12"] - - steps: - - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - pip install .[test] - - - name: Run Tests - run: pytest -m "not fuzzing" -n 0 -s --cov + tests: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + python-version: ["3.9", "3.10", "3.11"] + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python_version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install hatch + hatch env create + - name: Lint and typecheck + run: | + hatch run lint-check + - name: Run Tests + run: | + hatch run test:pytest diff --git a/pyproject.toml b/pyproject.toml index a208bc4..52efb0c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -200,6 +200,28 @@ lint-check = [ "mypy src/ape_utils/" ] +# Docs env dendencies +[tool.hatch.envs.docs] +dependencies = [ + "mkdocs", + "mkdocs-material", + "mkdocs-gen-files", + "mkdocstrings[python]", + "linkchecker", + "ape_utils @ {root:uri}/" +] + +[tool.hatch.envs.docs.scripts] +docs-serve = "mkdocs serve" +docs-build = "mkdocs build --clean --strict" +# --ignore-url=None since the SUMMARY.md file leaves a None in sitemap.xml +validate = "linkchecker --ignore-url=/reference --ignore-url=None site" +# https://github.com/linkchecker/linkchecker/issues/678 +build-check = [ + "docs-build", + "validate", +] + [tool.hatch.envs.test] extra-dependencies = ["pytest", "pytest-xdist", "pytest-cov", "hypothesis"]