ci.yaml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. run: |
  60. poetry run pytest -r a -v src tests --doctest-modules --cov=src --cov-report=term-missing --cov-report=xml
  61. poetry run coverage report
  62. - name: Upload coverage reports to Codecov with GitHub Action
  63. uses: codecov/codecov-action@v4.2.0
  64. env:
  65. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  66. imports-without-extras:
  67. strategy:
  68. fail-fast: false
  69. matrix:
  70. os: [ "ubuntu-latest" ]
  71. python-version: [ "3.9", "3.10", "3.11" ]
  72. runs-on: "${{ matrix.os }}"
  73. steps:
  74. - name: Check out repository
  75. uses: actions/checkout@v4
  76. - uses: ./.github/actions/setup
  77. with:
  78. python-version: "${{ matrix.python-version }}"
  79. venv-id: "imports-without-extras-${{ runner.os }}"
  80. poetry-dependency-install-flags: "--only main"
  81. - name: Check importable without extras
  82. run: poetry run python scripts/test-install.py
  83. check-build:
  84. runs-on: ubuntu-latest
  85. steps:
  86. - name: Check out repository
  87. uses: actions/checkout@v4
  88. - uses: ./.github/actions/setup
  89. with:
  90. python-version: "3.9"
  91. venv-id: "check-build-${{ runner.os }}"
  92. run-poetry-install: false
  93. poetry-dependency-install-flags: "not used"
  94. - name: Build package
  95. run: |
  96. poetry build --no-interaction
  97. - name: Check build
  98. run: |
  99. tar -tvf dist/faostat_data_primap-*.tar.gz --wildcards '*faostat_data_primap/py.typed'
  100. tar -tvf dist/faostat_data_primap-*.tar.gz --wildcards 'faostat_data_primap-*/LICENCE'
  101. check-dependency-licences:
  102. runs-on: ubuntu-latest
  103. steps:
  104. - name: Check out repository
  105. uses: actions/checkout@v4
  106. - uses: ./.github/actions/setup
  107. with:
  108. python-version: "3.9"
  109. venv-id: "licence-check"
  110. poetry-dependency-install-flags: "--all-extras"
  111. - name: Check licences of dependencies
  112. shell: bash
  113. run: |
  114. TEMP_FILE=$(mktemp)
  115. poetry export --without=tests --without=docs --without=dev > $TEMP_FILE
  116. poetry run liccheck -r $TEMP_FILE -R licence-check.txt
  117. cat licence-check.txt