pytest #16
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: pytest | |
# Controls when the workflow will run | |
on: | |
release: | |
types: [published] | |
#on: | |
# # Triggers the workflow on push or pull request events but only for the main branch | |
# push: | |
# branches: [ main ] | |
# pull_request: | |
# branches: [ main ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
test: | |
name: Run tests & display coverage | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.9' | |
- name: Set up Miniconda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
miniconda-version: "latest" | |
channels: conda-forge, os-simopt | |
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly! | |
auto-update-conda: true | |
auto-activate-base: true | |
- name: Create Conda environment | |
run: conda create -n myenv python=3.9 | |
- name: Activate Conda environment | |
run: conda activate myenv | |
- name: Install Conda package | |
run: | | |
conda install -c os-simopt simopt-tools | |
conda install conda-build | |
- name: Install Pip requirements | |
run: pip install -r requirements.txt | |
- name: Install Package in dev mode | |
run: | | |
cd src | |
conda develop . | |
cd .. | |
- name: Lanuch tests and generate report | |
run: | | |
pip install pytest | |
pip install pytest-cov | |
pytest | |
- name: Coverage comment | |
id: coverage_comment | |
uses: ewjoachim/python-coverage-comment-action@v2 | |
with: | |
GITHUB_TOKEN: ${{ github.token }} | |
# Only necessary in the "workflow_run" workflow. | |
#GITHUB_PR_RUN_ID: ${{ inputs.GITHUB_PR_RUN_ID }} | |
# If the coverage percentage is above or equal to this value, the badge will be green. | |
# Same with orange. Below is red. | |
MINIMUM_GREEN: 90 | |
MINIMUM_ORANGE: 70 | |
# If true, will run `coverage combine` before reading the `.coverage` file. | |
MERGE_COVERAGE_FILES: false | |
VERBOSE: true | |
# Name of the json file containing badge informations stored in the repo wiki. | |
# You typically don't have to change this unless you're already using this name for something else. | |
BADGE_FILENAME: python-coverage-comment-action-badge.json | |
# Name of the artifact in which the body of the comment to post on the PR is stored. | |
# You typically don't have to change this unless you're already using this name for something else. | |
COMMENT_ARTIFACT_NAME: python-coverage-comment-action | |
# Name of the file in which the body of the comment to post on the PR is stored. | |
# You typically don't have to change this unless you're already using this name for something else. | |
COMMENT_FILENAME: python-coverage-comment-action.txt | |
- name: Store Pull Request comment to be posted | |
uses: actions/upload-artifact@v2 | |
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' | |
with: | |
# If you use a different name, update COMMENT_ARTIFACT_NAME accordingly | |
name: python-coverage-comment-action | |
# If you use a different name, update COMMENT_FILENAME accordingly | |
path: python-coverage-comment-action.txt | |