mcaulifn/solcast

View on GitHub
.github/workflows/pullrequest.yaml

Summary

Maintainability
Test Coverage
---
name: Pull Request Builder

on:
  pull_request:
    branches:
      - main
    tags:
      - "!*"

jobs:
  test:
    permissions:
      contents: read
      checks: write
      pull-requests: write
    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        python-version:
          - 3.9
          - "3.10"
          - 3.11
          - 3.12
    steps:
      - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
        with:
          python-version: "${{ matrix.python-version }}"
      - name: Run tox
        run: |
          python -m pip install --upgrade pip
          pip install tox poetry==1.7.1
          tox -e py
      - name: Build
        run: poetry build
      - uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          file: ./coverage.xml
          flags: unittests
          name: pysolcast
          verbose: true
  build:
    needs:
      - checks
      - test
    outputs:
      hashes: ${{ steps.hash.outputs.hashes }}
    permissions:
      contents: read
      id-token: write
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
      - name: Fetch history and tags
        run: |
          git fetch --prune --unshallow
          git fetch --depth=1 origin +refs/tags/*:refs/tags/*
      - uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
        with:
          python-version: 3.x
      - name: Build
        run: |
          python -m pip install --upgrade pip
          pip install build
          python -m build
      - name: Generate SBOM
        id: sbom
        uses: anchore/sbom-action@61119d458adab75f756bc0b9e4bde25725f86a7a # v0.17.2
      - name: "Generate hashes"
        id: hash
        run: |
          cd dist && echo "hashes=$(sha256sum * | base64 -w0)" >> $GITHUB_OUTPUT
      - name: "Upload dists"
        uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
        with:
          name: "dist"
          path: "dist/"
          if-no-files-found: error
          retention-days: 5

  checks:
    permissions:
      checks: write
      contents: read
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
      - name: "Dependency Review"
        uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4
        with:
          comment-summary-in-pr: always
          fail-on-severity: moderate
  provenance:
    needs:
      - build
    permissions:
      actions: read
      contents: write
      id-token: write # Needed to access the workflow's OIDC identity.
    uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
    with:
      base64-subjects: "${{ needs.build.outputs.hashes }}"
      upload-assets: false

  publish-to-test-pypi:
    name: "Publish to Test PyPI"
    needs:
      - build
      - provenance
    permissions:
      id-token: write # Needed for trusted publishing to PyPI.
    runs-on: "ubuntu-latest"
    environment:
      name: "testpypi"
    steps:
      - name: "Download dists"
        uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
        with:
          name: "dist"
          path: "dist/"
      - name: Publish distribution 📦 to Test PyPI
        uses: pypa/gh-action-pypi-publish@8a08d616893759ef8e1aa1f2785787c0b97e20d6 # v1.10.0
        with:
          repository-url: https://test.pypi.org/legacy/