Skip to content

[pre-commit.ci] pre-commit autoupdate (#152) #60

[pre-commit.ci] pre-commit autoupdate (#152)

[pre-commit.ci] pre-commit autoupdate (#152) #60

Workflow file for this run

name: pytest
on:
push:
branches: [ main ]
paths:
- flowermd/**
- environment-dev.yml
- .github/workflows/pytest.yml
pull_request:
branches: [ main ]
paths:
- flowermd/**
- environment-dev.yml
- .github/workflows/pytest.yml
issue_comment:
types: [created]
branches: [ main ]
paths:
- flowermd/**
- environment-dev.yml
- .github/workflows/pytest.yml
workflow_dispatch:
jobs:
pytest:
if: github.event.pull_request.draft == false
strategy:
fail-fast: false
matrix:
os: [macos-latest, macOS-13, ubuntu-latest]
python-version: ['3.10', '3.11']
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Build environment
uses: conda-incubator/setup-miniconda@v3
with:
environment-file: environment-dev.yml
python-version: ${{ matrix.python-version }}
miniforge-variant: Mambaforge
miniforge-version: 4.9.2-4
use-mamba: true
- name: Install package
shell: bash -l {0}
run: pip install .
- name: Run pytest with coverage report
shell: bash -l {0}
run: python -m pytest -rs -v --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
test-tutorials:
if: ${{ github.event.issue.pull_request && github.event.comment.body== '/testtutorials'}}
runs-on: ubuntu-latest
steps:
- name: Put a reaction to the comment
run: gh api graphql --silent --raw-field query="mutation AddReaction {addReaction(input:{subjectId:\"$NODE_ID\",content:EYES}){reaction{content}subject{id}}}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_ID: ${{ github.event.comment.node_id }}
- name: Check if PR is open
run: |
STATE=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json state --jq .state)
if [ "$STATE" != "OPEN" ]; then
echo "Cannot build for closed PRs"
(
echo "**${{ github.workflow }}**"
echo "Cannot build Kuby for a closed PR. Use the `latest` version (built for the `master` branch) or create a new PR."
) | \
gh pr comment "${PR_NUMBER}" --repo ${{ github.repository }} -F -
gh api graphql --silent --raw-field query="mutation AddReaction {addReaction(input:{subjectId:\"$NODE_ID\",content:THUMBS_DOWN}){reaction{content}subject{id}}}"
gh api graphql --silent --raw-field query="mutation RemoveReaction {removeReaction(input:{subjectId:\"$NODE_ID\",content:EYES}){reaction{content}subject{id}}}"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
NODE_ID: ${{ github.event.comment.node_id }}
- name: Get PR HEAD Ref
id: getRef
run: echo "pr_ref=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json headRefOid | jq -r '.headRefOid')" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
- name: Check out repository
uses: actions/checkout@v2
- name: Build environment
uses: conda-incubator/setup-miniconda@v2
with:
environment-file: environment-dev.yml
miniforge-variant: Mambaforge
miniforge-version: 4.9.2-4
use-mamba: true
- name: Install package
shell: bash -l {0}
run: pip install .
- name: Run pytest on tutorials
shell: bash -l {0}
run: python -m pytest -rs -v --nbmake tutorials/