From fd2886a0352b192a8e72479270f0c4a3b628ae2f Mon Sep 17 00:00:00 2001 From: DevForge Engineer Date: Mon, 18 May 2026 07:27:31 -0400 Subject: [PATCH] fix(ci): consolidate duplicate CI workflows, harden security, update actions - Merge test.yml into ci.yml (test.yml ran same triggers + same tests) - Expand Python matrix: 3.11/3.12 -> 3.10/3.11/3.12/3.13 - Add CLI check steps from test.yml - Add persist-credentials: false to all checkout steps - Add top-level permissions: contents: read to ci.yml - Add contents: read to publish.yml permissions (was only id-token: write) - Update actions/checkout v4->v6, actions/setup-python v5->v6 - Remove redundant test.yml (functionality fully merged into ci.yml) --- .github/workflows/ci.yml | 24 ++++++++++++++++----- .github/workflows/publish.yml | 12 +++++++---- .github/workflows/test.yml | 40 ----------------------------------- 3 files changed, 27 insertions(+), 49 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2c7045..c43f0fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,18 +6,23 @@ on: pull_request: branches: [master] +permissions: + contents: read + jobs: test: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 + with: + persist-credentials: false - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} @@ -32,18 +37,27 @@ jobs: - name: Run tests run: python -m pytest tests/ -x -q + - name: Check CLI works + run: | + apiauth --version + apiauth --help + apiauth generate --help + publish: needs: test if: github.event_name == 'push' && github.ref == 'refs/heads/master' && secrets.PYPI_API_TOKEN != '' runs-on: ubuntu-latest permissions: + contents: read id-token: write steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 + with: + persist-credentials: false - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: "3.12" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2ae0c45..0a21460 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,18 +4,22 @@ on: release: types: [published] +permissions: + contents: read + id-token: write + jobs: publish: runs-on: ubuntu-latest environment: pypi - permissions: - id-token: write steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 + with: + persist-credentials: false - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: "3.12" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index e21d8d0..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CI - -on: - push: - branches: [master] - pull_request: - branches: [master] - -jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.10", "3.11", "3.12", "3.13"] - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -e ".[dev]" - - - name: Lint with ruff - run: pip install ruff && ruff check src/ --target-version py310 - - name: Run tests - run: | - python -m pytest tests/ -v --tb=short - - - name: Check CLI works - run: | - apiauth --version - apiauth --help - apiauth generate --help -