diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0dbb74a..862695a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,67 +29,42 @@ permissions: contents: read jobs: - linting: - name: Reuse linting job - uses: ./.github/workflows/lint.yml + lint: + uses: reqstool/.github/.github/workflows/python-lint.yml@91cd368066d5458b5d46bdf34c4d8ca483f6633f # 1.2.2 build: - needs: linting - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - reqstool-source: [pypi, main] - steps: - # Full history and tags: hatch-vcs derives the version from git state, so a - # shallow clone would build the wrong number rather than fail. - - name: Check out source repository - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - fetch-depth: 0 - fetch-tags: true - ref: ${{ inputs.ref || github.ref }} - - name: Set up Python - uses: actions/setup-python@v7.1.0 - with: - python-version: "3.15.2" - - name: Install dependencies - # renovate: datasource=pypi depName=hatch - run: pip install hatch==1.18.2 - - name: Run tests - run: hatch run dev:pytest --junitxml=build/junit.xml --cov=reqstool_python_decorators --cov-report=xml:build/coverage.xml - - name: Build project - run: hatch build - - name: Self-apply own decorator processor to own src/tests - # Relies on `hatch build` (above) not cleaning build/ -- annotations.yml lands - # alongside the junit/coverage output from the "Run tests" step, and - # reqstool_config.yml expects to find both there. If hatch build ever starts - # cleaning build/, move the pytest output dir outside of it. - run: hatch run dev:python scripts/generate_annotations.py - - name: Install reqstool - uses: reqstool/.github/.github/actions/install-reqstool@6fc8d3e3d4c3fdf7a83cb7b7a274e4761486ca71 # 1.2.1 - with: - reqstool-source: ${{ matrix.reqstool-source }} - - name: Validate reqstool spec completeness - # not yet available in the latest PyPI release; supplementary to (not a - # replacement for) the `reqstool status --fail-if-incomplete` gate below, which - # is the actual required check on the pypi leg - if: matrix.reqstool-source == 'main' - uses: reqstool/.github/.github/actions/validate-reqstool@6fc8d3e3d4c3fdf7a83cb7b7a274e4761486ca71 # 1.2.1 - - name: Run reqstool status - # Required gate on both matrix legs -- fails the build unless every - # requirement is implemented and verified. - uses: reqstool/.github/.github/actions/reqstool-status@6fc8d3e3d4c3fdf7a83cb7b7a274e4761486ca71 # 1.2.1 - with: - fail-if-incomplete: "true" - # Upload artifacts for later use - - name: Upload Artifacts - if: matrix.reqstool-source == 'pypi' - uses: actions/upload-artifact@v7.0.2 - with: - name: ${{ inputs.artifact-name || 'dist' }} - path: dist/ + needs: lint + uses: reqstool/.github/.github/workflows/python-build-hatch.yml@91cd368066d5458b5d46bdf34c4d8ca483f6633f # 1.2.2 + with: + coverage-source: reqstool_python_decorators + ref: ${{ inputs.ref }} + artifact-name: ${{ inputs.artifact-name || 'dist' }} + post-test-command: hatch run dev:python scripts/generate_annotations.py + + reqstool: + needs: build + uses: reqstool/.github/.github/workflows/common-reqstool-verify.yml@91cd368066d5458b5d46bdf34c4d8ca483f6633f # 1.2.2 + with: + build-artifact: ${{ inputs.artifact-name || 'dist' }}-build + + smoke: + needs: build + uses: reqstool/.github/.github/workflows/python-smoke.yml@91cd368066d5458b5d46bdf34c4d8ca483f6633f # 1.2.2 + with: + dist-artifact: ${{ inputs.artifact-name || 'dist' }} + requirements: pytest==8.4.1 + command: pytest tests/unit tests/e2e validate-openspec: uses: reqstool/.github/.github/workflows/common-validate-openspec.yml@6fc8d3e3d4c3fdf7a83cb7b7a274e4761486ca71 # 1.2.1 + + ci: + if: ${{ always() }} + needs: [lint, build, reqstool, smoke, validate-openspec] + runs-on: ubuntu-latest + steps: + - name: Fail unless every needed job succeeded + env: + NEEDS: ${{ toJSON(needs) }} + run: | + echo "$NEEDS" | python3 -c 'import json,sys; r={k:v["result"] for k,v in json.load(sys.stdin).items()}; print(r); sys.exit(0 if all(v=="success" for v in r.values()) else 1)' diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 6b476fe..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Lint (black and flake8) -on: - workflow_dispatch: - workflow_call: - -permissions: - contents: read - -jobs: - linting: - runs-on: ubuntu-latest - steps: - - name: Check out source repository - uses: actions/checkout@v7.0.1 - - name: Set up Python - uses: actions/setup-python@v7.1.0 - with: - python-version: "3.15.2" - - name: Install pip package(s) - # renovate: datasource=pypi depName=hatch - run: pip install hatch==1.18.2 - - name: Run black formatter check - run: hatch run dev:black --check --verbose src tests - - name: Run flake8 linter - run: hatch run dev:flake8