Skip to content

[question] What is the correct way to use hatch with github actions? #669

@EdAyers

Description

@EdAyers

I've moved my builds to hatch. It's really nice.
Currently I have a github actions workflow that looks like

name: Client Python Package

on:
  push:
    branches: ["main"]
  pull_request:
    branches: ["main"]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Install Hatch
        run: pipx install hatch
      - name: Run tests
        run: hatch run test:test
      - name: Build dist
        run: hatch build
      - name: Publish on PyPI
        if: github.ref == 'refs/heads/main'
        run: hatch publish

which works great!

However there are a few issues that I'm having some trouble figuring out.

  • Downloading the dependencies can take a while. Is there a way of enabling dependency caching? I couldn't figure out where hatch was caching dependencies.
  • I have a test matrix for all the different versions of python, but I get Skipped 2 incompatible environments: test.py38 -> cannot locate Python: 38 test.py39 -> cannot locate Python: 39. What steps can I have to make sure these are available?

Any pointers on how to solve these would be much appreciated. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions