ci.yaml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. name: CI
  2. on:
  3. pull_request:
  4. push:
  5. branches: [main]
  6. tags: ['v*']
  7. jobs:
  8. mypy:
  9. if: ${{ !github.event.pull_request.draft }}
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: Check out repository
  13. uses: actions/checkout@v4
  14. - uses: ./.github/actions/setup
  15. with:
  16. os: "ubuntu-latest"
  17. python-version: "3.9"
  18. venv-id: "docs"
  19. poetry-dependency-install-flags: "--all-extras --only 'main,dev'"
  20. - name: mypy
  21. run: MYPYPATH=stubs poetry run mypy src
  22. docs:
  23. if: ${{ !github.event.pull_request.draft }}
  24. runs-on: ubuntu-latest
  25. steps:
  26. - name: Check out repository
  27. uses: actions/checkout@v4
  28. - uses: ./.github/actions/setup
  29. with:
  30. os: "ubuntu-latest"
  31. python-version: "3.9"
  32. venv-id: "docs"
  33. poetry-dependency-install-flags: "--all-extras --only 'main,docs'"
  34. - name: docs
  35. run: poetry run sphinx-build -W --keep-going -T -b html docs/source docs/build
  36. tests:
  37. strategy:
  38. fail-fast: false
  39. matrix:
  40. os: [ "ubuntu-latest" ]
  41. python-version: [ "3.9", "3.10", "3.11" ]
  42. runs-on: "${{ matrix.os }}"
  43. defaults:
  44. run:
  45. # This might be needed for Windows and doesn't seem to affect unix-based systems
  46. # so we include it. If you have better proof of whether this is needed or not,
  47. # feel free to update.
  48. shell: bash
  49. steps:
  50. - name: Check out repository
  51. uses: actions/checkout@v4
  52. - uses: ./.github/actions/setup
  53. with:
  54. os: "${{ matrix.os }}"
  55. python-version: "${{ matrix.python-version }}"
  56. venv-id: "tests-${{ runner.os }}"
  57. poetry-dependency-install-flags: "--all-extras"
  58. - name: Run tests
  59. env:
  60. PYTHONPATH: src
  61. run: |
  62. poetry run pytest -r a -v src tests --import-mode=importlib --doctest-modules --cov=src --cov-report=term-missing --cov-report=xml
  63. poetry run coverage report
  64. - name: Upload coverage reports to Codecov with GitHub Action
  65. uses: codecov/codecov-action@v4.2.0
  66. env:
  67. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  68. imports-without-extras:
  69. strategy:
  70. fail-fast: false
  71. matrix:
  72. os: [ "ubuntu-latest" ]
  73. python-version: [ "3.9", "3.10", "3.11" ]
  74. runs-on: "${{ matrix.os }}"
  75. steps:
  76. - name: Check out repository
  77. uses: actions/checkout@v4
  78. - uses: ./.github/actions/setup
  79. with:
  80. python-version: "${{ matrix.python-version }}"
  81. venv-id: "imports-without-extras-${{ runner.os }}"
  82. poetry-dependency-install-flags: "--only main"
  83. - name: Check importable without extras
  84. run: poetry run python scripts/test-install.py
  85. check-build:
  86. runs-on: ubuntu-latest
  87. steps:
  88. - name: Check out repository
  89. uses: actions/checkout@v4
  90. - uses: ./.github/actions/setup
  91. with:
  92. python-version: "3.9"
  93. venv-id: "check-build-${{ runner.os }}"
  94. run-poetry-install: false
  95. poetry-dependency-install-flags: "not used"
  96. - name: Build package
  97. run: |
  98. poetry build --no-interaction
  99. - name: Check build
  100. run: |
  101. tar -tvf dist/faostat_data_primap-*.tar.gz --wildcards '*faostat_data_primap/py.typed'
  102. tar -tvf dist/faostat_data_primap-*.tar.gz --wildcards 'faostat_data_primap-*/LICENCE'
  103. check-dependency-licences:
  104. runs-on: ubuntu-latest
  105. steps:
  106. - name: Check out repository
  107. uses: actions/checkout@v4
  108. - uses: ./.github/actions/setup
  109. with:
  110. python-version: "3.9"
  111. venv-id: "licence-check"
  112. poetry-dependency-install-flags: "--all-extras"
  113. - name: Check licences of dependencies
  114. shell: bash
  115. run: |
  116. TEMP_FILE=$(mktemp)
  117. poetry self add poetry-plugin-export
  118. poetry export --without=tests --without=docs --without=dev > $TEMP_FILE
  119. poetry run liccheck -r $TEMP_FILE -R licence-check.txt
  120. cat licence-check.txt