CURVAS dataset #341
Workflow file for this run
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 ] | |
env: | |
MODULE_NAME: amid | |
jobs: | |
test: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
python-version: [ '3.8', '3.9', '3.10', '3.11' ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Check the version | |
if: "! github.event.pull_request.head.repo.fork " | |
run: | | |
VERSION=$(python -c "from pathlib import Path; import runpy; folder, = {d.parent for d in Path().resolve().glob('*/__init__.py') if d.parent.is_dir() and (d.parent / '__version__.py').exists()}; print(runpy.run_path(folder / '__version__.py')['__version__'])") | |
MATCH=$(pip index versions $MODULE_NAME | grep "Available versions:" | grep $VERSION) || echo | |
echo $MATCH | |
if [ "$GITHUB_BASE_REF" = "master" ] && [ "$MATCH" != "" ]; then exit 1; fi | |
- name: Build the package | |
run: | | |
python setup.py sdist | |
- name: Install | |
run: | | |
pip install dist/* | |
pip install -r tests/requirements.txt | |
cd tests | |
export MODULE_PARENT=$(python -c "import $MODULE_NAME, os; print(os.path.dirname($MODULE_NAME.__path__[0]))") | |
export MODULE_PARENT=${MODULE_PARENT%"/"} | |
cd .. | |
echo $MODULE_PARENT | |
echo "MODULE_PARENT=$(echo $MODULE_PARENT)" >> $GITHUB_ENV | |
- name: Create the storage | |
if: "! github.event.pull_request.head.repo.fork " | |
env: | |
CACHE_HOST: ${{ secrets.CACHE_HOST }} | |
CACHE_HOST_KEY: ${{ secrets.CACHE_HOST_KEY }} | |
CACHE_HOST_USER: ${{ secrets.CACHE_HOST_USER }} | |
run: | | |
mkdir -p ~/.config/amid ~/.ssh | |
cat >~/.config/amid/.bev.yml <<EOL | |
local: | |
storage: '/home/runner/work/amid/amid/storage' | |
cache: '/home/runner/work/amid/amid/cache' | |
remote: | |
storage: | |
remote: | |
sftp: 'amid:bucket' | |
meta: | |
fallback: local | |
EOL | |
amid init | |
cat >~/.ssh/config <<EOL | |
Host amid | |
HostName $CACHE_HOST | |
User $CACHE_HOST_USER | |
IdentityFile ~/.ssh/amid | |
EOL | |
echo "$CACHE_HOST_KEY" > ~/.ssh/amid | |
chmod 700 ~/.ssh | |
chmod 600 ~/.ssh/amid | |
- name: Check readme generation | |
if: "! github.event.pull_request.head.repo.fork " | |
run: | | |
pip install -r docs/requirements.txt | |
BEFORE=$(sha256sum README.md) | |
python docs/fill_readme.py | |
AFTER=$(sha256sum README.md) | |
if [ "$BEFORE" != "$AFTER" ]; then echo "The README changed after table generation. Please run 'python docs/fill_readme.py'" && exit 1; fi | |
- name: Test with pytest | |
if: "! github.event.pull_request.head.repo.fork " | |
run: | | |
pytest tests -m "not raw" --junitxml=reports/junit-${{ matrix.python-version }}.xml --cov="$MODULE_PARENT/$MODULE_NAME" --cov-report=xml --cov-branch | |
- name: Generate coverage report | |
if: "! github.event.pull_request.head.repo.fork " | |
run: | | |
coverage xml -o reports/coverage-${{ matrix.python-version }}.xml | |
sed -i -e "s|$MODULE_PARENT/||g" reports/coverage-${{ matrix.python-version }}.xml | |
sed -i -e "s|$(echo $MODULE_PARENT/ | tr "/" .)||g" reports/coverage-${{ matrix.python-version }}.xml | |
- name: Upload artifacts | |
if: "! github.event.pull_request.head.repo.fork " | |
uses: actions/upload-artifact@v3 | |
with: | |
name: reports-${{ matrix.python-version }} | |
path: reports/*-${{ matrix.python-version }}.xml | |
# TODO: coverage is not informative in the CI anyway | |
# - name: Upload coverage results | |
# if: "! github.event.pull_request.head.repo.fork " | |
# uses: codecov/codecov-action@v3 | |
# with: | |
# fail_ci_if_error: true | |
# files: reports/coverage-${{ matrix.python-version }}.xml | |
# verbose: true |