Merge pull request #15 from alan-turing-institute/python-migration #21
This file contains 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: Test code | |
# Run workflow on PRs and pushes to matching branches | |
on: # yamllint disable-line rule:truthy | |
push: | |
branches: [main] | |
pull_request: | |
jobs: | |
test_code: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Install hatch | |
run: pip install hatch | |
- name: Install requirements | |
run: | | |
sudo apt-get install \ | |
libldap2-dev \ | |
libsasl2-dev | |
- name: Test Python | |
run: hatch run test:all | |
# For security reasons, PRs created from forks cannot generate PR comments directly | |
# (see https://securitylab.github.com/research/github-actions-preventing-pwn-requests/). | |
# Instead we need to trigger another workflow after this one completes. | |
- name: Generate coverage comment | |
id: coverage_comment | |
uses: py-cov-action/python-coverage-comment-action@v3 | |
with: | |
GITHUB_TOKEN: ${{ github.token }} | |
# Save the coverage comment for later use | |
# See https://github.com/py-cov-action/python-coverage-comment-action/blob/main/README.md | |
- name: Save coverage comment as an artifact | |
uses: actions/upload-artifact@v4 | |
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' | |
with: | |
name: python-coverage-comment-action | |
path: python-coverage-comment-action.txt |