Update GitHub Actions workflow to specify test directory for coverage… #15
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pull Request - Ansible Lint and Code Coverage | |
| on: [push, pull_request] | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout the code | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2 | |
| - name: Setup Python | |
| uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 #v5.4.0 | |
| with: | |
| python-version: '3.x' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Install Ansible Collections | |
| run: | | |
| ansible-galaxy collection install ansible.windows --force | |
| ansible-galaxy collection install ansible.posix --force | |
| ansible-galaxy collection install ansible.utils --force | |
| ansible-galaxy collection install ansible.netcommon:5.1.2 --force | |
| ansible-galaxy collection install community.windows --force | |
| ansible-galaxy collection install community.general --force | |
| ansible-galaxy collection install microsoft.ad --force | |
| - name: Run ansible-lint | |
| run: | | |
| ansible-lint src/ -c .ansible-lint | |
| - name: Run pytest with coverage | |
| run: | | |
| pytest --cov=src/ --cov-report=xml tests/ | |
| - name: Check code formatting with black | |
| run: | | |
| black --check src/ --config pyproject.toml | |
| - name: Validate PR Description | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| const core = require('@actions/core'); | |
| const pr = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.payload.pull_request.number, | |
| }); | |
| const body = pr.data.body || ""; | |
| const requiredSections = [ | |
| "Description", | |
| "Test Cases", | |
| "Checklist", | |
| ]; | |
| const missingSections = requiredSections.filter(section => !body.includes(section)); | |
| if(missingSections.length > 0) { | |
| core.setFailed(`PR Description is missing the following sections: ${missingSections.join(", ")}`); | |
| } |