ci.yaml 3.8 KB

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