AML support (#49) #159
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: Tests | |
on: | |
pull_request: | |
branches: [main] | |
push: | |
branches: ['*'] | |
jobs: | |
run-with-coverage: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out | |
uses: actions/checkout@v3 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.12" | |
# Cache the installation of Poetry itself. | |
- name: Cache poetry installation | |
uses: actions/cache@v3 | |
with: | |
path: ~/.local | |
key: poetry-1.3.2 | |
# Install Poetry. | |
- uses: snok/install-poetry@v1.3.3 | |
with: | |
version: latest | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
# Cache dependencies. | |
- name: Cache dependencies | |
id: cache-deps | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: pydeps-${{ runner.os }}-python-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
- name: Install dependencies and project | |
run: | | |
poetry install --no-interaction --no-root | |
poetry install --no-interaction | |
if: steps.cache-deps.outputs.cache-hit != 'true' | |
- name: Run tests with coverage | |
run: poetry run pytest --cov=ctdfjorder --cov-report=html | |
- name: Upload coverage report as artifact | |
if: success() # This step will only run if previous steps succeeded | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-report | |
path: htmlcov | |
- name: Get coverage percentage | |
id: get-coverage | |
run: | | |
coverage=$(poetry run pytest --cov=ctdfjorder --cov-report=term | grep TOTAL | awk '{print $4}' | sed 's/%//') | |
echo "ANSWER=$coverage" >> $GITHUB_ENV | |
- name: Create the Badge | |
uses: schneegans/dynamic-badges-action@v1.7.0 | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: 5ceb7e714da5151b751f668c4cc49013 | |
filename: answer.json | |
label: Coverage | |
message: ${{ env.ANSWER }} % | |
valColorRange: ${{ env.ANSWER }} | |
maxColorRange: 100 | |
minColorRange: 0 |