Update test.yaml #38
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 and Cover | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
permissions: | |
# Gives the action the necessary permissions for publishing new | |
# comments in pull requests. | |
pull-requests: write | |
# Gives the action the necessary permissions for pushing data to the | |
# python-coverage-comment-action branch, and for editing existing | |
# comments (to avoid publishing multiple comments in the same PR) | |
contents: write | |
strategy: | |
# You can use PyPy versions in python-version. | |
# For example, pypy-2.7 and pypy-3.8 | |
max-parallel: 2 | |
matrix: | |
python-version: ["3.9", "3.10"] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
sudo apt install pandoc | |
python -m pip install --upgrade pip | |
python -m pip install .[tests] | |
env: | |
LD_LIBRARY_PATH: "DUMMY" | |
- name: Create folder | |
run: | | |
mkdir -p /home/runner/.astropy/cache/sncosmo | |
- name: Test | |
run: | | |
python -m coverage run -p -m unittest discover -s ./tests/ | |
env: | |
SNCOSMO_DATA_DIR: "/home/runner/.astropy/cache/sncosmo" | |
COVERAGE_FILE: .kilopop_coverage | |
- name: "Upload coverage data" | |
uses: actions/upload-artifact@v3 | |
with: | |
name: covdata | |
path: .kilopop_coverage* | |
coverage: | |
name: Coverage | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: "Check out the repo" | |
uses: "actions/checkout@v3" | |
- name: "Set up Python" | |
uses: "actions/setup-python@v4" | |
with: | |
python-version: "3.9" | |
- name: Install dependencies | |
run: | | |
sudo apt install pandoc | |
python -m pip install --upgrade pip | |
python -m pip install .[tests] | |
env: | |
LD_LIBRARY_PATH: "DUMMY" | |
- name: "Download coverage data" | |
uses: actions/download-artifact@v4 | |
with: | |
name: covdata | |
- name: Combine coverage | |
run: | | |
python -m coverage combine -q | |
python -m coverage report -m --skip-covered | |
python -m coverage json | |
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") | |
echo "total=$TOTAL" >> $GITHUB_ENV | |
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY | |
env: | |
COVERAGE_FILE: .kilopop_coverage | |
- name: "Make badge" | |
uses: schneegans/[email protected] | |
with: | |
# GIST_TOKEN is a GitHub personal access token with scope "gist". | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: f1a27976965673422ac94bc1afb240d3 # replace with your real Gist id. | |
filename: covbadge.json | |
label: Coverage | |
message: ${{ env.total }}% | |
minColorRange: 50 | |
maxColorRange: 90 | |
valColorRange: ${{ env.total }} |