lint-and-test.yml 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. name: lint-and-test
  2. on:
  3. push:
  4. pull_request:
  5. types:
  6. - opened
  7. jobs:
  8. check:
  9. runs-on: ubuntu-latest
  10. name: Check (on Python 3.9)
  11. steps:
  12. - uses: actions/setup-python@v4
  13. with:
  14. python-version: 3.9
  15. - uses: actions/checkout@v3
  16. - uses: pre-commit/action@v3.0.0
  17. test:
  18. needs: check
  19. runs-on: ubuntu-latest
  20. strategy:
  21. fail-fast: false
  22. matrix:
  23. py_version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
  24. include:
  25. - python-version: "3.9"
  26. coverage: yes
  27. name: "Test (on Python ${{ matrix.py_version }})"
  28. steps:
  29. - uses: actions/setup-python@v4
  30. with:
  31. python-version: ${{ matrix.py_version }}
  32. - name: Check out src from Git
  33. uses: actions/checkout@v3
  34. - name: Get history and tags for SCM versioning to work
  35. run: |
  36. git fetch --prune --unshallow
  37. git fetch --depth=1 origin +refs/tags/*:refs/tags/*
  38. - name: Upgrade pip
  39. run: |
  40. pip3 install --upgrade pip
  41. - name: "Caching for dependencies (.txt) - restore existing or ensure new cache will be made"
  42. uses: actions/cache@v4
  43. id: cache
  44. with:
  45. path: ${{ env.pythonLocation }}
  46. # manually disable a cache if needed by (re)setting CACHE_DATE
  47. key: ${{ runner.os }}-pip-${{ env.pythonLocation }}-${{ SECRETS.CACHE_DATE }}-${{ hashFiles('**/requirements/**/*.txt') }}
  48. restore-keys: |
  49. ${{ runner.os }}-pip-
  50. - run: |
  51. ci/setup-postgres.sh
  52. sudo apt-get -y install coinor-cbc
  53. - name: Install FlexMeasures & exact dependencies for tests
  54. run: make install-for-test
  55. if: github.event_name == 'push' && steps.cache.outputs.cache-hit != 'true'
  56. - name: Install FlexMeasures & latest dependencies for tests
  57. run: make install-for-test pinned=no
  58. if: github.event_name == 'pull_request'
  59. - name: Run all doctests in the data/schemas subpackage
  60. run: pytest flexmeasures/data/schemas --doctest-modules --ignore flexmeasures/data/schemas/tests
  61. - name: Run all doctests in the utils subpackage
  62. run: pytest flexmeasures/utils --doctest-modules --ignore flexmeasures/utils/tests
  63. - name: Run all tests except those marked to be skipped by GitHub AND record coverage
  64. run: pytest -v -m "not skip_github" --cov=flexmeasures --cov-branch --cov-report=lcov
  65. - name: Coveralls
  66. uses: coverallsapp/github-action@v2
  67. with:
  68. fail-on-error: false
  69. if: ${{ matrix.coverage == 'yes' }}
  70. env:
  71. PGHOST: 127.0.0.1
  72. PGPORT: 5432
  73. PGUSER: flexmeasures_test
  74. PGDB: flexmeasures_test
  75. PGPASSWORD: flexmeasures_test
  76. services:
  77. # Label used to access the service container
  78. postgres:
  79. # Docker Hub image
  80. image: postgres:12.5
  81. env:
  82. POSTGRES_USER: flexmeasures_test
  83. POSTGRES_PASSWORD: flexmeasures_test
  84. POSTGRES_DB: flexmeasures_test
  85. ports:
  86. - 5432:5432
  87. # needed because the postgres container does not provide a healthcheck
  88. options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5